~abentley/bzrtools/bzrtools.dev

« back to all changes in this revision

Viewing changes to colordiff.py

  • Committer: Aaron Bentley
  • Date: 2006-06-18 03:10:54 UTC
  • Revision ID: aaron.bentley@utoronto.ca-20060618031054-6c23097a4fd88d1d
Don't just assume we get lines

Show diffs side-by-side

added added

removed removed

Lines of Context:
40
40
    def __init__(self, target):
41
41
        self.target = target
42
42
        self.lp = LineParser()
 
43
        self.chunks = []
43
44
 
44
45
    def write(self, text):
45
 
        item = self.lp.parse_line(text)
 
46
        newstuff = text.split('\n')
 
47
        for newchunk in newstuff[:-1]:
 
48
            self._writeline(''.join(self.chunks + [newchunk, '\n']))
 
49
            self.chunks = []
 
50
        self.chunks = [newstuff[-1]]
 
51
 
 
52
    def _writeline(self, line):
 
53
        item = self.lp.parse_line(line)
46
54
        if isinstance(item, Hunk):
47
55
            self.target.write(colorstring(str(item), 'blue'))
48
56
        elif isinstance(item, InsertLine):