~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:48:02 UTC
  • Revision ID: mbp@sourcefrog.net-20050705084802-b1c1d199d28d04ea
- More merge3 cvs-form stuff

Show diffs side-by-side

added added

removed removed

Lines of Context:
70
70
 
71
71
 
72
72
    def merge_lines(self,
73
 
                    start_marker='<<<<<<<<\n',
74
 
                    mid_marker='========\n',
75
 
                    end_marker='>>>>>>>>\n'):
 
73
                    name_a=None,
 
74
                    name_b=None,
 
75
                    start_marker='<<<<<<<<',
 
76
                    mid_marker='========',
 
77
                    end_marker='>>>>>>>>',
 
78
                    show_base=False):
76
79
        """Return merge in cvs-like form.
77
80
        """
 
81
        if name_a:
 
82
            start_marker = start_marker + ' ' + name_a
 
83
        if name_b:
 
84
            end_marker = end_marker + ' ' + name_b
 
85
            
78
86
        for t in self.merge_regions():
79
87
            what = t[0]
80
88
            if what == 'unchanged':
87
95
                for i in range(t[1], t[2]):
88
96
                    yield self.b[i]
89
97
            elif what == 'conflict':
90
 
                yield start_marker
 
98
                yield start_marker + '\n'
91
99
                for i in range(t[3], t[4]):
92
100
                    yield self.a[i]
93
 
                yield mid_marker
 
101
                yield mid_marker + '\n'
94
102
                for i in range(t[5], t[6]):
95
103
                    yield self.b[i]
96
 
                yield end_marker
 
104
                yield end_marker + '\n'
97
105
            else:
98
106
                raise ValueError(what)
99
107
        
292
300
                del bm[0]
293
301
                
294
302
        return unc
 
303
 
 
304
 
 
305
def main(argv):
 
306
    base = file(argv[1], 'rt').readlines()
 
307
    a = file(argv[2], 'rt').readlines()
 
308
    b = file(argv[3], 'rt').readlines()
 
309
 
 
310
    m3 = Merge3(base, a, b)
 
311
 
 
312
    sys.stdout.writelines(m3.merge_lines(argv[2], argv[3]))
 
313
 
 
314
 
 
315
if __name__ == '__main__':
 
316
    import sys
 
317
    sys.exit(main(sys.argv))