Merge lp:~luks/bzr/branch-switch into lp:~bzr/bzr/trunk-old

Proposed by Lukáš Lalinský
Status: Superseded
Proposed branch: lp:~luks/bzr/branch-switch
Merge into: lp:~bzr/bzr/trunk-old
Diff against target: 96 lines (has conflicts)
Text conflict in NEWS
To merge this branch: bzr merge lp:~luks/bzr/branch-switch
Reviewer Review Type Date Requested Status
John A Meinel Needs Fixing
Review via email: mp+9969@code.launchpad.net

This proposal has been superseded by a proposal from 2009-08-11.

Commit message

Support for `bzr branch --switch`

To post a comment you must log in.
Revision history for this message
Lukáš Lalinský (luks) wrote :

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.

Revision history for this message
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)
>
> 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.
>

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_switch_no_checkout" assert what
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://enigmail.mozdev.org/

iEYEARECAAYFAkqBnGQACgkQJdeBCYSNAAOicwCfdIjxHxP0i5y68vllU8YyArZS
EEQAn2PL4ykfHtQWUfwxkFUH3zXVGr7K
=Et4B
-----END PGP SIGNATURE-----

review: Needs Fixing
Revision history for this message
Robert Collins (lifeless) wrote :

I thought we had 'switch -b' for this case? Is there really a need to
have both switch --branch and branch --switch?

Revision history for this message
John A Meinel (jameinel) wrote :

-----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://enigmail.mozdev.org/

iEYEARECAAYFAkqB5WoACgkQJdeBCYSNAAMYjgCfVedumO+/Xo/jgl0kYg0bkPyn
t9IAn1tIjmrIboawgHcw5E17jKAg4NAy
=KqUk
-----END PGP SIGNATURE-----

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'NEWS'
--- NEWS 2009-08-11 02:58:23 +0000
+++ NEWS 2009-08-11 10:35:10 +0000
@@ -21,6 +21,7 @@
21* Further tweaks to handling of ``bzr add`` messages about ignored files.21* Further tweaks to handling of ``bzr add`` messages about ignored files.
22 (Jason Spashett, #76616)22 (Jason Spashett, #76616)
2323
24<<<<<<< TREE
24Improvements25Improvements
25************26************
2627
@@ -54,6 +55,19 @@
54with bugfix-only releases based on it continuing for at least six months55with bugfix-only releases based on it continuing for at least six months
55or until the following stable release.56or until the following stable release.
5657
58=======
59New Features
60************
61
62* ``bzr branch --switch`` can now switch the checkout in the current directory
63 to the newly created branch. (Lukáš Lalinský)
64
65In Development
66##############
67
68Compatibility Breaks
69********************
70>>>>>>> MERGE-SOURCE
5771
58New Features72New Features
59************73************
6074
=== modified file 'bzrlib/builtins.py'
--- bzrlib/builtins.py 2009-08-10 08:25:53 +0000
+++ bzrlib/builtins.py 2009-08-11 10:35:10 +0000
@@ -1167,6 +1167,9 @@
1167 help='Hard-link working tree files where possible.'),1167 help='Hard-link working tree files where possible.'),
1168 Option('no-tree',1168 Option('no-tree',
1169 help="Create a branch without a working-tree."),1169 help="Create a branch without a working-tree."),
1170 Option('switch',
1171 help="Switch the checkout in the current directory "
1172 "to the new branch."),
1170 Option('stacked',1173 Option('stacked',
1171 help='Create a stacked branch referring to the source branch. '1174 help='Create a stacked branch referring to the source branch. '
1172 'The new branch will depend on the availability of the source '1175 'The new branch will depend on the availability of the source '
@@ -1183,9 +1186,12 @@
11831186
1184 def run(self, from_location, to_location=None, revision=None,1187 def run(self, from_location, to_location=None, revision=None,
1185 hardlink=False, stacked=False, standalone=False, no_tree=False,1188 hardlink=False, stacked=False, standalone=False, no_tree=False,
1186 use_existing_dir=False):1189 use_existing_dir=False, switch=False):
1190 from bzrlib import switch as _mod_switch
1187 from bzrlib.tag import _merge_tags_if_possible1191 from bzrlib.tag import _merge_tags_if_possible
11881192 if switch:
1193 # Check if we have a WT in the current directory
1194 wt, _ = WorkingTree.open_containing('.')
1189 accelerator_tree, br_from = bzrdir.BzrDir.open_tree_or_branch(1195 accelerator_tree, br_from = bzrdir.BzrDir.open_tree_or_branch(
1190 from_location)1196 from_location)
1191 if (accelerator_tree is not None and1197 if (accelerator_tree is not None and
@@ -1245,6 +1251,11 @@
1245 except (errors.NotStacked, errors.UnstackableBranchFormat,1251 except (errors.NotStacked, errors.UnstackableBranchFormat,
1246 errors.UnstackableRepositoryFormat), e:1252 errors.UnstackableRepositoryFormat), e:
1247 note('Branched %d revision(s).' % branch.revno())1253 note('Branched %d revision(s).' % branch.revno())
1254 if switch:
1255 # Switch to the new branch
1256 _mod_switch.switch(wt.bzrdir, branch)
1257 note('Switched to branch: %s',
1258 urlutils.unescape_for_display(branch.base, 'utf-8'))
1248 finally:1259 finally:
1249 br_from.unlock()1260 br_from.unlock()
12501261
12511262
=== modified file 'bzrlib/tests/blackbox/test_branch.py'
--- bzrlib/tests/blackbox/test_branch.py 2009-08-03 04:19:03 +0000
+++ bzrlib/tests/blackbox/test_branch.py 2009-08-11 10:35:10 +0000
@@ -52,6 +52,19 @@
52 self.assertFalse(b._transport.has('branch-name'))52 self.assertFalse(b._transport.has('branch-name'))
53 b.bzrdir.open_workingtree().commit(message='foo', allow_pointless=True)53 b.bzrdir.open_workingtree().commit(message='foo', allow_pointless=True)
5454
55 def test_branch_switch_no_checkout(self):
56 self.example_branch('a')
57 self.run_bzr_error(['Cannot switch a branch, only a checkout'],
58 'branch --switch a b', working_dir='.')
59
60 def test_branch_switch(self):
61 self.example_branch('a')
62 self.run_bzr('checkout --lightweight a tree')
63 out, err = self.run_bzr('branch --switch ../a ../b', working_dir='tree')
64 tree = WorkingTree.open('tree')
65 self.assertEndsWith(tree.branch.base, '/b/')
66 self.assertContainsRe(err, "Switched to branch: .*/b/")
67
55 def test_branch_only_copies_history(self):68 def test_branch_only_copies_history(self):
56 # Knit branches should only push the history for the current revision.69 # Knit branches should only push the history for the current revision.
57 format = bzrdir.BzrDirMetaFormat1()70 format = bzrdir.BzrDirMetaFormat1()