At lp:///~jameinel/bzr/sort_knit_fetch
------------------------------------------------------------
revno: 4044
revision-id: [email protected]
parent: [email protected]
committer: John Arbash Meinel <[email protected]>
branch nick: sort_knit_fetch
timestamp: Wed 2009-02-25 14:12:13 -0600
message:
Add direct tests for _get_total_build_size.
=== modified file 'bzrlib/knit.py'
--- a/bzrlib/knit.py 2009-02-24 23:06:35 +0000
+++ b/bzrlib/knit.py 2009-02-25 20:12:13 +0000
@@ -807,7 +807,7 @@
versioned_files.writer.end()
-def _get_total_build_size(keys, positions):
+def _get_total_build_size(self, keys, positions):
"""Determine the total bytes to build these keys.
(helper function because _KnitGraphIndex and _KndxIndex work the same, but
@@ -2659,15 +2659,7 @@
return index_memo[0][:-1], index_memo[1]
return keys.sort(key=get_sort_key)
- def _get_total_build_size(self, keys, positions):
- """Determine the total bytes to build these keys.
-
- :param keys: Keys that we want to build
- :param positions: dict of {key, (info, index_memo, comp_parent)} (such
- as returned by _get_components_positions)
- :return: Number of bytes to build those keys
- """
- return _get_total_build_size(keys, positions)
+ _get_total_build_size = _get_total_build_size
def _split_key(self, key):
"""Split key into a prefix and suffix."""
@@ -2990,15 +2982,7 @@
return positions[key][1]
return keys.sort(key=get_index_memo)
- def _get_total_build_size(self, keys, positions):
- """Determine the total bytes to build these keys.
-
- :param keys: Keys that we want to build
- :param positions: dict of {key, (info, index_memo, comp_parent)} (such
- as returned by _get_components_positions)
- :return: Number of bytes to build those keys
- """
- return _get_total_build_size(keys, positions)
+ _get_total_build_size = _get_total_build_size
class _KnitKeyAccess(object):
=== modified file 'bzrlib/tests/test_knit.py'
--- a/bzrlib/tests/test_knit.py 2009-02-23 15:42:47 +0000
+++ b/bzrlib/tests/test_knit.py 2009-02-25 20:12:13 +0000
@@ -1093,6 +1093,26 @@
call[1][1].getvalue())
self.assertEqual({'create_parent_dir': True}, call[2])
+ def assertTotalBuildSize(self, size, keys, positions):
+ self.assertEqual(size,
+ knit._get_total_build_size(None, keys, positions))
+
+ def test__get_total_build_size(self):
+ positions = {
+ ('a',): (('fulltext', False), (('a',), 0, 100), None),
+ ('b',): (('line-delta', False), (('b',), 100, 21), ('a',)),
+ ('c',): (('line-delta', False), (('c',), 121, 35), ('b',)),
+ ('d',): (('line-delta', False), (('d',), 156, 12), ('b',)),
+ }
+ self.assertTotalBuildSize(100, [('a',)], positions)
+ self.assertTotalBuildSize(121, [('b',)], positions)
+ # c needs both a & b
+ self.assertTotalBuildSize(156, [('c',)], positions)
+ # we shouldn't count 'b' twice
+ self.assertTotalBuildSize(156, [('b',), ('c',)], positions)
+ self.assertTotalBuildSize(133, [('d',)], positions)
+ self.assertTotalBuildSize(168, [('c',), ('d',)], positions)
+
def test_get_position(self):
transport = MockTransport([
_KndxIndex.HEADER,
--
bazaar-commits mailing list
[email protected]
https://lists.ubuntu.com/mailman/listinfo/bazaar-commits