Rev 2637: Implement KnitGraphIndex.get_method. in http://people.ubuntu.com/~robertc/baz2.0/repository
Robert Collins
robertc at robertcollins.net
Fri Jul 13 20:00:05 BST 2007
At http://people.ubuntu.com/~robertc/baz2.0/repository
------------------------------------------------------------
revno: 2637
revision-id: robertc at robertcollins.net-20070713190002-izvtokos305lqjzn
parent: robertc at robertcollins.net-20070713185447-8edq39gs1yj548m1
committer: Robert Collins <robertc at robertcollins.net>
branch nick: repository
timestamp: Sat 2007-07-14 05:00:02 +1000
message:
Implement KnitGraphIndex.get_method.
modified:
bzrlib/knit.py knit.py-20051212171256-f056ac8f0fbe1bd9
bzrlib/tests/test_knit.py test_knit.py-20051212171302-95d4c00dd5f11f2b
=== modified file 'bzrlib/knit.py'
--- a/bzrlib/knit.py 2007-07-13 18:54:47 +0000
+++ b/bzrlib/knit.py 2007-07-13 19:00:02 +0000
@@ -1392,10 +1392,21 @@
def get_position(self, version_id):
"""Return data position and size of specified version."""
- node = list(self._graph_index.iter_entries([version_id]))[0]
- bits = node[2][1:].split(' ')
+ bits = self._get_node(version_id)[2][1:].split(' ')
return int(bits[0]), int(bits[1])
+ def get_method(self, version_id):
+ """Return compression method of specified version."""
+ fulltext = self._get_node(version_id)[2][0] == 'F'
+ if fulltext:
+ return 'fulltext'
+ else:
+ return 'line-delta'
+
+ def _get_node(self, version_id):
+ return list(self._graph_index.iter_entries([version_id]))[0]
+
+
class _KnitData(_KnitComponentFile):
"""Contents of the knit data file"""
=== modified file 'bzrlib/tests/test_knit.py'
--- a/bzrlib/tests/test_knit.py 2007-07-13 18:54:47 +0000
+++ b/bzrlib/tests/test_knit.py 2007-07-13 19:00:02 +0000
@@ -1522,10 +1522,10 @@
def two_graph_index(self):
# build a complex graph across several indices.
index1 = self.make_g_index('1', 1, [
- ('tip', (['parent'], ), ' 0 100'),
+ ('tip', (['parent'], ), 'F0 100'),
('tail', ([], ), '')])
index2 = self.make_g_index('2', 1, [
- ('parent', (['tail', 'ghost'], ), ' 100 78'),
+ ('parent', (['tail', 'ghost'], ), 'L100 78'),
('separate', ([], ), '')])
combined_index = CombinedGraphIndex([index1, index2])
return KnitGraphIndex(combined_index)
@@ -1618,6 +1618,11 @@
self.assertEqual((0, 100), index.get_position('tip'))
self.assertEqual((100, 78), index.get_position('parent'))
+ def test_get_method(self):
+ index = self.two_graph_index()
+ self.assertEqual('fulltext', index.get_method('tip'))
+ self.assertEqual('line-delta', index.get_method('parent'))
+
## --- mutating tests for later ---
#
# def test_add_version
More information about the bazaar-commits
mailing list