/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar

« back to all changes in this revision

Viewing changes to bzrlib/merge_core.py

  • Committer: Robert Collins
  • Date: 2005-10-20 04:08:12 UTC
  • mfrom: (1185.12.68)
  • Revision ID: robertc@robertcollins.net-20051020040812-fecd1bc32aa3478e
Merge from Aaron Bentley.

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))
221
227
        return merge_factory(entry.id, base, other)
222
228
 
223
229
    if isinstance(contents, changeset.ReplaceContents):
224
 
        if contents.old_contents is None and contents.new_contents is None:
 
230
        base_contents = contents.old_contents
 
231
        other_contents = contents.new_contents
 
232
        if base_contents is None and other_contents is None:
225
233
            return None
226
 
        if contents.new_contents is None:
 
234
        if other_contents is None:
227
235
            this_contents = get_contents(this, entry.id)
228
236
            if this_path is not None and bzrlib.osutils.lexists(this_path):
229
 
                if this_contents != contents.old_contents:
 
237
                if this_contents != base_contents:
230
238
                    return conflict_handler.rem_contents_conflict(this_path, 
231
 
                        this_contents, contents.old_contents)
 
239
                        this_contents, base_contents)
232
240
                return contents
233
241
            else:
234
242
                return None
235
 
        elif contents.old_contents is None:
 
243
        elif base_contents is None:
236
244
            if this_path is None or not bzrlib.osutils.lexists(this_path):
237
245
                return contents
238
246
            else:
239
247
                this_contents = get_contents(this, entry.id)
240
 
                if this_contents == contents.new_contents:
 
248
                if this_contents == other_contents:
241
249
                    return None
242
250
                else:
243
251
                    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):
 
252
                        other_contents)
 
253
        elif isinstance(base_contents, changeset.TreeFileCreate) and \
 
254
            isinstance(other_contents, changeset.TreeFileCreate):
247
255
            return make_merge()
248
256
        else:
249
257
            this_contents = get_contents(this, entry.id)
250
 
            if this_contents == contents.old_contents:
 
258
            if this_contents == base_contents:
251
259
                return contents
252
 
            elif this_contents == contents.new_contents:
 
260
            elif this_contents == other_contents:
253
261
                return None
254
 
            elif contents.old_contents == contents.new_contents:
 
262
            elif base_contents == other_contents:
255
263
                return None
256
264
            else:
257
 
                conflict_handler.threeway_contents_conflict(this_path, 
258
 
                    this_contents, contents.old_contents,
259
 
                    contents.new_contents)
 
265
                conflict_handler.threeway_contents_conflict(this_path,
 
266
                                                            this_contents,
 
267
                                                            base_contents,
 
268
                                                            other_contents)
260
269
                
261
270
 
262
271
def make_merged_metadata(entry, base, other):