Merge lp:~jelmer/brz/flag-b into lp:brz/3.1

Proposed by Jelmer Vernooij
Status: Merged
Approved by: Jelmer Vernooij
Approved revision: no longer in the source branch.
Merge reported by: The Breezy Bot
Merged at revision: not available
Proposed branch: lp:~jelmer/brz/flag-b
Merge into: lp:brz/3.1
Diff against target: 106 lines (+35/-4)
5 files modified
breezy/builtins.py (+4/-2)
breezy/controldir.py (+2/-2)
breezy/tests/blackbox/test_branch.py (+11/-0)
breezy/tests/test_bzrdir.py (+14/-0)
doc/en/release-notes/brz-3.1.txt (+4/-0)
To merge this branch: bzr merge lp:~jelmer/brz/flag-b
Reviewer Review Type Date Requested Status
Jelmer Vernooij Approve
Review via email: mp+381552@code.launchpad.net

Commit message

Add a -b option to ''brz branch''.

Description of the change

Add a -b option to ''brz branch''.

To post a comment you must log in.
Revision history for this message
Jelmer Vernooij (jelmer) :
review: Approve

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 2020-02-18 05:59:35 +0000
3+++ breezy/builtins.py 2020-04-02 01:43:54 +0000
4@@ -1470,15 +1470,17 @@
5 help="Bind new branch to from location."),
6 Option('no-recurse-nested',
7 help='Do not recursively check out nested trees.'),
8+ Option('colocated-branch', short_name='b',
9+ type=str, help='Name of colocated branch to sprout.'),
10 ]
11
12 def run(self, from_location, to_location=None, revision=None,
13 hardlink=False, stacked=False, standalone=False, no_tree=False,
14 use_existing_dir=False, switch=False, bind=False,
15- files_from=None, no_recurse_nested=False):
16+ files_from=None, no_recurse_nested=False, colocated_branch=None):
17 from breezy import switch as _mod_switch
18 accelerator_tree, br_from = controldir.ControlDir.open_tree_or_branch(
19- from_location)
20+ from_location, name=colocated_branch)
21 if no_recurse_nested:
22 recurse = 'none'
23 else:
24
25=== modified file 'breezy/controldir.py'
26--- breezy/controldir.py 2020-03-22 19:12:43 +0000
27+++ breezy/controldir.py 2020-04-02 01:43:54 +0000
28@@ -808,7 +808,7 @@
29 a_transport = new_t
30
31 @classmethod
32- def open_tree_or_branch(klass, location):
33+ def open_tree_or_branch(klass, location, name=None):
34 """Return the branch and working tree at a location.
35
36 If there is no tree at the location, tree will be None.
37@@ -817,7 +817,7 @@
38 :return: (tree, branch)
39 """
40 controldir = klass.open(location)
41- return controldir._get_tree_branch()
42+ return controldir._get_tree_branch(name=name)
43
44 @classmethod
45 def open_containing_tree_or_branch(klass, location,
46
47=== modified file 'breezy/tests/blackbox/test_branch.py'
48--- breezy/tests/blackbox/test_branch.py 2020-01-19 14:49:03 +0000
49+++ breezy/tests/blackbox/test_branch.py 2020-04-02 01:43:54 +0000
50@@ -107,6 +107,17 @@
51 self.assertEqual('Branched 0 revisions.\n', err)
52 self.assertPathExists('a')
53
54+ def test_from_name(self):
55+ """Branch from a colocated branch into a regular branch."""
56+ os.mkdir('b')
57+ tree = self.example_branch('b/a', format='development-colo')
58+ tree.controldir.create_branch(name='somecolo')
59+ out, err = self.run_bzr('branch -b somecolo %s' %
60+ local_path_to_url('b/a'))
61+ self.assertEqual('', out)
62+ self.assertEqual('Branched 0 revisions.\n', err)
63+ self.assertPathExists('a')
64+
65 def test_branch_broken_pack(self):
66 """branching with a corrupted pack file."""
67 self.example_branch('a')
68
69=== modified file 'breezy/tests/test_bzrdir.py'
70--- breezy/tests/test_bzrdir.py 2020-01-19 03:22:04 +0000
71+++ breezy/tests/test_bzrdir.py 2020-04-02 01:43:54 +0000
72@@ -821,6 +821,20 @@
73 self.assertEqual(os.path.realpath('topdir/foo'),
74 self.local_branch_path(branch))
75
76+ def test_open_tree_or_branch_named(self):
77+ tree = self.make_branch_and_tree('topdir')
78+ self.assertRaises(
79+ NotBranchError,
80+ bzrdir.BzrDir.open_tree_or_branch, 'topdir', name='missing')
81+ tree.branch.controldir.create_branch('named')
82+ tree, branch = bzrdir.BzrDir.open_tree_or_branch('topdir', name='named')
83+ self.assertEqual(os.path.realpath('topdir'),
84+ os.path.realpath(tree.basedir))
85+ self.assertEqual(os.path.realpath('topdir'),
86+ self.local_branch_path(branch))
87+ self.assertEqual(branch.name, 'named')
88+ self.assertIs(tree.controldir, branch.controldir)
89+
90 def test_open_from_transport(self):
91 # transport pointing at bzrdir should give a bzrdir with root transport
92 # set to the given transport
93
94=== modified file 'doc/en/release-notes/brz-3.1.txt'
95--- doc/en/release-notes/brz-3.1.txt 2020-03-28 22:25:33 +0000
96+++ doc/en/release-notes/brz-3.1.txt 2020-04-02 01:43:54 +0000
97@@ -80,6 +80,10 @@
98 * ``brz sprout`` is now an alias for ``brz branch``.
99 (Jelmer Vernooij)
100
101+ * ``brz branch`` now accepts a ``-b`` flag with the
102+ name of the colocated branch to sprout.
103+ (Jelmer Vernooij, #1869977)
104+
105 Improvements
106 ************
107

Subscribers

People subscribed via source and target branches