[MERGE] Even faster branching
Ian Clatworthy
ian.clatworthy at internode.on.net
Thu Dec 20 08:59:43 GMT 2007
Aaron Bentley wrote:
> Hi all,
>
> This version is even faster than the previous one
Sweet.
bb:tweak
I'd like to see the accelerator_tree param documented in the docstrings
of at least one of the public functions/methods, e.g. bzrdir.sprout,
workingtree.initialize. Also, a few minor tweaks to the tests as noted
below. Otherwise looks good to me.
> + def test_open_tree_or_branch(self):
> + def local_branch_path(branch):
> + return os.path.realpath(
> + urlutils.local_path_from_url(branch.base))
> +
> + self.make_branch_and_tree('topdir')
> + tree, branch = bzrdir.BzrDir.open_tree_or_branch('topdir')
> + self.assertEqual(os.path.realpath('topdir'),
> + os.path.realpath(tree.basedir))
> + self.assertEqual(os.path.realpath('topdir'),
> + local_branch_path(branch))
> + self.assertIs(tree.bzrdir, branch.bzrdir)
> + # opening from non-local should not return the tree
> + tree, branch, relpath = bzrdir.BzrDir.open_containing_tree_or_branch(
> + self.get_readonly_url('topdir/foo'))
> + self.assertEqual(None, tree)
> + self.assertEqual('foo', relpath)
> + # without a tree:
> + self.make_branch('topdir/foo')
> + tree, branch, relpath = bzrdir.BzrDir.open_containing_tree_or_branch(
> + 'topdir/foo')
> + self.assertIs(tree, None)
> + self.assertEqual(os.path.realpath('topdir/foo'),
> + local_branch_path(branch))
> + self.assertEqual('', relpath)
> +
The calls to open_containing_tree_or_branch need to be replaced with
calls to open_tree_or_branch. I'm guessing this was missed after a
copy-and-paste. :-)
> + def test_build_tree_accelerator_tree(self):
> + source = self.make_branch_and_tree('source')
> + self.build_tree_contents([('source/file1', 'A')])
> + self.build_tree_contents([('source/file2', 'B')])
> + source.add(['file1', 'file2'], ['file1-id', 'file2-id'])
> + source.commit('commit files')
> + self.build_tree_contents([('source/file2', 'C')])
> + calls = []
> + real_source_get_file = source.get_file
> + def get_file(file_id, path=None):
> + calls.append(file_id)
> + return real_source_get_file(file_id, path)
> + source.get_file = get_file
> + source.lock_read()
> + self.addCleanup(source.unlock)
> + target = self.make_branch_and_tree('target')
> + build_tree(source.basis_tree(), target, source)
> + self.assertEqual(['file1-id'], calls)
As well as trapping and testing calls as you're doing, I'd like to see
the contents of the files in the result tree explicitly tested for
correctness. The right file-ids but the wrong contents would be a bit
upsetting to users ...
Ian C.
More information about the bazaar
mailing list