[MERGE] Additional fetch testcase
Martin Pool
mbp at canonical.com
Wed Oct 18 06:55:06 BST 2006
On 17 Oct 2006, Aaron Bentley <aaron.bentley at utoronto.ca> wrote:
> This testcase ensures that the tree root's knit is updated properly. I
> wrote it to make sure nothing was wrong with
> WorkingTree.fileids_altered_by_revision_ids, and nothing is. But I
> figure extra testing is always good.
>
> Aaron
> -----BEGIN PGP SIGNATURE-----
> Version: GnuPG v1.4.2.2 (GNU/Linux)
> Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org
>
> iD8DBQFFNZZG0F+nu1YWqI0RAiPAAJ4iYQn8XsRqAMu/vQhHII2J7OLfJgCfdiIp
> QjoTYMejO5noRV/0Laodl4E=
> =TX2G
> -----END PGP SIGNATURE-----
> # Bazaar revision bundle v0.8
> #
> # message:
> # Ensure that fetch properly updates inventory root knit
> # committer: Aaron Bentley <aaron.bentley at utoronto.ca>
> # date: Tue 2006-10-17 22:44:51.680999994 -0400
>
> === modified file bzrlib/tests/test_fetch.py
> --- bzrlib/tests/test_fetch.py
> +++ bzrlib/tests/test_fetch.py
> @@ -17,6 +17,7 @@
> import os
> import sys
>
> +from bzrlib import bzrdir, repository
> from bzrlib.branch import Branch
> from bzrlib.bzrdir import BzrDir
> from bzrlib.builtins import merge
> @@ -25,6 +26,7 @@
> from bzrlib.tests.HTTPTestUtil import TestCaseWithWebserver
> from bzrlib.tests.test_revision import make_branches
> from bzrlib.trace import mutter
> +from bzrlib.upgrade import Convert
> from bzrlib.workingtree import WorkingTree
>
>
> @@ -113,6 +115,33 @@
> wt = self.make_branch_and_tree('br')
> self.assertEqual(wt.branch.fetch(wt.branch), (0, []))
>
> + def test_fetch_root_knit(self):
> + """Ensure that knit2 updates the root knit
> +
> + This tests the case where the root has been changed
> + """
> + knit1 = bzrdir.BzrDirMetaFormat1()
> + knit1.repository_format = repository.RepositoryFormatKnit1()
> + knit2 = bzrdir.BzrDirMetaFormat1()
> + knit2.repository_format = repository.RepositoryFormatKnit2()
Perhaps call these knit1_format, and so on? Reading this I expect
'knit1' to be a Knit.
> + tree = self.make_branch_and_tree('tree', knit1)
> + tree.set_root_id('tree-root')
> + tree.commit('rev1', rev_id='rev1')
> + tree.commit('rev2', rev_id='rev2')
> + Convert(tree.basedir, knit2)
> + tree = WorkingTree.open(tree.basedir)
> + branch = self.make_branch('branch', format=knit2)
> + branch.pull(tree.branch, stop_revision='rev1')
> + repo = branch.repository
A couple of lines above this I have trouble understanding *why* you're
doing this, and maybe some comments explaining that would help. In
regular code inline comments can be a sign it needs to be cleaned up; in
tests sometimes even straightforward code needs explanation of why.
> + root_weave = repo.weave_store.get_weave('tree-root',
> + repo.get_transaction())
> + self.assertTrue('rev1' in root_weave)
> + self.assertTrue('rev2' not in root_weave)
> + branch.pull(tree.branch)
> + root_weave = repo.weave_store.get_weave('tree-root',
> + repo.get_transaction())
> + self.assertTrue('rev2' in root_weave)
> +
+1 for adding the test with those changes, though I'd like to hear
Robert's opinion on this from a testing point of view.
--
Martin
More information about the bazaar
mailing list