[MERGE] Policy-based repository acquisition

Andrew Bennetts andrew at canonical.com
Wed Apr 9 15:39:07 BST 2008


Aaron Bentley wrote:
> >> === modified file 'bzrlib/bzrdir.py'
> > [...]
> >> +    def cloning_metadir(self):
> >> +        """Produce a metadir suitable for cloning with."""
> >> +        return self._format.__class__()
> >> +
> > 
> > I don't think this method is going to produce the right result with
> > RemoteBzrDirs.  You are missing some test coverage for this I suspect.
> 
> I don't understand.  I'm implementing a method on BzrDirPreSplitOut,
> which RemoteBzrDir does not derive from.

Oops, I missed "@@ -1010,6 +1050,10 @@" line in the diff indicating that this
hunk was much later than the bits I'd just read.

> > I don't think the intent of this test is entirely self-evident, either.  How
> > about adding a docstring like: "A bzrdir will by default use itself when
> > acquiring a repository (creating one if necessary.)"  Did I guess right?
> 
> The bit about creating one if necessary is wrong-- it always creates it.

Just goes to show that the intent wasn't self-evident, then :)

> >> +    def test_clone_on_transport_preserves_repo_format(self):
> >> +        source_branch = self.make_branch('source', format='knit')
> >> +        # Ensure no format data is cached
> >> +        a_dir = bzrlib.branch.Branch.open_from_transport(
> >> +            self.get_transport('source')).bzrdir
> >> +        target_transport = a_dir.root_transport.clone('..').clone('target')
> >> +        target_bzrdir = a_dir.clone_on_transport(target_transport)
> >> +        target_repo = target_bzrdir.open_repository()
> >> +        self.assertEqual(target_repo._format, source_branch.repository._format)
> > 
> > I think this probably ought to be a bzrdir_implementations test
> 
> No.  I tried it and it just didn't work properly.  It seemed like the
> test infrastructure was interfering with creating a knit repo.

That's a shame.  The test infrastructure is there to help rather than hinder.
We should figure out how to improve this part of the test infrastructure at some
point...

In the meantime, it's little a bit of a hack, but if you do this inside
TestBzrDir:

        bd = TestCaseWithTransport.make_bzrdir(self, 'source', format='knit')
        bd.create_repository()
        source_branch = bd.create_branch()

instead of:

        source_branch = self.make_branch('source', format='knit')

you get a branch with a KnitRepository.

-Andrew.




More information about the bazaar mailing list