Rev 6212: (jelmer) Add support for cloning into a colocated branch. (Jelmer Vernooij) in file:///srv/pqm.bazaar-vcs.org/archives/thelove/bzr/%2Btrunk/
Patch Queue Manager
pqm at pqm.ubuntu.com
Thu Oct 13 14:09:12 UTC 2011
At file:///srv/pqm.bazaar-vcs.org/archives/thelove/bzr/%2Btrunk/
------------------------------------------------------------
revno: 6212 [merge]
revision-id: pqm at pqm.ubuntu.com-20111013140911-c2zv6a9pux62xnr9
parent: pqm at pqm.ubuntu.com-20111013134409-bqexgj0ar8dw1y9c
parent: jelmer at samba.org-20111011132741-telfq15oxuj3qgmp
committer: Patch Queue Manager <pqm at pqm.ubuntu.com>
branch nick: +trunk
timestamp: Thu 2011-10-13 14:09:11 +0000
message:
(jelmer) Add support for cloning into a colocated branch. (Jelmer Vernooij)
modified:
bzrlib/builtins.py builtins.py-20050830033751-fc01482b9ca23183
bzrlib/tests/blackbox/test_branch.py test_branch.py-20060524161337-noms9gmcwqqrfi8y-1
=== modified file 'bzrlib/builtins.py'
--- a/bzrlib/builtins.py 2011-10-09 13:52:06 +0000
+++ b/bzrlib/builtins.py 2011-10-11 13:27:41 +0000
@@ -1317,29 +1317,39 @@
'already exists.') % to_location)
else:
try:
- bzrdir.BzrDir.open_from_transport(to_transport)
+ to_dir = bzrdir.BzrDir.open_from_transport(to_transport)
except errors.NotBranchError:
- pass
+ to_dir = None
else:
- raise errors.AlreadyBranchError(to_location)
+ try:
+ to_dir.open_branch()
+ except errors.NotBranchError:
+ pass
+ else:
+ raise errors.AlreadyBranchError(to_location)
except errors.NoSuchFile:
raise errors.BzrCommandError(gettext('Parent of "%s" does not exist.')
% to_location)
- try:
- # preserve whatever source format we have.
- dir = br_from.bzrdir.sprout(to_transport.base, revision_id,
- possible_transports=[to_transport],
- accelerator_tree=accelerator_tree,
- hardlink=hardlink, stacked=stacked,
- force_new_repo=standalone,
- create_tree_if_local=not no_tree,
- source_branch=br_from)
- branch = dir.open_branch()
- except errors.NoSuchRevision:
- to_transport.delete_tree('.')
- msg = gettext("The branch {0} has no revision {1}.").format(
- from_location, revision)
- raise errors.BzrCommandError(msg)
+ else:
+ to_dir = None
+ if to_dir is None:
+ try:
+ # preserve whatever source format we have.
+ to_dir = br_from.bzrdir.sprout(to_transport.base, revision_id,
+ possible_transports=[to_transport],
+ accelerator_tree=accelerator_tree,
+ hardlink=hardlink, stacked=stacked,
+ force_new_repo=standalone,
+ create_tree_if_local=not no_tree,
+ source_branch=br_from)
+ branch = to_dir.open_branch()
+ except errors.NoSuchRevision:
+ to_transport.delete_tree('.')
+ msg = gettext("The branch {0} has no revision {1}.").format(
+ from_location, revision)
+ raise errors.BzrCommandError(msg)
+ else:
+ branch = br_from.sprout(to_dir, revision_id=revision_id)
_merge_tags_if_possible(br_from, branch)
# If the source branch is stacked, the new branch may
# be stacked whether we asked for that explicitly or not.
=== modified file 'bzrlib/tests/blackbox/test_branch.py'
--- a/bzrlib/tests/blackbox/test_branch.py 2011-10-06 16:41:45 +0000
+++ b/bzrlib/tests/blackbox/test_branch.py 2011-10-11 13:27:41 +0000
@@ -63,6 +63,23 @@
self.assertFalse(b._transport.has('branch-name'))
b.bzrdir.open_workingtree().commit(message='foo', allow_pointless=True)
+ def test_into_colocated(self):
+ """Branch from a branch into a colocated branch."""
+ self.example_branch('a')
+ out, err = self.run_bzr(
+ 'init --format=development-colo file:b,branch=orig')
+ self.assertEqual(
+ """Created a standalone tree (format: development-colo)\n""",
+ out)
+ self.assertEqual('', err)
+ out, err = self.run_bzr(
+ 'branch --use-existing-dir a file:b,branch=thiswasa')
+ self.assertEqual('', out)
+ self.assertEqual('Branched 2 revisions.\n', err)
+ out, err = self.run_bzr('branches b')
+ self.assertEqual(" orig\n thiswasa\n", out)
+ self.assertEqual('', err)
+
def test_branch_broken_pack(self):
"""branching with a corrupted pack file."""
self.example_branch('a')
More information about the bazaar-commits
mailing list