~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/merge.py

  • Committer: Aaron Bentley
  • Date: 2005-07-28 18:46:35 UTC
  • mto: (1092.1.41) (1185.3.4) (974.1.47)
  • mto: This revision was merged to the branch mainline in revision 1020.
  • Revision ID: abentley@panoramicfeedback.com-20050728184635-2461268fd9d1e8d1
Added default backups for merge-revert

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
from merge_core import merge_flex
 
1
from merge_core import merge_flex, ApplyMerge3, BackupBeforeChange
2
2
from changeset import generate_changeset, ExceptionConflictHandler
3
3
from changeset import Inventory, Diff3Merge
4
 
from merge_core import ApplyMerge3
5
4
from bzrlib import find_branch
6
5
import bzrlib.osutils
7
6
from bzrlib.errors import BzrCommandError
166
165
 
167
166
def merge(other_revision, base_revision,
168
167
          check_clean=True, ignore_zero=False,
169
 
          this_dir=None):
 
168
          this_dir=None, backup_files=False):
170
169
    """Merge changes into a tree.
171
170
 
172
171
    base_revision
202
201
            base_revision = ['.', base_revno]
203
202
        base_branch, base_tree = get_tree(base_revision, tempdir, "base")
204
203
        merge_inner(this_branch, other_tree, base_tree, tempdir, 
205
 
                    ignore_zero=ignore_zero)
 
204
                    ignore_zero=ignore_zero, backup_files=backup_files)
206
205
    finally:
207
206
        shutil.rmtree(tempdir)
208
207
 
232
231
 
233
232
 
234
233
def merge_inner(this_branch, other_tree, base_tree, tempdir, 
235
 
                ignore_zero=False, merge_type="diff3"):
 
234
                ignore_zero=False, merge_type="diff3", backup_files=False):
236
235
    merge_types = {"merge3": ApplyMerge3, 
237
236
                   "diff3": Diff3Merge}
238
237
 
239
238
    def merge_factory(base_file, other_file):
240
 
        return merge_types[merge_type](base_file, other_file)
 
239
        contents_change = merge_types[merge_type](base_file, other_file)
 
240
        if backup_files:
 
241
            contents_change = BackupBeforeChange(contents_change)
 
242
        return contents_change
241
243
 
242
244
    this_tree = get_tree((this_branch.base, None), tempdir, "this")[1]
243
245