[MERGE] compare_trees with all unknowns

John Arbash Meinel john at arbash-meinel.com
Wed Jul 26 21:57:38 BST 2006


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

Robert Collins wrote:

...

> FYI
> Heres an incremental patch to my tree_implementations patch that adds
> trees matching all your test trees - I'll be using these in the
> Tree.compare() patch.
> 
> Cheers,
> Rob
> 
> 

...

v- This is the full permutation (which is nice). However, should it
really be part of the base level TestTreeImplementations class?
It seems more specialized to specifically testing 'InterTree.compare()'
so it should be on a different base class.

>  
> +    def _make_abc_tree(self, tree):
> +        """setup an abc content tree."""
> +        files = ['a', 'b/', 'b/c']
> +        self.build_tree(files, transport=tree.bzrdir.root_transport)
> +        tree.add(files, ['a-id', 'b-id', 'c-id'])

...

v- I realize you are testing it here, though. So maybe it is okay. If
you think it is something that a large portion of the Tree tests are
going to want.

> === modified file 'bzrlib/tests/tree_implementations/test_test_trees.py'
> --- bzrlib/tests/tree_implementations/test_test_trees.py	2006-07-21 01:37:47 +0000
> +++ bzrlib/tests/tree_implementations/test_test_trees.py	2006-07-25 05:50:52 +0000
> @@ -28,3 +28,96 @@
>          self.assertEqual([], tree.conflicts())
>          self.assertEqual([], list(tree.unknowns()))
>          self.assertEqual([inventory.ROOT_ID], list(iter(tree)))
> +        self.assertEqual(
> +            [('', inventory.ROOT_ID)],
> +            [(path, node.file_id) for path, node in tree.iter_entries_by_dir()])
> +
> +    def test_abc_tree_no_parents(self):
> +        tree = self.get_tree_no_parents_abc_content()
> +        self.assertEqual([], tree.get_parent_ids())
> +        self.assertEqual([], tree.conflicts())
> +        self.assertEqual([], list(tree.unknowns()))
> +        # __iter__ has no strongly defined order
> +        self.assertEqual(
> +            set([inventory.ROOT_ID, 'a-id', 'b-id', 'c-id']),
> +            set(iter(tree)))
> +        self.assertEqual(
> +            [('', inventory.ROOT_ID), ('a', 'a-id'), ('b', 'b-id'), ('b/c', 'c-id')],
> +            [(path, node.file_id) for path, node in tree.iter_entries_by_dir()])
> +        self.assertEqualDiff('contents of a\n', tree.get_file_text('a-id'))
> +        self.assertFalse(tree.is_executable('c-id'))

...

> 
> === modified file 'bzrlib/workingtree.py'
> --- bzrlib/workingtree.py	2006-07-24 03:34:16 +0000
> +++ bzrlib/workingtree.py	2006-07-25 03:14:21 +0000
> @@ -459,6 +459,9 @@
>      def get_file(self, file_id):
>          return self.get_file_byname(self.id2path(file_id))
>  
> +    def get_file_text(self, file_id):
> +        return self.get_file(file_id).read()
> +
>      def get_file_byname(self, filename):
>          return file(self.abspath(filename), 'rb')


Is there a need for 'get_file_text()'?

So a couple small issues. If you have good responses for them, +1 from me.

John
=:->
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.2.2 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFEx9dCJdeBCYSNAAMRAlLcAKDPIL6esjYaJsJypZDfBrqWISwV3ACgqtvO
J6CahllPB+i/ql8+xnCRPag=
=OwKy
-----END PGP SIGNATURE-----




More information about the bazaar mailing list