~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/merge.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:
124
124
 
125
125
    def new_contents_conflict(self, filename, other_contents):
126
126
        """Conflicting contents for newly added file."""
127
 
        other.contents.apply(filename + ".OTHER")
 
127
        other_contents(filename + ".OTHER", self, False)
128
128
        self.conflict("Conflict in newly added file %s" % filename)
129
129
    
130
130
 
242
242
def merge(other_revision, base_revision,
243
243
          check_clean=True, ignore_zero=False,
244
244
          this_dir=None, backup_files=False, merge_type=ApplyMerge3,
245
 
          file_list=None):
 
245
          file_list=None, show_base=False):
246
246
    """Merge changes into a tree.
247
247
 
248
248
    base_revision
323
323
                                      " tree." % fname)
324
324
    merge_inner(this_branch, other_tree, base_tree, tempdir=None, 
325
325
                ignore_zero=ignore_zero, backup_files=backup_files, 
326
 
                merge_type=merge_type, interesting_ids=interesting_ids)
 
326
                merge_type=merge_type, interesting_ids=interesting_ids,
 
327
                show_base=show_base)
327
328
    if base_is_ancestor and other_rev_id is not None\
328
329
        and other_rev_id not in this_branch.revision_history():
329
330
        this_branch.add_pending_merge(other_rev_id)
339
340
 
340
341
def merge_inner(this_branch, other_tree, base_tree, tempdir=None, 
341
342
                ignore_zero=False, merge_type=ApplyMerge3, backup_files=False,
342
 
                interesting_ids=None):
 
343
                interesting_ids=None, show_base=False):
343
344
    """Primary interface for merging. 
344
345
 
345
346
    typical use is probably 
352
353
        _tempdir = tempdir
353
354
    try:
354
355
        _merge_inner(this_branch, other_tree, base_tree, _tempdir,
355
 
                     ignore_zero, merge_type, backup_files, interesting_ids)
 
356
                     ignore_zero, merge_type, backup_files, interesting_ids,
 
357
                     show_base=show_base)
356
358
    finally:
357
359
        if tempdir is None:
358
360
            shutil.rmtree(_tempdir)
360
362
 
361
363
def _merge_inner(this_branch, other_tree, base_tree, user_tempdir, 
362
364
                ignore_zero=False, merge_type=ApplyMerge3, backup_files=False,
363
 
                interesting_ids=None):
 
365
                interesting_ids=None, show_base=False):
364
366
    def merge_factory(file_id, base, other):
365
 
        contents_change = merge_type(file_id, base, other)
 
367
        if show_base is True:
 
368
            contents_change = merge_type(file_id, base, other, show_base=True)
 
369
        else:
 
370
            contents_change = merge_type(file_id, base, other)
366
371
        if backup_files:
367
372
            contents_change = BackupBeforeChange(contents_change)
368
373
        return contents_change