~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/merge_core.py

  • Committer: Michael Ellerman
  • Date: 2005-10-26 10:03:47 UTC
  • mfrom: (1185.16.116)
  • mto: (1185.16.126)
  • mto: This revision was merged to the branch mainline in revision 1488.
  • Revision ID: michael@ellerman.id.au-20051026100347-bb0b2bd42f7953f2
MergeĀ mainline.

Show diffs side-by-side

added added

removed removed

Lines of Context:
9
9
 
10
10
class ApplyMerge3:
11
11
    """Contents-change wrapper around merge3.Merge3"""
12
 
    def __init__(self, file_id, base, other):
 
12
    def __init__(self, file_id, base, other, show_base=False):
13
13
        self.file_id = file_id
14
14
        self.base = base
15
15
        self.other = other
 
16
        self.show_base = show_base
16
17
 
17
18
    def is_creation(self):
18
19
        return False
49
50
        new_conflicts = False
50
51
        output_file = file(new_file, "wb")
51
52
        start_marker = "!START OF MERGE CONFLICT!" + "I HOPE THIS IS UNIQUE"
 
53
        if self.show_base is True:
 
54
            base_marker = '|' * 7
 
55
        else:
 
56
            base_marker = None
52
57
        for line in m3.merge_lines(name_a = "TREE", name_b = "MERGE-SOURCE", 
53
 
                       start_marker=start_marker):
 
58
                       name_base = "BASE-REVISION",
 
59
                       start_marker=start_marker, base_marker=base_marker):
54
60
            if line.startswith(start_marker):
55
61
                new_conflicts = True
56
62
                output_file.write(line.replace(start_marker, '<' * 7))
109
115
                                    conflict_handler, merge_factory)
110
116
    result = apply_changeset(new_cset, invert_invent(this.inventory),
111
117
                             this.basedir, conflict_handler, False)
112
 
    conflict_handler.finalize()
113
118
    return result
114
 
 
115
119
    
116
120
 
117
121
def make_merge_changeset(cset, this, base, other, 
221
225
        return merge_factory(entry.id, base, other)
222
226
 
223
227
    if isinstance(contents, changeset.ReplaceContents):
224
 
        if contents.old_contents is None and contents.new_contents is None:
 
228
        base_contents = contents.old_contents
 
229
        other_contents = contents.new_contents
 
230
        if base_contents is None and other_contents is None:
225
231
            return None
226
 
        if contents.new_contents is None:
 
232
        if other_contents is None:
227
233
            this_contents = get_contents(this, entry.id)
228
234
            if this_path is not None and bzrlib.osutils.lexists(this_path):
229
 
                if this_contents != contents.old_contents:
 
235
                if this_contents != base_contents:
230
236
                    return conflict_handler.rem_contents_conflict(this_path, 
231
 
                        this_contents, contents.old_contents)
 
237
                        this_contents, base_contents)
232
238
                return contents
233
239
            else:
234
240
                return None
235
 
        elif contents.old_contents is None:
 
241
        elif base_contents is None:
236
242
            if this_path is None or not bzrlib.osutils.lexists(this_path):
237
243
                return contents
238
244
            else:
239
245
                this_contents = get_contents(this, entry.id)
240
 
                if this_contents == contents.new_contents:
 
246
                if this_contents == other_contents:
241
247
                    return None
242
248
                else:
243
249
                    conflict_handler.new_contents_conflict(this_path, 
244
 
                                                           other_contents)
245
 
        elif isinstance(contents.old_contents, changeset.TreeFileCreate) and \
246
 
            isinstance(contents.new_contents, changeset.TreeFileCreate):
 
250
                        other_contents)
 
251
        elif isinstance(base_contents, changeset.TreeFileCreate) and \
 
252
            isinstance(other_contents, changeset.TreeFileCreate):
247
253
            return make_merge()
248
254
        else:
249
255
            this_contents = get_contents(this, entry.id)
250
 
            if this_contents == contents.old_contents:
 
256
            if this_contents == base_contents:
251
257
                return contents
252
 
            elif this_contents == contents.new_contents:
 
258
            elif this_contents == other_contents:
253
259
                return None
254
 
            elif contents.old_contents == contents.new_contents:
 
260
            elif base_contents == other_contents:
255
261
                return None
256
262
            else:
257
 
                conflict_handler.threeway_contents_conflict(this_path, 
258
 
                    this_contents, contents.old_contents,
259
 
                    contents.new_contents)
 
263
                conflict_handler.threeway_contents_conflict(this_path,
 
264
                                                            this_contents,
 
265
                                                            base_contents,
 
266
                                                            other_contents)
260
267
                
261
268
 
262
269
def make_merged_metadata(entry, base, other):