Rev 4682: (vila) Handle pending merges as uncommitted changes in file:///home/pqm/archives/thelove/bzr/%2Btrunk/
Canonical.com Patch Queue Manager
pqm at pqm.ubuntu.com
Wed Sep 9 17:21:07 BST 2009
At file:///home/pqm/archives/thelove/bzr/%2Btrunk/
------------------------------------------------------------
revno: 4682 [merge]
revision-id: pqm at pqm.ubuntu.com-20090909162106-ar32j79ayhfrkap3
parent: pqm at pqm.ubuntu.com-20090909151627-572a71uyxs8evrex
parent: v.ladeuil+lp at free.fr-20090909154352-zmyiya46nukx3vu7
committer: Canonical.com Patch Queue Manager <pqm at pqm.ubuntu.com>
branch nick: +trunk
timestamp: Wed 2009-09-09 17:21:06 +0100
message:
(vila) Handle pending merges as uncommitted changes
modified:
NEWS NEWS-20050323055033-4e00b5db738777ff
bzrlib/builtins.py builtins.py-20050830033751-fc01482b9ca23183
bzrlib/tests/blackbox/test_merge.py test_merge.py-20060323225809-9bc0459c19917f41
bzrlib/tests/blackbox/test_remove_tree.py test_remove_tree.py-20061110192919-5j3xjciiaqbs2dvo-1
=== modified file 'NEWS'
--- a/NEWS 2009-09-09 13:05:33 +0000
+++ b/NEWS 2009-09-09 15:43:52 +0000
@@ -37,6 +37,10 @@
* ``bzr info -v`` on a 2a format still claimed that it was a "Development
format" (John Arbash Meinel, #424392)
+* ``bzr merge`` and ``bzr remove-tree`` now requires --force if pending
+ merges are present in the working tree.
+ (Vincent Ladeuil, #426344)
+
* Clearer message when Bazaar runs out of memory, instead of a ``MemoryError``
traceback. (Martin Pool, #109115)
=== modified file 'bzrlib/builtins.py'
--- a/bzrlib/builtins.py 2009-08-28 05:00:33 +0000
+++ b/bzrlib/builtins.py 2009-09-08 16:45:11 +0000
@@ -461,8 +461,8 @@
raise errors.BzrCommandError("You cannot remove the working tree"
" of a remote path")
if not force:
- # XXX: What about pending merges ? -- vila 20090629
- if working.has_changes(working.basis_tree()):
+ if (working.has_changes(working.basis_tree())
+ or len(working.get_parent_ids()) > 1):
raise errors.UncommittedChanges(working)
working_path = working.bzrdir.root_transport.base
@@ -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-09 14:39:29 +0000
+++ b/bzrlib/tests/blackbox/test_merge.py 2009-09-09 15:43:52 +0000
@@ -25,6 +25,7 @@
branch,
bzrdir,
conflicts,
+ errors,
merge_directive,
osutils,
tests,
@@ -591,16 +592,29 @@
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')
=== modified file 'bzrlib/tests/blackbox/test_remove_tree.py'
--- a/bzrlib/tests/blackbox/test_remove_tree.py 2009-03-23 14:59:43 +0000
+++ b/bzrlib/tests/blackbox/test_remove_tree.py 2009-09-08 16:45:11 +0000
@@ -122,3 +122,30 @@
self.run_bzr('remove-tree branch1 --force')
self.failIfExists('branch1/foo')
self.failUnlessExists('branch1/bar')
+
+ def test_remove_tree_pending_merges(self):
+ self.run_bzr(['branch', 'branch1', 'branch2'])
+ self.build_tree(['branch1/bar'])
+ self.tree.add('bar')
+ self.tree.commit('2')
+ self.failUnlessExists('branch1/bar')
+ self.run_bzr(['merge', '../branch1'], working_dir='branch2')
+ self.failUnlessExists('branch2/bar')
+ self.run_bzr(['revert', '.'], working_dir='branch2')
+ self.failIfExists('branch2/bar')
+ output = self.run_bzr_error(["Working tree .* has uncommitted changes"],
+ 'remove-tree branch2', retcode=3)
+
+ def test_remove_tree_pending_merges_force(self):
+ self.run_bzr(['branch', 'branch1', 'branch2'])
+ self.build_tree(['branch1/bar'])
+ self.tree.add('bar')
+ self.tree.commit('2')
+ self.failUnlessExists('branch1/bar')
+ self.run_bzr(['merge', '../branch1'], working_dir='branch2')
+ self.failUnlessExists('branch2/bar')
+ self.run_bzr(['revert', '.'], working_dir='branch2')
+ self.failIfExists('branch2/bar')
+ self.run_bzr('remove-tree branch2 --force')
+ self.failIfExists('branch2/foo')
+ self.failIfExists('branch2/bar')
More information about the bazaar-commits
mailing list