Rev 3745: Change 'bzr merge' so that it uses --reprocess as long as --show-base is not given. in http://bzr.arbash-meinel.com/branches/bzr/1.8-dev/merge_reprocess
John Arbash Meinel
john at arbash-meinel.com
Mon Sep 29 23:57:07 BST 2008
At http://bzr.arbash-meinel.com/branches/bzr/1.8-dev/merge_reprocess
------------------------------------------------------------
revno: 3745
revision-id: john at arbash-meinel.com-20080929225644-ke56t6jna3lmthut
parent: pqm at pqm.ubuntu.com-20080926211130-ojyixbni0jpqoify
committer: John Arbash Meinel <john at arbash-meinel.com>
branch nick: merge_reprocess
timestamp: Mon 2008-09-29 17:56:44 -0500
message:
Change 'bzr merge' so that it uses --reprocess as long as --show-base is not given.
-------------- next part --------------
=== modified file 'NEWS'
--- a/NEWS 2008-09-26 21:11:30 +0000
+++ b/NEWS 2008-09-29 22:56:44 +0000
@@ -15,6 +15,9 @@
towards your mainline. This simplifies the output, makes it faster,
and reduces memory consumption. (John Arbash Meinel)
+ * ``bzr merge`` now defaults to having ``--reprocess`` set, whenever
+ ``--show-base`` is not supplied. (John Arbash Meinel)
+
* ``bzr+http//`` will now optionally load plugins and write logs on the
server. (Marius Kruger)
=== modified file 'bzrlib/builtins.py'
--- a/bzrlib/builtins.py 2008-09-24 13:43:48 +0000
+++ b/bzrlib/builtins.py 2008-09-29 22:56:44 +0000
@@ -2908,7 +2908,7 @@
]
def run(self, location=None, revision=None, force=False,
- merge_type=None, show_base=False, reprocess=False, remember=False,
+ merge_type=None, show_base=False, reprocess=None, remember=False,
uncommitted=False, pull=False,
directory=None,
preview=False,
@@ -3017,6 +3017,12 @@
not merger.merge_type is _mod_merge.Merge3Merger):
raise errors.BzrCommandError("Show-base is not supported for this"
" merge type. %s" % merger.merge_type)
+ if merger.reprocess is None:
+ if merger.show_base:
+ merger.reprocess = False
+ else:
+ # Use reprocess if the merger supports it
+ merger.reprocess = merger.merge_type.supports_reprocess
if merger.reprocess and not merger.merge_type.supports_reprocess:
raise errors.BzrCommandError("Conflict reduction is not supported"
" for merge type %s." %
=== modified file 'bzrlib/tests/blackbox/test_merge.py'
--- a/bzrlib/tests/blackbox/test_merge.py 2008-08-02 17:10:50 +0000
+++ b/bzrlib/tests/blackbox/test_merge.py 2008-09-29 22:56:44 +0000
@@ -44,6 +44,24 @@
tree.commit(message='setup')
return tree
+ def create_conflicting_branches(self):
+ """Create two branches which have overlapping modifications.
+
+ :return: (tree, other_branch) Where merging other_branch causes a file
+ conflict.
+ """
+ builder = self.make_branch_builder('branch')
+ builder.build_snapshot('rev1', None,
+ [('add', ('', 'root-id', 'directory', None)),
+ ('add', ('fname', 'f-id', 'file', 'a\nb\nc\n'))])
+ builder.build_snapshot('rev2other', ['rev1'],
+ [('modify', ('f-id', 'a\nB\nD\n'))])
+ other = builder.get_branch().bzrdir.sprout('other').open_branch()
+ builder.build_snapshot('rev2this', ['rev1'],
+ [('modify', ('f-id', 'a\nB\nC\n'))])
+ tree = builder.get_branch().create_checkout('tree', lightweight=True)
+ return tree, other
+
def test_merge_reprocess(self):
d = BzrDir.create_standalone_workingtree('.')
d.commit('h')
@@ -101,6 +119,58 @@
self.run_bzr('merge ../b -r last:1')
self.assertEqual([a_tip], a.get_parent_ids())
+ def test_merge_defaults_to_reprocess(self):
+ tree, other = self.create_conflicting_branches()
+ # The default merge algorithm should enable 'reprocess' because
+ # 'show-base' is not set
+ self.run_bzr('merge ../other', working_dir='tree')
+ self.assertEqualDiff('a\n'
+ 'B\n'
+ '<<<<<<< TREE\n'
+ 'C\n'
+ '=======\n'
+ 'D\n'
+ '>>>>>>> MERGE-SOURCE\n',
+ tree.get_file_text('f-id'))
+
+ def test_merge_explicit_reprocess_show_base(self):
+ tree, other = self.create_conflicting_branches()
+ # Explicitly setting --reprocess, and --show-base is an error
+ self.run_bzr_error(['Cannot do conflict reduction and show base'],
+ 'merge ../other --reprocess --show-base',
+ working_dir='tree')
+
+ def test_merge_override_reprocess(self):
+ tree, other = self.create_conflicting_branches()
+ # Explicitly disable reprocess
+ self.run_bzr('merge ../other --no-reprocess', working_dir='tree')
+ self.assertEqualDiff('a\n'
+ '<<<<<<< TREE\n'
+ 'B\n'
+ 'C\n'
+ '=======\n'
+ 'B\n'
+ 'D\n'
+ '>>>>>>> MERGE-SOURCE\n',
+ tree.get_file_text('f-id'))
+
+ def test_merge_override_show_base(self):
+ tree, other = self.create_conflicting_branches()
+ # Setting '--show-base' will auto-disable '--reprocess'
+ self.run_bzr('merge ../other --show-base', working_dir='tree')
+ self.assertEqualDiff('a\n'
+ '<<<<<<< TREE\n'
+ 'B\n'
+ 'C\n'
+ '||||||| BASE-REVISION\n'
+ 'b\n'
+ 'c\n'
+ '=======\n'
+ 'B\n'
+ 'D\n'
+ '>>>>>>> MERGE-SOURCE\n',
+ tree.get_file_text('f-id'))
+
def test_merge_with_missing_file(self):
"""Merge handles missing file conflicts"""
self.build_tree_contents([
More information about the bazaar-commits
mailing list