Rev 5282: (mbp) remove-tree now refuses to run without --force if there are shelved in file:///home/pqm/archives/thelove/bzr/%2Btrunk/

Canonical.com Patch Queue Manager pqm at pqm.ubuntu.com
Fri Jun 4 11:10:52 BST 2010


At file:///home/pqm/archives/thelove/bzr/%2Btrunk/

------------------------------------------------------------
revno: 5282 [merge]
revision-id: pqm at pqm.ubuntu.com-20100604101050-5iiiag2n2soczg1l
parent: pqm at pqm.ubuntu.com-20100604085449-n7lw5cj01w94ygxu
parent: matt.giuca at gmail.com-20100528060457-v03aq5pfd0vzjvej
committer: Canonical.com Patch Queue Manager <pqm at pqm.ubuntu.com>
branch nick: +trunk
timestamp: Fri 2010-06-04 11:10:50 +0100
message:
  (mbp) remove-tree now refuses to run without --force if there are shelved
   changes. (#586639) (Matt Giuca)
modified:
  bzrlib/builtins.py             builtins.py-20050830033751-fc01482b9ca23183
  bzrlib/errors.py               errors.py-20050309040759-20512168c4e14fbd
  bzrlib/tests/blackbox/test_remove_tree.py test_remove_tree.py-20061110192919-5j3xjciiaqbs2dvo-1
=== modified file 'bzrlib/builtins.py'
--- a/bzrlib/builtins.py	2010-06-02 04:50:35 +0000
+++ b/bzrlib/builtins.py	2010-06-04 10:10:50 +0000
@@ -491,7 +491,7 @@
     takes_options = [
         Option('force',
                help='Remove the working tree even if it has '
-                    'uncommitted changes.'),
+                    'uncommitted or shelved changes.'),
         ]
 
     def run(self, location_list, force=False):
@@ -511,6 +511,8 @@
             if not force:
                 if (working.has_changes()):
                     raise errors.UncommittedChanges(working)
+                if working.get_shelf_manager().last_shelf() is not None:
+                    raise errors.ShelvedChanges(working)
 
             if working.user_url != working.branch.user_url:
                 raise errors.BzrCommandError("You cannot remove the working tree"

=== modified file 'bzrlib/errors.py'
--- a/bzrlib/errors.py	2010-05-13 17:32:55 +0000
+++ b/bzrlib/errors.py	2010-05-28 06:04:57 +0000
@@ -2850,6 +2850,12 @@
         BzrError.__init__(self, tree=tree, display_url=display_url, more=more)
 
 
+class ShelvedChanges(UncommittedChanges):
+
+    _fmt = ('Working tree "%(display_url)s" has shelved changes'
+            ' (See bzr shelve --list).%(more)s')
+
+
 class MissingTemplateVariable(BzrError):
 
     _fmt = 'Variable {%(name)s} is not available.'

=== modified file 'bzrlib/tests/blackbox/test_remove_tree.py'
--- a/bzrlib/tests/blackbox/test_remove_tree.py	2009-11-16 05:57:00 +0000
+++ b/bzrlib/tests/blackbox/test_remove_tree.py	2010-05-28 06:04:57 +0000
@@ -19,6 +19,7 @@
 
 import os
 
+from bzrlib import shelf
 from bzrlib.tests.blackbox import ExternalBase
 
 
@@ -155,3 +156,22 @@
         self.run_bzr('remove-tree branch2 --force')
         self.failIfExists('branch2/foo')
         self.failIfExists('branch2/bar')
+
+    def test_remove_tree_shelved_changes(self):
+        # https://bugs.launchpad.net/bzr/+bug/586639
+        tree = self.make_branch_and_tree('.')
+        creator = shelf.ShelfCreator(tree, tree.basis_tree(), [])
+        self.addCleanup(creator.finalize)
+        shelf_id = tree.get_shelf_manager().shelve_changes(creator, 'Foo')
+        output = self.run_bzr_error(["Working tree .* has shelved changes"],
+                                    'remove-tree', retcode=3)
+
+    def test_remove_tree_shelved_changes_force(self):
+        tree = self.make_branch_and_tree('.')
+        creator = shelf.ShelfCreator(tree, tree.basis_tree(), [])
+        self.addCleanup(creator.finalize)
+        shelf_id = tree.get_shelf_manager().shelve_changes(creator, 'Foo')
+        self.run_bzr('remove-tree --force')
+        self.run_bzr('checkout')
+        # Ensure shelf is empty
+        self.assertIs(None, tree.get_shelf_manager().last_shelf())




More information about the bazaar-commits mailing list