Merge lp:~jelmer/brz/colo-switch-jml into lp:brz

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/colo-switch-jml
Merge into: lp:brz
Diff against target: 61 lines (+32/-2)
2 files modified
breezy/builtins.py (+5/-2)
breezy/tests/blackbox/test_switch.py (+27/-0)
To merge this branch: bzr merge lp:~jelmer/brz/colo-switch-jml
Reviewer Review Type Date Requested Status
Martin Packman Approve
Review via email: mp+358607@code.launchpad.net

Commit message

Fix switching to older revisions when creating a new branch.

Description of the change

Fix switching to older revisions when creating a new branch.

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

Thanks!

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 2018-11-04 15:48:54 +0000
3+++ breezy/builtins.py 2018-11-11 21:57:02 +0000
4@@ -6277,8 +6277,11 @@
5 gettext('cannot create branch without source branch'))
6 to_location = lookup_new_sibling_branch(control_dir, to_location,
7 possible_transports=possible_transports)
8+ if revision is not None:
9+ revision = revision.as_revision_id(branch)
10 to_branch = branch.controldir.sprout(to_location,
11 possible_transports=possible_transports,
12+ revision_id=revision,
13 source_branch=branch).open_branch()
14 else:
15 try:
16@@ -6287,8 +6290,8 @@
17 except errors.NotBranchError:
18 to_branch = open_sibling_branch(control_dir, to_location,
19 possible_transports=possible_transports)
20- if revision is not None:
21- revision = revision.as_revision_id(to_branch)
22+ if revision is not None:
23+ revision = revision.as_revision_id(to_branch)
24 try:
25 switch.switch(control_dir, to_branch, force, revision_id=revision,
26 store_uncommitted=store)
27
28=== modified file 'breezy/tests/blackbox/test_switch.py'
29--- breezy/tests/blackbox/test_switch.py 2018-07-13 00:24:33 +0000
30+++ breezy/tests/blackbox/test_switch.py 2018-11-11 21:57:02 +0000
31@@ -576,3 +576,30 @@
32 $ brz branches
33 * br1
34 ''', null_output_matches_anything=True)
35+
36+ def test_switch_to_new_branch_on_old_rev(self):
37+ """switch to previous rev in a standalone directory
38+
39+ Inspired by: https://bugs.launchpad.net/brz/+bug/933362
40+ """
41+ self.script_runner = script.ScriptRunner()
42+ self.script_runner.run_script(self, '''
43+ $ brz init
44+ Created a standalone tree (format: 2a)
45+ $ brz switch -b trunk
46+ 2>Tree is up to date at revision 0.
47+ 2>Switched to branch:...
48+ $ brz commit -m 1 --unchanged
49+ 2>Committing to: ...
50+ 2>Committed revision 1.
51+ $ brz commit -m 2 --unchanged
52+ 2>Committing to: ...
53+ 2>Committed revision 2.
54+ $ brz switch -b blah -r1
55+ 2>Updated to revision 1.
56+ 2>Switched to branch:...
57+ $ brz branches
58+ * blah
59+ trunk
60+ $ brz st
61+ ''')

Subscribers

People subscribed via source and target branches