[MERGE] test_ancestry performance tweaks

John Arbash Meinel john at arbash-meinel.com
Wed Oct 4 06:06:22 BST 2006


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Robert Collins wrote:
> This is a small tweak to test_ancestry - 
> 

I think you meant this is a small performance tweak to use Memory
transport since Ancestry doesn't need a real working tree.

But +1 from me anyway.

John
=:->

> 
> ------------------------------------------------------------------------
> 
> === modified file 'bzrlib/tests/test_ancestry.py'
> --- bzrlib/tests/test_ancestry.py	2006-07-28 16:05:23 +0000
> +++ bzrlib/tests/test_ancestry.py	2006-10-04 04:48:05 +0000
> @@ -19,42 +19,37 @@
>  import os
>  import sys
>  
> -from bzrlib.tests import TestCase, TestCaseWithTransport
> +from bzrlib.tests import TestCaseWithMemoryTransport
>  from bzrlib.branch import Branch
>  from bzrlib.revision import is_ancestor
>  
>  
> -class TestAncestry(TestCaseWithTransport):
> +class TestAncestry(TestCaseWithMemoryTransport):
> +
> +    def assertAncestryEqual(self, expected, revision_id, branch):
> +        """Assert that the ancestry of revision_id in branch is as expected."""
> +        ancestry = branch.repository.get_ancestry(revision_id)
> +        self.assertEqual(expected, ancestry)
>  
>      def test_straightline_ancestry(self):
>          """Test ancestry file when just committing."""
> -        wt = self.make_branch_and_tree('.')
> -        b = wt.branch
> -
> -        wt.commit(message='one',
> -                  allow_pointless=True,
> -                  rev_id='tester at foo--1')
> -
> -        wt.commit(message='two',
> -                  allow_pointless=True,
> -                  rev_id='tester at foo--2')
> -
> -        ancs = b.repository.get_ancestry('tester at foo--2')
> -        self.assertEqual([None, 'tester at foo--1', 'tester at foo--2'], ancs)
> -        self.assertEqual([None, 'tester at foo--1'], 
> -                         b.repository.get_ancestry('tester at foo--1'))
> +        tree = self.make_branch_and_memory_tree('.')
> +        branch = tree.branch
> +        rev_id_one = tree.commit('one')
> +        rev_id_two = tree.commit('two', allow_pointless=True)
> +
> +        self.assertAncestryEqual([None, rev_id_one, rev_id_two],
> +            rev_id_two, branch)
> +        self.assertAncestryEqual([None, rev_id_one], rev_id_one, branch)
>  
>      def test_none_is_always_an_ancestor(self):
> -        wt = self.make_branch_and_tree('.')
> -        b = wt.branch
> +        tree = self.make_branch_and_memory_tree('.')
>          # note this is tested before any commits are done.
> -        self.assertEqual(True, is_ancestor(None, None, b))
> -        wt.commit(message='one',
> -                  allow_pointless=True,
> -                  rev_id='tester at foo--1')
> -        self.assertEqual(True, is_ancestor(None, None, b))
> -        self.assertEqual(True, is_ancestor('tester at foo--1', None, b))
> -        self.assertEqual(False, is_ancestor(None, 'tester at foo--1', b))
> +        self.assertTrue(is_ancestor(None, None, tree.branch))
> +        rev_id = tree.commit('one')
> +        self.assertTrue(is_ancestor(None, None, tree.branch))
> +        self.assertTrue(is_ancestor(rev_id, None, tree.branch))
> +        self.assertFalse(is_ancestor(None, rev_id, tree.branch))
>  
>  
>  # TODO: check that ancestry is updated to include indirectly merged revisions
> 
> === modified file 'bzrlib/tests/test_memorytree.py'
> --- bzrlib/tests/test_memorytree.py	2006-09-15 02:03:15 +0000
> +++ bzrlib/tests/test_memorytree.py	2006-10-04 04:03:43 +0000
> @@ -140,3 +140,9 @@
>          tree.unversion(['foo-id'])
>          self.assertFalse(tree.has_id('foo-id'))
>          tree.unlock()
> +
> +    def test_last_revision(self):
> +        """There should be a last revision method we can call."""
> +        tree = self.make_branch_and_memory_tree('branch')
> +        rev_id = tree.commit('first post')
> +        self.assertEqual(rev_id, tree.last_revision())
> 

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.5 (Darwin)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFFI0FNJdeBCYSNAAMRAiwrAKDFztpmGrZenNFXpTtuv7YjMHPArACgpiEf
9sovZUX7lxX59xOE6/ytdrk=
=ellj
-----END PGP SIGNATURE-----




More information about the bazaar mailing list