Merge lp:~spiv/bzr/remove-tree-multi-253137 into lp:bzr

Proposed by Andrew Bennetts
Status: Merged
Approved by: Ian Clatworthy
Approved revision: not available
Merged at revision: not available
Proposed branch: lp:~spiv/bzr/remove-tree-multi-253137
Merge into: lp:bzr
Diff against target: 95 lines (+35/-22)
3 files modified
NEWS (+3/-0)
bzrlib/builtins.py (+26/-22)
bzrlib/tests/blackbox/test_remove_tree.py (+6/-0)
To merge this branch: bzr merge lp:~spiv/bzr/remove-tree-multi-253137
Reviewer Review Type Date Requested Status
Ian Clatworthy Approve
Review via email: mp+19158@code.launchpad.net
To post a comment you must log in.
Revision history for this message
Andrew Bennetts (spiv) wrote :

This fairly simple patch extends remove-tree to be able to remove multiple trees at once. The patch is mainly the work of Jared Hance, I just fixed a simple bug in the original patch and added a test.

Special thanks to Martin for noticing that I had unlanded work here.

Revision history for this message
Andrew Bennetts (spiv) wrote :

(Btw, according to LP team membership, Jared has signed the Canonical Contributors Agreement)

Revision history for this message
Ian Clatworthy (ian-clatworthy) :
review: Approve
Revision history for this message
John A Meinel (jameinel) wrote :

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Andrew Bennetts wrote:
> Andrew Bennetts has proposed merging lp:~spiv/bzr/remove-tree-multi-253137 into lp:bzr.
>
> Requested reviews:
> bzr-core (bzr-core)
> Related bugs:
> #253137 remove-tree should be able to operate on multiple branches at once
> https://bugs.launchpad.net/bugs/253137
>
>
> This fairly simple patch extends remove-tree to be able to remove multiple trees at once. The patch is mainly the work of Jared Hance, I just fixed a simple bug in the original patch and added a test.
>
> Special thanks to Martin for noticing that I had unlanded work here.
>

I'm late to this, but:

+ try:
+ working = d.open_workingtree()
+ except errors.NoWorkingTree:
+ raise errors.BzrCommandError("No working tree to remove")
+ except errors.NotLocalUrl:
+ raise errors.BzrCommandError("You cannot remove the
working tree"
+ " of a remote path")

This isn't very helpful if you are supplying multiple paths. Which one
doesn't have a working tree? (And should we fail all following ones
because 1 of them didn't have a tree?)

Anyway, you don't have to fix it now, I filed:
https://bugs.edge.launchpad.net/bzr/+bug/521005

To keep track of it.
John
=:->
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (Cygwin)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iEYEARECAAYFAkt1aXkACgkQJdeBCYSNAAOqaQCfeGVXw+nNK9d8ccCEBHDBu2aA
ilMAoISIJ6YvW3b61nQkYezyQmCKjM1u
=+MLO
-----END PGP SIGNATURE-----

Revision history for this message
Andrew Bennetts (spiv) wrote :

John A Meinel wrote:
[...]
> This isn't very helpful if you are supplying multiple paths. Which one
> doesn't have a working tree? (And should we fail all following ones
> because 1 of them didn't have a tree?)
>
> Anyway, you don't have to fix it now, I filed:
> https://bugs.edge.launchpad.net/bzr/+bug/521005
>
> To keep track of it.

Good catch. Thanks for the bug report!

-Andrew.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'NEWS'
2--- NEWS 2010-02-11 11:48:55 +0000
3+++ NEWS 2010-02-12 04:38:13 +0000
4@@ -59,6 +59,9 @@
5 * ``bzr add`` will not add conflict related files unless explicitly required.
6 (Vincent Ladeuil, #322767, #414589)
7
8+* ``bzr remove-tree`` can now remove multiple working trees.
9+ (Jared Hance, Andrew Bennetts, #253137)
10+
11 * Network transfer amounts and rates are now displayed in SI units according
12 to the Ubuntu Units Policy <https://wiki.ubuntu.com/UnitsPolicy>.
13 (Gordon Tyler, #514399)
14
15=== modified file 'bzrlib/builtins.py'
16--- bzrlib/builtins.py 2010-02-11 09:27:55 +0000
17+++ bzrlib/builtins.py 2010-02-12 04:38:13 +0000
18@@ -453,34 +453,38 @@
19 To re-create the working tree, use "bzr checkout".
20 """
21 _see_also = ['checkout', 'working-trees']
22- takes_args = ['location?']
23+ takes_args = ['location*']
24 takes_options = [
25 Option('force',
26 help='Remove the working tree even if it has '
27 'uncommitted changes.'),
28 ]
29
30- def run(self, location='.', force=False):
31- d = bzrdir.BzrDir.open(location)
32-
33- try:
34- working = d.open_workingtree()
35- except errors.NoWorkingTree:
36- raise errors.BzrCommandError("No working tree to remove")
37- except errors.NotLocalUrl:
38- raise errors.BzrCommandError("You cannot remove the working tree"
39- " of a remote path")
40- if not force:
41- if (working.has_changes()):
42- raise errors.UncommittedChanges(working)
43-
44- working_path = working.bzrdir.root_transport.base
45- branch_path = working.branch.bzrdir.root_transport.base
46- if working_path != branch_path:
47- raise errors.BzrCommandError("You cannot remove the working tree"
48- " from a lightweight checkout")
49-
50- d.destroy_workingtree()
51+ def run(self, location_list, force=False):
52+ if not location_list:
53+ location_list=['.']
54+
55+ for location in location_list:
56+ d = bzrdir.BzrDir.open(location)
57+
58+ try:
59+ working = d.open_workingtree()
60+ except errors.NoWorkingTree:
61+ raise errors.BzrCommandError("No working tree to remove")
62+ except errors.NotLocalUrl:
63+ raise errors.BzrCommandError("You cannot remove the working tree"
64+ " of a remote path")
65+ if not force:
66+ if (working.has_changes()):
67+ raise errors.UncommittedChanges(working)
68+
69+ working_path = working.bzrdir.root_transport.base
70+ branch_path = working.branch.bzrdir.root_transport.base
71+ if working_path != branch_path:
72+ raise errors.BzrCommandError("You cannot remove the working tree"
73+ " from a lightweight checkout")
74+
75+ d.destroy_workingtree()
76
77
78 class cmd_revno(Command):
79
80=== modified file 'bzrlib/tests/blackbox/test_remove_tree.py'
81--- bzrlib/tests/blackbox/test_remove_tree.py 2009-09-08 16:45:11 +0000
82+++ bzrlib/tests/blackbox/test_remove_tree.py 2010-02-12 04:38:13 +0000
83@@ -43,6 +43,12 @@
84 self.run_bzr('remove-tree branch1')
85 self.failIfExists('branch1/foo')
86
87+ def test_remove_tree_multiple_branch_explicit(self):
88+ self.tree.bzrdir.sprout('branch2')
89+ self.run_bzr('remove-tree branch1 branch2')
90+ self.failIfExists('branch1/foo')
91+ self.failIfExists('branch2/foo')
92+
93 def test_remove_tree_sprouted_branch(self):
94 self.tree.bzrdir.sprout('branch2')
95 self.failUnlessExists('branch2/foo')