~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:37:09 UTC
  • Revision ID: mbp@sourcefrog.net-20050705083709-8a5107dea678b14a
- code to represent merges in regular text conflict form

Show diffs side-by-side

added added

removed removed

Lines of Context:
69
69
 
70
70
 
71
71
 
 
72
    def merge_lines(self,
 
73
                    start_marker='<<<<<<<<\n',
 
74
                    mid_marker='========\n',
 
75
                    end_marker='>>>>>>>>\n'):
 
76
        """Return merge in cvs-like form.
 
77
        """
 
78
        for t in self.merge_regions():
 
79
            what = t[0]
 
80
            if what == 'unchanged':
 
81
                for i in range(t[1], t[2]):
 
82
                    yield self.base[i]
 
83
            elif what == 'a':
 
84
                for i in range(t[1], t[2]):
 
85
                    yield self.a[i]
 
86
            elif what == 'b':
 
87
                for i in range(t[1], t[2]):
 
88
                    yield self.b[i]
 
89
            elif what == 'conflict':
 
90
                yield start_marker
 
91
                for i in range(t[3], t[4]):
 
92
                    yield self.a[i]
 
93
                yield mid_marker
 
94
                for i in range(t[5], t[6]):
 
95
                    yield self.b[i]
 
96
                yield end_marker
 
97
            else:
 
98
                raise ValueError(what)
 
99
        
 
100
        
 
101
 
 
102
 
 
103
 
72
104
    def merge_groups(self):
73
105
        """Yield sequence of line groups.  Each one is a tuple:
74
106