~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/merge3.py

  • Committer: Martin Pool
  • Date: 2005-07-05 08:30:08 UTC
  • Revision ID: mbp@sourcefrog.net-20050705083008-4e40cfceb9f6bdb1
- new Merge3.merge_groups feeds back the merged lines

Show diffs side-by-side

added added

removed removed

Lines of Context:
68
68
        self.b_ops = SequenceMatcher(None, base, b).get_opcodes()
69
69
 
70
70
 
 
71
 
 
72
    def merge_groups(self):
 
73
        """Yield sequence of line groups.  Each one is a tuple:
 
74
 
 
75
        'unchanged', lines
 
76
             Lines unchanged from base
 
77
 
 
78
        'a', lines
 
79
             Lines taken from a
 
80
 
 
81
        'b', lines
 
82
             Lines taken from b
 
83
 
 
84
        'conflict', base_lines, a_lines, b_lines
 
85
             Lines from base were changed to either a or b and conflict.
 
86
        """
 
87
        for t in self.merge_regions():
 
88
            what = t[0]
 
89
            if what == 'unchanged':
 
90
                yield what, self.base[t[1]:t[2]]
 
91
            elif what == 'a':
 
92
                yield what, self.a[t[1]:t[2]]
 
93
            elif what == 'b':
 
94
                yield what, self.b[t[1]:t[2]]
 
95
            elif what == 'conflict':
 
96
                yield (what,
 
97
                       self.base[t[1]:t[2]],
 
98
                       self.a[t[3]:t[4]],
 
99
                       self.b[t[5]:t[6]])
 
100
            else:
 
101
                raise ValueError(what)
 
102
 
 
103
 
71
104
    def merge_regions(self):
72
105
        """Return sequences of matching and conflicting regions.
73
106
 
122
155
                elif equal_b and not equal_a:
123
156
                    yield 'a', ia, amatch
124
157
                elif not equal_a and not equal_b:
125
 
                    yield 'conflict', ia, amatch, ib, bmatch
 
158
                    yield 'conflict', iz, zmatch, ia, amatch, ib, bmatch
126
159
                else:
127
160
                    assert 0
128
161