Merge lp:~jelmer/brz/reference-force into lp:brz

Proposed by Jelmer Vernooij on 2018-09-29
Status: Merged
Approved by: Jelmer Vernooij on 2018-11-04
Approved revision: 7133
Merge reported by: The Breezy Bot
Merged at revision: not available
Proposed branch: lp:~jelmer/brz/reference-force
Merge into: lp:brz
Diff against target: 54 lines (+18/-3)
2 files modified
breezy/builtins.py (+8/-3)
breezy/tests/blackbox/test_reference.py (+10/-0)
To merge this branch: bzr merge lp:~jelmer/brz/reference-force
Reviewer Review Type Date Requested Status
Martin Packman 2018-09-29 Approve on 2018-10-13
Review via email: mp+355876@code.launchpad.net

Description of the change

Support forcing the setting of a reference.

Useful for testing.

To post a comment you must log in.
Martin Packman (gz) wrote :

Change seems fine. The flag named --force is one to be careful with, tends to be easy to reach for but ambiguous. Fine here though? Not a commonly used command. Alternative would be `--unversioned` and fail in the inverse, or `--even-if-unversioned` or something else longish.

review: Approve
Jelmer Vernooij (jelmer) wrote :

How about --force-unversioned?

The Breezy Bot (the-breezy-bot) wrote :

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'breezy/builtins.py'
2--- breezy/builtins.py 2018-09-27 07:25:00 +0000
3+++ breezy/builtins.py 2018-11-01 00:44:25 +0000
4@@ -2972,7 +2972,8 @@
5 Option('ignored', short_name='i',
6 help='Print ignored files.'),
7 Option('kind', short_name='k',
8- help='List entries of a particular kind: file, directory, symlink.',
9+ help=('List entries of a particular kind: file, '
10+ 'directory, symlink, tree-reference.'),
11 type=text_type),
12 'null',
13 'show-ids',
14@@ -6682,8 +6683,12 @@
15 hidden = True
16
17 takes_args = ['path?', 'location?']
18+ takes_options = [
19+ Option('force-unversioned',
20+ help='Set reference even if path is not versioned.'),
21+ ]
22
23- def run(self, path=None, location=None):
24+ def run(self, path=None, location=None, force_unversioned=False):
25 branchdir = '.'
26 if path is not None:
27 branchdir = path
28@@ -6697,7 +6702,7 @@
29 info = viewitems(branch._get_all_reference_info())
30 self._display_reference_info(tree, branch, info)
31 else:
32- if not tree.is_versioned(path):
33+ if not tree.is_versioned(path) and not force_unversioned:
34 raise errors.NotVersionedError(path)
35 if location is None:
36 info = [(path, branch.get_reference_info(path))]
37
38=== modified file 'breezy/tests/blackbox/test_reference.py'
39--- breezy/tests/blackbox/test_reference.py 2018-07-07 15:06:42 +0000
40+++ breezy/tests/blackbox/test_reference.py 2018-11-01 00:44:25 +0000
41@@ -87,3 +87,13 @@
42 out, err = self.run_bzr('reference file http://example.org',
43 working_dir='tree', retcode=3)
44 self.assertEqual('brz: ERROR: file is not versioned.\n', err)
45+
46+ def test_missing_file_forced(self):
47+ tree = self.make_branch_and_tree('tree')
48+ out, err = self.run_bzr(
49+ 'reference --force-unversioned file http://example.org',
50+ working_dir='tree')
51+ location, file_id = tree.branch.get_reference_info('file')
52+ self.assertEqual('http://example.org', location)
53+ self.assertEqual('', out)
54+ self.assertEqual('', err)

Subscribers

People subscribed via source and target branches