[MERGE][#251871] Use source_branch.sprout in BzrDir.sprout when possible.
andrew at canonical.com
Thu Jul 31 10:02:22 BST 2008
This patch fixes bzr.dev so that branching with the bzr-svn plugin (using the
latest tip of the stable branch) works again. When sprouting from an SvnBranch,
calling source._format.initialise(result) was failing because SvnBranchFormat
simply raises NotImplementedError, which is somewhat reasonable as generally you
cannot create them at arbitrary locations outside an SVN repository. (Perhaps
IncompatibleFormat or UninitializableFormat would be a more appropriate error
for bzr-svn to raise, but it doesn't really matter.)
Basically, this patch just reverts BzrDir.sprout to calling source_branch.sprout
when it can, which is how things used to work.
There's a bit of tension in BzrDir.sprout about which format to use for the
result_branch. Generally it wants to preserve the source format, except:
* sometimes we require a stacking-compatible format, even if the source isn't
* sometimes we might be cloning from a bzrdir with no branch (although comments
in the code speculate that this may be a dead code path...)
* sometimes, as with bzr-svn, the source format isn't actually initializable.
This could happen with very old bzr formats too I suppose (those that are no
longer supported for writing, just reading).
This patch preserves the existing logic for the force-stacking and
no-source-branch cases: they are special-cased and don't call
source_branch.sprout. The general case now relies on source_branch.sprout to
make an appropriate choice of format, which is how bzr-svn decides to create
rich-root-pack branches for SvnBranches.
I'm pretty sure we'll be touching this code again at some point in the future.
For instance the duplication of Branch.sprout logic later in the function smells
a bit (as the comment acknowledges). But this seems like a simple and correct
change for now, even if it doesn't get rid of the underlying messiness. It's a
bit late in the release cycle for deep changes anyway...
This patch currently lacks a test: perhaps an appropriate test would be that
sprouting a bzrdir works when the a source branch has:
* an uninitialisable format
* a working sprout method
I'm have a niggling feeling that's too specific, but perhaps it's fine.
I've tested this branch quite a bit manually. With the attached bundle, and
this small patch to bzr-svn I can branch and branch --stacked direct from an SVN
repo and SVN checkouts:
=== modified file 'workingtree.py'
--- workingtree.py 2008-07-23 16:06:27 +0000
+++ workingtree.py 2008-07-31 06:31:24 +0000
@@ -21,7 +21,7 @@
from bzrlib.bzrdir import BzrDirFormat, BzrDir
from bzrlib.errors import (InvalidRevisionId, NotBranchError, NoSuchFile,
NoRepositoryPresent, BzrError, UninitializableFormat,
+ OutOfDateTree, NoSuchRevisionInTree)
from bzrlib.inventory import Inventory, InventoryFile, InventoryLink
from bzrlib.lockable_files import TransportLock, LockableFiles
from bzrlib.lockdir import LockDir
@@ -581,6 +581,9 @@
+ def revision_tree(self, revision_id):
+ raise NoSuchRevisionInTree(self, revision_id)
That patch fixes a traceback when branching from a checkout.
(Btw, it appears that "bzr info -v" inside a branch stacked on an SvnBranch
fails, not sure yet if it's a bzr-svn issue or a bzr issue.)
-------------- next part --------------
A non-text attachment was scrubbed...
Size: 4156 bytes
Desc: not available
Url : https://lists.ubuntu.com/archives/bazaar/attachments/20080731/0e637e12/attachment.bin
More information about the bazaar