[MERGE][#270397] Fix branch --stacked from a branch on a smart server. Also, a question about branch.sprout.

Andrew Bennetts andrew.bennetts at canonical.com
Mon Oct 27 00:54:19 GMT 2008


Doing “bzr branch --stacked” from a smart server into a standalone branch is
failing because the created repository is in the wrong format:

    $ bzr branch --stacked bzr://localhost/trunk local-trunk
    Source format does not support stacking, using format: '1.6'
      Packs 5 (adds stacking support, requires bzr 1.6)
    
    bzr: ERROR: The branch 'file:///tmp/test-area/local-trunk/'(Bazaar Branch
    Format 6 (bzr 0.15)) is not a stackable format. You will need to upgrade the
    branch to permit branch stacking.

Somewhere between 1.6 and 1.7 Branch.sprout was updated to use the given
to_bzrdir to choose the format of the new branch, rather than just making it the
same as the branch being sprouted from.  This is used to make --stacked work:
BzrDir.sprout will ensure that the new bzrdir object passed to the source
branch's sprout will cause a stackable branch (i.e. format 7) to be created if
stacked=True.

Unforntunately, RemoteBranch.sprout was not updated for the new contract, and
the tests failed to notice this.

This branch fixes RemoteBranch.sprout and adds an explicit test that stacking
from a smart server branch works.

It's enough to fix <https://bugs.launchpad.net/bzr/+bug/270397>, but I think we
need to do more than I've done here.  The tests in
branch_implementations.test_sprout should really cover this behaviour as well.
In fact there's already a test that looks like it tests the contract here, but
it's misleading:

    def test_sprout_preserves_kind(self):
        branch1 = self.make_branch('branch1')
        target_repo = self.make_repository('branch2')
        target_repo.fetch(branch1.repository)
        branch2 = branch1.sprout(target_repo.bzrdir)
        if isinstance(branch1, remote.RemoteBranch):
            branch1._ensure_real()
            target_class = branch1._real_branch.__class__
        else:
            target_class = branch1.__class__
        self.assertIsInstance(branch2, target_class)

The contract isn't simply “sprout preserves kind” anymore, but this test is
still passing despite that.  I think this particular test covers “sprout
preserves kind if the to_bzrdir doesn't specify something else”... which is a
start, but obviously leaves some important gaps :)

I think perhaps we've been a little fuzzy on exactly what the design here is.
Rather than assume I know what all the requirements and intentions are, I'll
ask:

What exactly is the behaviour of some_branch.sprout meant to be?

-Andrew.

-------------- next part --------------
A non-text attachment was scrubbed...
Name: bug-270397-3795.patch
Type: text/x-diff
Size: 8552 bytes
Desc: not available
Url : https://lists.ubuntu.com/archives/bazaar/attachments/20081027/88ace8d6/attachment-0001.bin 


More information about the bazaar mailing list