RFC: difference in dirstate iter_changes and inventory iter_changes
Robert Collins
robertc at robertcollins.net
Wed Aug 13 04:00:07 BST 2008
On Thu, 2008-08-07 at 23:07 -0400, Aaron Bentley wrote:
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
>
> Robert Collins wrote:
> > tree.add('foo')
> > os.unlink('foo')
> > len(tree.iter_changes(tree.basis_tree()))
> > -> 1 for inventory based iter_changes
> > -> 0 for dirstate
> >
> > any objection to my making these consistently 1 ?
>
> I'm in favour of that.
Partly done, and I found an interesting thing:
consider these two tests:
=== modified file 'bzrlib/tests/intertree_implementations/test_compare.py'
--- bzrlib/tests/intertree_implementations/test_compare.py 2008-03-07 14:25:46 +0000
+++ bzrlib/tests/intertree_implementations/test_compare.py 2008-08-13 02:50:31 +0000
@@ -695,6 +695,32 @@
])
self.assertEqual(expected, self.do_iter_changes(tree1, tree2))
+ def test_only_in_source_and_missing(self):
+ tree1 = self.make_branch_and_tree('tree1')
+ tree2 = self.make_to_branch_and_tree('tree2')
+ tree2.set_root_id(tree1.get_root_id())
+ self.build_tree(['tree1/file'])
+ tree1.add(['file'], ['file-id'])
+ os.unlink('tree1/file')
+ tree1, tree2 = self.mutable_trees_to_locked_test_trees(tree1, tree2)
+ root_id = tree1.path2id('')
+ expected = [('file-id', ('file', None), False, (True, False),
+ (root_id, None), ('file', None), (None, None), (False, None))]
+ self.assertEqual(expected, self.do_iter_changes(tree1, tree2))
+
+ def test_only_in_target_and_missing(self):
+ tree1 = self.make_branch_and_tree('tree1')
+ tree2 = self.make_to_branch_and_tree('tree2')
+ tree2.set_root_id(tree1.get_root_id())
+ self.build_tree(['tree2/file'])
+ tree2.add(['file'], ['file-id'])
+ os.unlink('tree2/file')
+ tree1, tree2 = self.mutable_trees_to_locked_test_trees(tree1, tree2)
+ root_id = tree1.path2id('')
+ expected = [('file-id', (None, 'file'), False, (False, True),
+ (None, root_id), (None, 'file'), (None, None), (None, False))]
+ self.assertEqual(expected, self.do_iter_changes(tree1, tree2))
+
def test_unchanged_with_renames_and_modifications(self):
"""want_unchanged should generate a list of unchanged entries."""
tree1 = self.make_branch_and_tree('1')
Both fail on DirState as I expected; on the inventory based case though,
one passes and one fails - but the tests are symmetrical!
So whats the failure?
Turns out that
missing-in-source returns True to 'content_change' and
missing-in-target-only returns False to 'content_change'.
I think False is a better answer (the content hasn't changed from one
tree to the other - its absent in both) so I'm going to fix the
missing-only-in-source case unless someone replies to the mail objecting
or providing a rationale for it being assymetric.
-Rob
--
GPG key available at: <http://www.robertcollins.net/keys.txt>.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: This is a digitally signed message part
Url : https://lists.ubuntu.com/archives/bazaar/attachments/20080813/46f91029/attachment-0001.pgp
More information about the bazaar
mailing list