Merge lp:~mgiuca/bzr/remove-tree-shelved into lp:bzr

Proposed by Matt Giuca
Status: Merged
Approved by: Martin Pool
Approved revision: no longer in the source branch.
Merged at revision: 5282
Proposed branch: lp:~mgiuca/bzr/remove-tree-shelved
Merge into: lp:bzr
Diff against target: 73 lines (+29/-1)
3 files modified
bzrlib/builtins.py (+3/-1)
bzrlib/errors.py (+6/-0)
bzrlib/tests/blackbox/test_remove_tree.py (+20/-0)
To merge this branch: bzr merge lp:~mgiuca/bzr/remove-tree-shelved
Reviewer Review Type Date Requested Status
Martin Pool Approve
Alexander Belchenko Approve
Review via email: mp+26272@code.launchpad.net

Commit message

remove-tree now refuses to run without --force if there are shelved changes. (#586639)

Description of the change

remove-tree now refuses to run without --force if there are shelved changes. (#586639)
Added two new test cases (./bzr selftest remove-tree).

To post a comment you must log in.
Revision history for this message
Alexander Belchenko (bialix) wrote :

Looks good for me.

review: Approve
Revision history for this message
Robert Collins (lifeless) wrote :

+1 from me too

Revision history for this message
Martin Pool (mbp) wrote :

Needs news; that can be added during merging.

Thanks for fixing this, Matt.

Can you please execute the copyright agreement <http://www.canonical.com/contributors> so we can merge this?

review: Approve
Revision history for this message
Martin Pool (mbp) wrote :

On 31 May 2010 13:42, Martin Pool <email address hidden> wrote:
> Review: Approve
> Needs news; that can be added during merging.
>
> Thanks for fixing this, Matt.
>
> Can you please execute the copyright agreement <http://www.canonical.com/contributors> so we can merge this?

wgrant tells me the link is broken; I've put a copy of the agreement
here: http://sourcefrog.net/tmp/1y/Canonical%20Contributor%20Agreement,%20ver%202.5.pdf

--
Martin <http://launchpad.net/~mbp/>

Revision history for this message
Matt Giuca (mgiuca) wrote :

Cheers, Martin. I've emailed the acceptance of the Agreement to you. Thanks to the Bazaar team for a very fast response.

Revision history for this message
Martin Pool (mbp) wrote :

sent to pqm by email

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'bzrlib/builtins.py'
2--- bzrlib/builtins.py 2010-05-25 17:27:52 +0000
3+++ bzrlib/builtins.py 2010-05-28 07:28:31 +0000
4@@ -491,7 +491,7 @@
5 takes_options = [
6 Option('force',
7 help='Remove the working tree even if it has '
8- 'uncommitted changes.'),
9+ 'uncommitted or shelved changes.'),
10 ]
11
12 def run(self, location_list, force=False):
13@@ -511,6 +511,8 @@
14 if not force:
15 if (working.has_changes()):
16 raise errors.UncommittedChanges(working)
17+ if working.get_shelf_manager().last_shelf() is not None:
18+ raise errors.ShelvedChanges(working)
19
20 if working.user_url != working.branch.user_url:
21 raise errors.BzrCommandError("You cannot remove the working tree"
22
23=== modified file 'bzrlib/errors.py'
24--- bzrlib/errors.py 2010-05-13 17:32:55 +0000
25+++ bzrlib/errors.py 2010-05-28 07:28:31 +0000
26@@ -2850,6 +2850,12 @@
27 BzrError.__init__(self, tree=tree, display_url=display_url, more=more)
28
29
30+class ShelvedChanges(UncommittedChanges):
31+
32+ _fmt = ('Working tree "%(display_url)s" has shelved changes'
33+ ' (See bzr shelve --list).%(more)s')
34+
35+
36 class MissingTemplateVariable(BzrError):
37
38 _fmt = 'Variable {%(name)s} is not available.'
39
40=== modified file 'bzrlib/tests/blackbox/test_remove_tree.py'
41--- bzrlib/tests/blackbox/test_remove_tree.py 2009-11-16 05:57:00 +0000
42+++ bzrlib/tests/blackbox/test_remove_tree.py 2010-05-28 07:28:31 +0000
43@@ -19,6 +19,7 @@
44
45 import os
46
47+from bzrlib import shelf
48 from bzrlib.tests.blackbox import ExternalBase
49
50
51@@ -155,3 +156,22 @@
52 self.run_bzr('remove-tree branch2 --force')
53 self.failIfExists('branch2/foo')
54 self.failIfExists('branch2/bar')
55+
56+ def test_remove_tree_shelved_changes(self):
57+ # https://bugs.launchpad.net/bzr/+bug/586639
58+ tree = self.make_branch_and_tree('.')
59+ creator = shelf.ShelfCreator(tree, tree.basis_tree(), [])
60+ self.addCleanup(creator.finalize)
61+ shelf_id = tree.get_shelf_manager().shelve_changes(creator, 'Foo')
62+ output = self.run_bzr_error(["Working tree .* has shelved changes"],
63+ 'remove-tree', retcode=3)
64+
65+ def test_remove_tree_shelved_changes_force(self):
66+ tree = self.make_branch_and_tree('.')
67+ creator = shelf.ShelfCreator(tree, tree.basis_tree(), [])
68+ self.addCleanup(creator.finalize)
69+ shelf_id = tree.get_shelf_manager().shelve_changes(creator, 'Foo')
70+ self.run_bzr('remove-tree --force')
71+ self.run_bzr('checkout')
72+ # Ensure shelf is empty
73+ self.assertIs(None, tree.get_shelf_manager().last_shelf())