Rev 4478: add a test case that covers what the new fix actually does. in http://bazaar.launchpad.net/~jameinel/bzr/lifeless/bug-390563
John Arbash Meinel
john at arbash-meinel.com
Thu Jun 25 15:48:29 BST 2009
At http://bazaar.launchpad.net/~jameinel/bzr/lifeless/bug-390563
------------------------------------------------------------
revno: 4478
revision-id: john at arbash-meinel.com-20090625144813-7uxhjg41f7y0r7uh
parent: robertc at robertcollins.net-20090625093429-llak4vj4q5nlqt2e
committer: John Arbash Meinel <john at arbash-meinel.com>
branch nick: bug-390563
timestamp: Thu 2009-06-25 09:48:13 -0500
message:
add a test case that covers what the new fix actually does.
-------------- next part --------------
=== modified file 'bzrlib/chk_map.py'
--- a/bzrlib/chk_map.py 2009-06-25 09:34:29 +0000
+++ b/bzrlib/chk_map.py 2009-06-25 14:48:13 +0000
@@ -1,4 +1,4 @@
-# Copyright (C) 2008 Canonical Ltd
+# Copyright (C) 2008, 2009 Canonical Ltd
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@@ -1465,7 +1465,7 @@
all_uninteresting_items.update(uninteresting_items)
del uninteresting_items
# Do not examine in detail pages common to all interesting trees.
- # Pages that are common to all interesting trees will have their
+ # Pages that are common to all interesting trees will have their
# older versions found via the uninteresting tree traversal. Some pages
# found via the interesting trees traversal will be uninteresting for
# other of the interesting trees, which is why we require the pages to be
=== modified file 'bzrlib/tests/test_chk_map.py'
--- a/bzrlib/tests/test_chk_map.py 2009-06-25 09:34:29 +0000
+++ b/bzrlib/tests/test_chk_map.py 2009-06-25 14:48:13 +0000
@@ -1,4 +1,4 @@
-# Copyright (C) 2008 Canonical Ltd
+# Copyright (C) 2008, 2009 Canonical Ltd
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@@ -1894,8 +1894,8 @@
self).get_chk_bytes()
return self._chk_bytes
- def get_map_key(self, a_dict):
- c_map = self._get_map(a_dict, maximum_size=10,
+ def get_map_key(self, a_dict, maximum_size=10):
+ c_map = self._get_map(a_dict, maximum_size=maximum_size,
chk_bytes=self.get_chk_bytes())
return c_map.key()
@@ -2154,7 +2154,16 @@
('abb',): 'right'
})
basis_map = CHKMap(self.get_chk_bytes(), basis)
- basis_map._dump_tree()
+ self.assertEqualDiff(
+ "'' InternalNode\n"
+ " 'a' InternalNode\n"
+ " 'aa' LeafNode\n"
+ " ('aaa',) 'left'\n"
+ " 'ab' LeafNode\n"
+ " ('abb',) 'right'\n"
+ " 'c' LeafNode\n"
+ " ('ccc',) 'common'\n",
+ basis_map._dump_tree())
# Get left expected data
left_map = CHKMap(self.get_chk_bytes(), left)
self.assertEqualDiff(
@@ -2184,3 +2193,68 @@
(right, []),
(l_d_key, [(('ddd',), 'change')]),
], [left, right], [basis])
+
+ def test_multiple_maps_similar(self):
+ # We want to have a depth=2 tree, with multiple entries in each leaf
+ # node
+ basis = self.get_map_key({
+ ('aaa',): 'unchanged',
+ ('abb',): 'will change left',
+ ('caa',): 'unchanged',
+ ('cbb',): 'will change right',
+ }, maximum_size=60)
+ left = self.get_map_key({
+ ('aaa',): 'unchanged',
+ ('abb',): 'changed left',
+ ('caa',): 'unchanged',
+ ('cbb',): 'will change right',
+ }, maximum_size=60)
+ right = self.get_map_key({
+ ('aaa',): 'unchanged',
+ ('abb',): 'will change left',
+ ('caa',): 'unchanged',
+ ('cbb',): 'changed right',
+ }, maximum_size=60)
+ basis_map = CHKMap(self.get_chk_bytes(), basis)
+ self.assertEqualDiff(
+ "'' InternalNode\n"
+ " 'a' LeafNode\n"
+ " ('aaa',) 'unchanged'\n"
+ " ('abb',) 'will change left'\n"
+ " 'c' LeafNode\n"
+ " ('caa',) 'unchanged'\n"
+ " ('cbb',) 'will change right'\n",
+ basis_map._dump_tree())
+ # Get left expected data
+ left_map = CHKMap(self.get_chk_bytes(), left)
+ self.assertEqualDiff(
+ "'' InternalNode\n"
+ " 'a' LeafNode\n"
+ " ('aaa',) 'unchanged'\n"
+ " ('abb',) 'changed left'\n"
+ " 'c' LeafNode\n"
+ " ('caa',) 'unchanged'\n"
+ " ('cbb',) 'will change right'\n",
+ left_map._dump_tree())
+ # Keys from left side target
+ l_a_key = left_map._root_node._items['a'].key()
+ l_c_key = left_map._root_node._items['c'].key()
+ # Get right expected data
+ right_map = CHKMap(self.get_chk_bytes(), right)
+ self.assertEqualDiff(
+ "'' InternalNode\n"
+ " 'a' LeafNode\n"
+ " ('aaa',) 'unchanged'\n"
+ " ('abb',) 'will change left'\n"
+ " 'c' LeafNode\n"
+ " ('caa',) 'unchanged'\n"
+ " ('cbb',) 'changed right'\n",
+ right_map._dump_tree())
+ r_a_key = right_map._root_node._items['a'].key()
+ r_c_key = right_map._root_node._items['c'].key()
+ self.assertIterInteresting(
+ [(left, []),
+ (right, []),
+ (l_a_key, [(('abb',), 'changed left')]),
+ (r_c_key, [(('cbb',), 'changed right')]),
+ ], [left, right], [basis])
More information about the bazaar-commits
mailing list