Rev 4674: Don't allow merge on top of pending merges without --force. in file:///home/vila/src/bzr/bugs/merge-strict/
Vincent Ladeuil
v.ladeuil+lp at free.fr
Tue Sep 8 17:42:51 BST 2009
At file:///home/vila/src/bzr/bugs/merge-strict/
------------------------------------------------------------
revno: 4674
revision-id: v.ladeuil+lp at free.fr-20090908164251-8lskfhs8f9aclnnp
parent: v.ladeuil+lp at free.fr-20090908153936-bi89hl7i6h3djzcv
committer: Vincent Ladeuil <v.ladeuil+lp at free.fr>
branch nick: merge-strict
timestamp: Tue 2009-09-08 18:42:51 +0200
message:
Don't allow merge on top of pending merges without --force.
* bzrlib/tests/blackbox/test_merge.py:
(TestMergeForce.test_merge_force,
TestMergeForce.test_merge_with_uncommitted_changes,
TestMergeForce): Complete tests around --force including pending
merges.
* bzrlib/builtins.py:
(cmd_merge.run): Check pending merges too.
-------------- next part --------------
=== modified file 'bzrlib/builtins.py'
--- a/bzrlib/builtins.py 2009-08-28 05:00:33 +0000
+++ b/bzrlib/builtins.py 2009-09-08 16:42:51 +0000
@@ -3653,13 +3653,14 @@
verified = 'inapplicable'
tree = WorkingTree.open_containing(directory)[0]
- # die as quickly as possible if there are uncommitted changes
try:
basis_tree = tree.revision_tree(tree.last_revision())
except errors.NoSuchRevision:
basis_tree = tree.basis_tree()
+
+ # die as quickly as possible if there are uncommitted changes
if not force:
- if tree.has_changes(basis_tree):
+ if tree.has_changes(basis_tree) or len(tree.get_parent_ids()) > 1:
raise errors.UncommittedChanges(tree)
view_info = _get_view_info_for_change_reporter(tree)
=== modified file 'bzrlib/tests/blackbox/test_merge.py'
--- a/bzrlib/tests/blackbox/test_merge.py 2009-09-08 15:39:36 +0000
+++ b/bzrlib/tests/blackbox/test_merge.py 2009-09-08 16:42:51 +0000
@@ -25,6 +25,7 @@
branch,
bzrdir,
conflicts,
+ errors,
merge_directive,
osutils,
tests,
@@ -589,18 +590,31 @@
self.failUnlessExists('this/other_file')
-class TestMergeForce(TestMerge):
+class TestMergeForce(tests.TestCaseWithTransport):
- def test_merge_force(self):
- tree_a = self.make_branch_and_tree('a')
+ def setUp(self):
+ super(TestMergeForce, self).setUp()
+ self.tree_a = self.make_branch_and_tree('a')
self.build_tree(['a/foo'])
- tree_a.add(['foo'])
- tree_a.commit('add file')
- tree_b = tree_a.bzrdir.sprout('b').open_workingtree()
+ self.tree_a.add(['foo'])
+ self.tree_a.commit('add file')
+ self.tree_b = self.tree_a.bzrdir.sprout('b').open_workingtree()
self.build_tree_contents([('a/foo', 'change 1')])
- tree_a.commit('change file')
- tree_b.merge_from_branch(tree_a.branch)
- tree_a.commit('empty change to allow merge to run')
+ self.tree_a.commit('change file')
+ self.tree_b.merge_from_branch(self.tree_a.branch)
+
+ def test_merge_force(self):
+ self.tree_a.commit('empty change to allow merge to run')
+ # Second merge on top if the uncommitted one
self.run_bzr(['merge', '../a', '--force'], working_dir='b')
+ def test_merge_with_uncommitted_changes(self):
+ self.run_bzr_error(['Working tree .* has uncommitted changes'],
+ ['merge', '../a'], working_dir='b')
+
+ def test_merge_with_pending_merges(self):
+ # Revert the changes keeping the pending merge
+ self.run_bzr(['revert', 'b'])
+ self.run_bzr_error(['Working tree .* has uncommitted changes'],
+ ['merge', '../a'], working_dir='b')
More information about the bazaar-commits
mailing list