Rev 2635: Implement KnitGraphIndex.has_version. in http://people.ubuntu.com/~robertc/baz2.0/repository

Robert Collins robertc at robertcollins.net
Fri Jul 13 19:32:39 BST 2007


At http://people.ubuntu.com/~robertc/baz2.0/repository

------------------------------------------------------------
revno: 2635
revision-id: robertc at robertcollins.net-20070713183236-iyluu19jnoef43qc
parent: robertc at robertcollins.net-20070713182231-ysvixzjwrx0n2oe1
committer: Robert Collins <robertc at robertcollins.net>
branch nick: repository
timestamp: Sat 2007-07-14 04:32:36 +1000
message:
  Implement KnitGraphIndex.has_version.
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:22:31 +0000
+++ b/bzrlib/knit.py	2007-07-13 18:32:36 +0000
@@ -1386,6 +1386,9 @@
         """Get all the versions in the file. not topologically sorted."""
         return [node[0] for node in self._graph_index.iter_all_entries()]
     
+    def has_version(self, version_id):
+        """True if the version is in the index."""
+        return len(list(self._graph_index.iter_entries([version_id]))) == 1
 
 
 class _KnitData(_KnitComponentFile):

=== modified file 'bzrlib/tests/test_knit.py'
--- a/bzrlib/tests/test_knit.py	2007-07-13 18:22:31 +0000
+++ b/bzrlib/tests/test_knit.py	2007-07-13 18:32:36 +0000
@@ -1608,3 +1608,13 @@
         self.assertEqual(set(['tail', 'tip', 'parent', 'separate']),
             set(index.get_versions()))
 
+    def test_has_version(self):
+        index = self.two_graph_index()
+        self.assertTrue(index.has_version('tail'))
+        self.assertFalse(index.has_version('ghost'))
+
+## --- mutating tests for later ---
+#
+#  def test_add_version
+#  def test_add_versions
+#  




More information about the bazaar-commits mailing list