Merge lp:~luks/bzr/branch-switch into lp:~bzr/bzr/trunk-old
- branch-switch
- Merge into trunk-old
Status: | Merged |
---|---|
Merged at revision: | not available |
Proposed branch: | lp:~luks/bzr/branch-switch |
Merge into: | lp:~bzr/bzr/trunk-old |
Diff against target: |
159 lines (has conflicts)
Text conflict in NEWS |
To merge this branch: | bzr merge lp:~luks/bzr/branch-switch |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Alexander Belchenko | Approve | ||
John A Meinel | Approve | ||
Review via email: mp+9987@code.launchpad.net |
This proposal supersedes a proposal from 2009-08-11.
Commit message
Support for `bzr branch --switch`
Description of the change
Lukáš Lalinský (luks) wrote : Posted in a previous version of this proposal | # |
John A Meinel (jameinel) wrote : Posted in a previous version of this proposal | # |
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Lukáš Lalinský wrote:
> Lukáš Lalinský has proposed merging lp:~luks/bzr/branch-switch into lp:bzr.
>
> Requested reviews:
> bzr-core (bzr-core)
>
> This patch adds a new option to bzr branch that allows to switch the checkout in the current directory to the new branch. This is based on yesterday's discussion in #bzr -- http://
>
I would like to see a test for what happens when you are only in a
branch, and not a working tree at all.
I'd also like to see "test_branch_
happens as a side effect. Does it:
1) Create/not create the branch 'b'?
2) Do anything to the local branch or working tree?
Also, I think we should have a test with a heavyweight checkout, to
assert what it does there.
Note that I'm not particularly strong on what the answers to the
questions should be. I just want the behavior identified, so we don't
accidentally change it in the future.
review needs_fixing
John
=:->
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (Cygwin)
Comment: Using GnuPG with Mozilla - http://
iEYEARECAAYFAkq
EEQAn2PL4ykfHtQ
=Et4B
-----END PGP SIGNATURE-----
John A Meinel (jameinel) wrote : | # |
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Lukáš Lalinský wrote:
> Lukáš Lalinský has proposed merging lp:~luks/bzr/branch-switch into lp:bzr.
>
> Requested reviews:
> bzr-core (bzr-core)
>
review approve
John
=:->
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (Cygwin)
Comment: Using GnuPG with Mozilla - http://
iEYEARECAAYFAkq
Ll8AoJOhoFbtxH6
=3FMl
-----END PGP SIGNATURE-----
Robert Collins (lifeless) wrote : Posted in a previous version of this proposal | # |
I thought we had 'switch -b' for this case? Is there really a need to
have both switch --branch and branch --switch?
John A Meinel (jameinel) wrote : Posted in a previous version of this proposal | # |
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Robert Collins wrote:
> I thought we had 'switch -b' for this case? Is there really a need to
> have both switch --branch and branch --switch?
>
>
>
branch --switch allows for a custom source that isn't "."
John
=:->
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (Cygwin)
Comment: Using GnuPG with Mozilla - http://
iEYEARECAAYFAkq
t9IAn1tIjmrIboa
=KqUk
-----END PGP SIGNATURE-----
Alexander Belchenko (bialix) wrote : | # |
I like the idea and implementation.
John, can you merge this, please?
Vincent Ladeuil (vila) wrote : | # |
Sent to pqm
Preview Diff
1 | === modified file 'NEWS' | |||
2 | --- NEWS 2009-08-20 05:32:57 +0000 | |||
3 | +++ NEWS 2009-08-20 08:35:58 +0000 | |||
4 | @@ -12,6 +12,7 @@ | |||
5 | 12 | Compatibility Breaks | 12 | Compatibility Breaks |
6 | 13 | ******************** | 13 | ******************** |
7 | 14 | 14 | ||
8 | 15 | <<<<<<< TREE | ||
9 | 15 | * The default format for bzr is now ``2a``. This format brings many | 16 | * The default format for bzr is now ``2a``. This format brings many |
10 | 16 | significant performance and size improvements. bzr can pull from | 17 | significant performance and size improvements. bzr can pull from |
11 | 17 | any existing repository into a ``2a`` one, but can only transfer | 18 | any existing repository into a ``2a`` one, but can only transfer |
12 | @@ -83,6 +84,16 @@ | |||
13 | 83 | 84 | ||
14 | 84 | * Fixed "Pack ... already exists" error when running ``bzr pack`` on a | 85 | * Fixed "Pack ... already exists" error when running ``bzr pack`` on a |
15 | 85 | fully packed 2a repository. (Andrew Bennetts, #382463) | 86 | fully packed 2a repository. (Andrew Bennetts, #382463) |
16 | 87 | ======= | ||
17 | 88 | New Features | ||
18 | 89 | ************ | ||
19 | 90 | |||
20 | 91 | * ``bzr branch --switch`` can now switch the checkout in the current directory | ||
21 | 92 | to the newly created branch. (Lukáš Lalinský) | ||
22 | 93 | |||
23 | 94 | Bug Fixes | ||
24 | 95 | ********* | ||
25 | 96 | >>>>>>> MERGE-SOURCE | ||
26 | 86 | 97 | ||
27 | 87 | * Further tweaks to handling of ``bzr add`` messages about ignored files. | 98 | * Further tweaks to handling of ``bzr add`` messages about ignored files. |
28 | 88 | (Jason Spashett, #76616) | 99 | (Jason Spashett, #76616) |
29 | 89 | 100 | ||
30 | === modified file 'bzrlib/builtins.py' | |||
31 | --- bzrlib/builtins.py 2009-08-10 08:25:53 +0000 | |||
32 | +++ bzrlib/builtins.py 2009-08-20 08:35:58 +0000 | |||
33 | @@ -1167,6 +1167,9 @@ | |||
34 | 1167 | help='Hard-link working tree files where possible.'), | 1167 | help='Hard-link working tree files where possible.'), |
35 | 1168 | Option('no-tree', | 1168 | Option('no-tree', |
36 | 1169 | help="Create a branch without a working-tree."), | 1169 | help="Create a branch without a working-tree."), |
37 | 1170 | Option('switch', | ||
38 | 1171 | help="Switch the checkout in the current directory " | ||
39 | 1172 | "to the new branch."), | ||
40 | 1170 | Option('stacked', | 1173 | Option('stacked', |
41 | 1171 | help='Create a stacked branch referring to the source branch. ' | 1174 | help='Create a stacked branch referring to the source branch. ' |
42 | 1172 | 'The new branch will depend on the availability of the source ' | 1175 | 'The new branch will depend on the availability of the source ' |
43 | @@ -1183,9 +1186,9 @@ | |||
44 | 1183 | 1186 | ||
45 | 1184 | def run(self, from_location, to_location=None, revision=None, | 1187 | def run(self, from_location, to_location=None, revision=None, |
46 | 1185 | hardlink=False, stacked=False, standalone=False, no_tree=False, | 1188 | hardlink=False, stacked=False, standalone=False, no_tree=False, |
48 | 1186 | use_existing_dir=False): | 1189 | use_existing_dir=False, switch=False): |
49 | 1190 | from bzrlib import switch as _mod_switch | ||
50 | 1187 | from bzrlib.tag import _merge_tags_if_possible | 1191 | from bzrlib.tag import _merge_tags_if_possible |
51 | 1188 | |||
52 | 1189 | accelerator_tree, br_from = bzrdir.BzrDir.open_tree_or_branch( | 1192 | accelerator_tree, br_from = bzrdir.BzrDir.open_tree_or_branch( |
53 | 1190 | from_location) | 1193 | from_location) |
54 | 1191 | if (accelerator_tree is not None and | 1194 | if (accelerator_tree is not None and |
55 | @@ -1245,6 +1248,12 @@ | |||
56 | 1245 | except (errors.NotStacked, errors.UnstackableBranchFormat, | 1248 | except (errors.NotStacked, errors.UnstackableBranchFormat, |
57 | 1246 | errors.UnstackableRepositoryFormat), e: | 1249 | errors.UnstackableRepositoryFormat), e: |
58 | 1247 | note('Branched %d revision(s).' % branch.revno()) | 1250 | note('Branched %d revision(s).' % branch.revno()) |
59 | 1251 | if switch: | ||
60 | 1252 | # Switch to the new branch | ||
61 | 1253 | wt, _ = WorkingTree.open_containing('.') | ||
62 | 1254 | _mod_switch.switch(wt.bzrdir, branch) | ||
63 | 1255 | note('Switched to branch: %s', | ||
64 | 1256 | urlutils.unescape_for_display(branch.base, 'utf-8')) | ||
65 | 1248 | finally: | 1257 | finally: |
66 | 1249 | br_from.unlock() | 1258 | br_from.unlock() |
67 | 1250 | 1259 | ||
68 | 1251 | 1260 | ||
69 | === modified file 'bzrlib/tests/blackbox/test_branch.py' | |||
70 | --- bzrlib/tests/blackbox/test_branch.py 2009-08-11 05:26:57 +0000 | |||
71 | +++ bzrlib/tests/blackbox/test_branch.py 2009-08-20 08:35:58 +0000 | |||
72 | @@ -19,7 +19,13 @@ | |||
73 | 19 | 19 | ||
74 | 20 | import os | 20 | import os |
75 | 21 | 21 | ||
77 | 22 | from bzrlib import (branch, bzrdir, errors, repository) | 22 | from bzrlib import ( |
78 | 23 | branch, | ||
79 | 24 | bzrdir, | ||
80 | 25 | errors, | ||
81 | 26 | repository, | ||
82 | 27 | revision as _mod_revision, | ||
83 | 28 | ) | ||
84 | 23 | from bzrlib.repofmt.knitrepo import RepositoryFormatKnit1 | 29 | from bzrlib.repofmt.knitrepo import RepositoryFormatKnit1 |
85 | 24 | from bzrlib.tests.blackbox import ExternalBase | 30 | from bzrlib.tests.blackbox import ExternalBase |
86 | 25 | from bzrlib.tests import ( | 31 | from bzrlib.tests import ( |
87 | @@ -52,6 +58,72 @@ | |||
88 | 52 | self.assertFalse(b._transport.has('branch-name')) | 58 | self.assertFalse(b._transport.has('branch-name')) |
89 | 53 | b.bzrdir.open_workingtree().commit(message='foo', allow_pointless=True) | 59 | b.bzrdir.open_workingtree().commit(message='foo', allow_pointless=True) |
90 | 54 | 60 | ||
91 | 61 | def test_branch_switch_no_branch(self): | ||
92 | 62 | # No branch in the current directory: | ||
93 | 63 | # => new branch will be created, but switch fails | ||
94 | 64 | self.example_branch('a') | ||
95 | 65 | self.make_repository('current') | ||
96 | 66 | self.run_bzr_error(['No WorkingTree exists for'], | ||
97 | 67 | 'branch --switch ../a ../b', working_dir='current') | ||
98 | 68 | a = branch.Branch.open('a') | ||
99 | 69 | b = branch.Branch.open('b') | ||
100 | 70 | self.assertEqual(a.last_revision(), b.last_revision()) | ||
101 | 71 | |||
102 | 72 | def test_branch_switch_no_wt(self): | ||
103 | 73 | # No working tree in the current directory: | ||
104 | 74 | # => new branch will be created, but switch fails and the current | ||
105 | 75 | # branch is unmodified | ||
106 | 76 | self.example_branch('a') | ||
107 | 77 | self.make_branch('current') | ||
108 | 78 | self.run_bzr_error(['No WorkingTree exists for'], | ||
109 | 79 | 'branch --switch ../a ../b', working_dir='current') | ||
110 | 80 | a = branch.Branch.open('a') | ||
111 | 81 | b = branch.Branch.open('b') | ||
112 | 82 | self.assertEqual(a.last_revision(), b.last_revision()) | ||
113 | 83 | work = branch.Branch.open('current') | ||
114 | 84 | self.assertEqual(work.last_revision(), _mod_revision.NULL_REVISION) | ||
115 | 85 | |||
116 | 86 | def test_branch_switch_no_checkout(self): | ||
117 | 87 | # Standalone branch in the current directory: | ||
118 | 88 | # => new branch will be created, but switch fails and the current | ||
119 | 89 | # branch is unmodified | ||
120 | 90 | self.example_branch('a') | ||
121 | 91 | self.make_branch_and_tree('current') | ||
122 | 92 | self.run_bzr_error(['Cannot switch a branch, only a checkout'], | ||
123 | 93 | 'branch --switch ../a ../b', working_dir='current') | ||
124 | 94 | a = branch.Branch.open('a') | ||
125 | 95 | b = branch.Branch.open('b') | ||
126 | 96 | self.assertEqual(a.last_revision(), b.last_revision()) | ||
127 | 97 | work = branch.Branch.open('current') | ||
128 | 98 | self.assertEqual(work.last_revision(), _mod_revision.NULL_REVISION) | ||
129 | 99 | |||
130 | 100 | def test_branch_switch_checkout(self): | ||
131 | 101 | # Checkout in the current directory: | ||
132 | 102 | # => new branch will be created and checkout bound to the new branch | ||
133 | 103 | self.example_branch('a') | ||
134 | 104 | self.run_bzr('checkout a current') | ||
135 | 105 | out, err = self.run_bzr('branch --switch ../a ../b', working_dir='current') | ||
136 | 106 | a = branch.Branch.open('a') | ||
137 | 107 | b = branch.Branch.open('b') | ||
138 | 108 | self.assertEqual(a.last_revision(), b.last_revision()) | ||
139 | 109 | work = WorkingTree.open('current') | ||
140 | 110 | self.assertEndsWith(work.branch.get_bound_location(), '/b/') | ||
141 | 111 | self.assertContainsRe(err, "Switched to branch: .*/b/") | ||
142 | 112 | |||
143 | 113 | def test_branch_switch_lightweight_checkout(self): | ||
144 | 114 | # Lightweight checkout in the current directory: | ||
145 | 115 | # => new branch will be created and lightweight checkout pointed to | ||
146 | 116 | # the new branch | ||
147 | 117 | self.example_branch('a') | ||
148 | 118 | self.run_bzr('checkout --lightweight a current') | ||
149 | 119 | out, err = self.run_bzr('branch --switch ../a ../b', working_dir='current') | ||
150 | 120 | a = branch.Branch.open('a') | ||
151 | 121 | b = branch.Branch.open('b') | ||
152 | 122 | self.assertEqual(a.last_revision(), b.last_revision()) | ||
153 | 123 | work = WorkingTree.open('current') | ||
154 | 124 | self.assertEndsWith(work.branch.base, '/b/') | ||
155 | 125 | self.assertContainsRe(err, "Switched to branch: .*/b/") | ||
156 | 126 | |||
157 | 55 | def test_branch_only_copies_history(self): | 127 | def test_branch_only_copies_history(self): |
158 | 56 | # Knit branches should only push the history for the current revision. | 128 | # Knit branches should only push the history for the current revision. |
159 | 57 | format = bzrdir.BzrDirMetaFormat1() | 129 | format = bzrdir.BzrDirMetaFormat1() |
This patch adds a new option to bzr branch that allows to switch the checkout in the current directory to the new branch. This is based on yesterday's discussion in #bzr -- http:// irclogs. ubuntu. com/2009/ 08/10/% 23bzr.html from 19:48. Another option was to add a "source" argument to bzr switch -b (http:// paste.pocoo. org/show/ 133506/), but the only way seems to be to add it to the end of the command line and "bzr <command> <target> <source>" is not used in any other bzr command except for bzr export.