Merge lp:~amanica/bzr/rm-no-backup-400554 into lp:bzr

Proposed by Marius Kruger
Status: Merged
Approved by: Martin Packman
Approved revision: no longer in the source branch.
Merged at revision: 5465
Proposed branch: lp:~amanica/bzr/rm-no-backup-400554
Merge into: lp:bzr
Diff against target: 102 lines (+40/-7)
3 files modified
NEWS (+5/-0)
bzrlib/builtins.py (+9/-2)
bzrlib/tests/blackbox/test_remove.py (+26/-5)
To merge this branch: bzr merge lp:~amanica/bzr/rm-no-backup-400554
Reviewer Review Type Date Requested Status
Martin Pool Approve
Martin Packman (community) Approve
Review via email: mp+36612@code.launchpad.net

Commit message

add 'bzr rm --no-backup' and deprecate the --force opting to be consitent with revert

Description of the change

This fixes the last bit of:
https://bugs.launchpad.net/bzr/+bug/400554
by adding a --no-backup to `bzr rm` and deprecating --force.
--no-backup is consistent with `bzr revert`
so now we don't need the big --force hammer any more.

* I didn't change the internal parameter names because I don't know if its worth the effort
  of renaming it.
* The --force option still appears in the help because I can't see how to
  hide one RegistryOption but still work as a enumish thing. If we have to
  hide it, we should first implement this feature in another merge proposal.
* --force now prints out a deprecation warning, encouraging the user to rather use
  --no-backup.
* Maybe I'm not making it clear enough that --no-backup will delete
  everything you tell it to, with no going back.

To post a comment you must log in.
Revision history for this message
Martin Pool (mbp) wrote :

Thanks for that, Marius.

62 + self.run_bzr(['remove', '--no-backup'] + list(files),
63 + error_regexes=["deleted a", "deleted b",
64 + "removed b/c", "deleted d"])
65 + self.assertFilesDeleted(files)

This code is fine, but it would be easier to read and write if you used run_script instead, and no slower.

review: Approve
Revision history for this message
Marius Kruger (amanica) wrote :

On 1 October 2010 07:15, Martin Pool <email address hidden> wrote:
> Review: Approve
> Thanks for that, Marius.
pleasure ;-)

> 62      +        self.run_bzr(['remove', '--no-backup'] + list(files),
> 63      +                     error_regexes=["deleted a", "deleted b",
> 64      +                                    "removed b/c", "deleted d"])
> 65      +        self.assertFilesDeleted(files)
>
> This code is fine, but it would be easier to read and write if you used run_script instead, and no slower.

ok I changed the 2 tests that this patch touches to use ScriptRunner.
I can do a follow-on if you'd like the rest of test_remove converted.

With ScriptRunner it does read better.
Previously we did try to make the tests less fragile by not
matching everything exactly eg. the files may be deleted in
a different order. Maybe because this is a blackbox test
for *remove* its ok to test every character.

Revision history for this message
Martin Packman (gz) wrote :

I actually prefer the non-scriptrunner version, but if we're really not worried about directory iteration order on the output I guess either is fine.

review: Approve
Revision history for this message
Marius Kruger (amanica) wrote :

On 4 October 2010 10:06, Martin [gz] <email address hidden> wrote:
> Review: Approve
> I actually prefer the non-scriptrunner version, but if we're really not worried about directory iteration order on the output I guess either is fine.

yes there are pros and cons.
Directory iteration order may have been a valid issue if we were not
sorting them;
it would have been nice though if you can somehow tell the script
runner that certain lines are allowed to be in a different order..
I'll let whoever merge this decide which way to go since its approved
either way :-)

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

On 4 October 2010 19:06, Martin [gz] <email address hidden> wrote:
> Review: Approve
> I actually prefer the non-scriptrunner version, but if we're really not worried about directory iteration order on the output I guess either is fine.

Because of it not caring about the ordering, or for some other reason?

--
Martin

Revision history for this message
Vincent Ladeuil (vila) 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 'NEWS'
2--- NEWS 2010-10-01 08:49:39 +0000
3+++ NEWS 2010-10-02 18:11:43 +0000
4@@ -51,6 +51,11 @@
5 Improvements
6 ************
7
8+* ``bzr remove`` now takes a ``--no-backup`` option for when you don't want it
9+ to backup anything, just delete it. This option used to be called ``--force``
10+ which is now deprecated.
11+ (Marius Kruger, #400554)
12+
13 Documentation
14 *************
15
16
17=== modified file 'bzrlib/builtins.py'
18--- bzrlib/builtins.py 2010-10-01 08:49:39 +0000
19+++ bzrlib/builtins.py 2010-10-02 18:11:43 +0000
20@@ -1505,13 +1505,20 @@
21 title='Deletion Strategy', value_switches=True, enum_switch=False,
22 safe='Backup changed files (default).',
23 keep='Delete from bzr but leave the working copy.',
24+ no_backup='Don\'t backup changed files.',
25 force='Delete all the specified files, even if they can not be '
26- 'recovered and even if they are non-empty directories.')]
27+ 'recovered and even if they are non-empty directories. '
28+ '(deprecated, use no-backup)')]
29 aliases = ['rm', 'del']
30 encoding_type = 'replace'
31
32 def run(self, file_list, verbose=False, new=False,
33 file_deletion_strategy='safe'):
34+ if file_deletion_strategy == 'force':
35+ note("(The --force option is deprecated, rather use --no-backup "
36+ "in future.)")
37+ file_deletion_strategy = 'no-backup'
38+
39 tree, file_list = WorkingTree.open_containing_paths(file_list)
40
41 if file_list is not None:
42@@ -1538,7 +1545,7 @@
43 file_deletion_strategy = 'keep'
44 tree.remove(file_list, verbose=verbose, to_file=self.outf,
45 keep_files=file_deletion_strategy=='keep',
46- force=file_deletion_strategy=='force')
47+ force=(file_deletion_strategy=='no-backup'))
48
49
50 class cmd_file_id(Command):
51
52=== modified file 'bzrlib/tests/blackbox/test_remove.py'
53--- bzrlib/tests/blackbox/test_remove.py 2010-07-09 23:09:39 +0000
54+++ bzrlib/tests/blackbox/test_remove.py 2010-10-02 18:11:43 +0000
55@@ -18,8 +18,12 @@
56 import os
57 import sys
58
59-from bzrlib.tests import SymlinkFeature, TestSkipped
60-from bzrlib.tests import TestCaseWithTransport
61+from bzrlib.tests import (
62+ script,
63+ SymlinkFeature,
64+ TestCaseWithTransport,
65+ TestSkipped,
66+ )
67 from bzrlib.workingtree import WorkingTree
68 from bzrlib import osutils
69
70@@ -200,12 +204,29 @@
71 self.run_bzr('remove --keep a', error_regexes=["a is not versioned."])
72 self.assertFilesUnversioned(files)
73
74+ def test_remove_no_backup_unversioned_files(self):
75+ self.build_tree(files)
76+ tree = self.make_branch_and_tree('.')
77+ script.ScriptRunner().run_script(self, '''
78+ $ bzr remove --no-backup a b/ b/c d/
79+ 2>deleted d
80+ 2>removed b/c (but kept a copy: b/c.~1~)
81+ 2>deleted b
82+ 2>deleted a
83+ ''')
84+ self.assertFilesDeleted(files)
85+
86 def test_remove_force_unversioned_files(self):
87 self.build_tree(files)
88 tree = self.make_branch_and_tree('.')
89- self.run_bzr(['remove', '--force'] + list(files),
90- error_regexes=["deleted a", "deleted b",
91- "removed b/c", "deleted d"])
92+ script.ScriptRunner().run_script(self, '''
93+ $ bzr remove --force a b/ b/c d/
94+ 2>(The --force option is deprecated, rather use --no-backup in future.)
95+ 2>deleted d
96+ 2>removed b/c (but kept a copy: b/c.~1~)
97+ 2>deleted b
98+ 2>deleted a
99+ ''')
100 self.assertFilesDeleted(files)
101
102 def test_remove_deleted_files(self):