~abentley/bzrtools/bzrtools.dev

« back to all changes in this revision

Viewing changes to colordiff.py

  • Committer: Aaron Bentley
  • Date: 2007-01-17 15:57:28 UTC
  • Revision ID: abentley@panoramicfeedback.com-20070117155728-uhertlirgksegd9d
Update from review comments

Show diffs side-by-side

added added

removed removed

Lines of Context:
104
104
            line_class = 'diffstuff'
105
105
            self._analyse_old_new()
106
106
        elif isinstance(item, InsertLine):
107
 
            if str(line).rstrip('\n').endswith(' '):
 
107
            if item.contents.endswith(' \n'):
108
108
                self.added_trailing_whitespace += 1
109
109
            line_class = 'newtext'
110
 
            self._new_lines.append(line)
 
110
            self._new_lines.append(item)
111
111
        elif isinstance(item, RemoveLine):
112
112
            line_class = 'oldtext'
113
 
            self._old_lines.append(line)
 
113
            self._old_lines.append(item)
114
114
        elif isinstance(item, basestring) and item.startswith('==='):
115
115
            line_class = 'metaline'
116
116
            self._analyse_old_new()
133
133
            return
134
134
        if not self.check_style:
135
135
            return
136
 
        old = [l[1:] for l in self._old_lines]
137
 
        new = [l[1:] for l in self._new_lines]
138
 
        ws_matched = self._matched_lines(self._old_lines, self._new_lines)
139
 
        old = [l[1:].rstrip() for l in self._old_lines]
140
 
        new = [l[1:].rstrip() for l in self._new_lines]
 
136
        old = [l.contents for l in self._old_lines]
 
137
        new = [l.contents for l in self._new_lines]
 
138
        ws_matched = self._matched_lines(old, new)
 
139
        old = [l.rstrip() for l in old]
 
140
        new = [l.rstrip() for l in new]
141
141
        no_ws_matched = self._matched_lines(old, new)
142
142
        assert no_ws_matched >= ws_matched
143
143
        if no_ws_matched > ws_matched:
156
156
        sys.stdout = real_stdout
157
157
    if check_style:
158
158
        if dw.added_trailing_whitespace > 0:
159
 
            trace.warning('%d new line(s) has trailing whitespace.' %
 
159
            trace.warning('%d new line(s) have trailing whitespace.' %
160
160
                          dw.added_trailing_whitespace)
161
161
        if dw.spurious_whitespace > 0:
162
 
            trace.warning('%d line(s) has spurious whitespace changes' %
 
162
            trace.warning('%d line(s) have spurious whitespace changes' %
163
163
                          dw.spurious_whitespace)
164
164