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

Robert Collins robertc at robertcollins.net
Fri Jul 13 19:16:41 BST 2007


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

------------------------------------------------------------
revno: 2632
revision-id: robertc at robertcollins.net-20070713181638-ffyopwssoa2vwcyx
parent: robertc at robertcollins.net-20070713180843-4e3hfamt1l8udca2
committer: Robert Collins <robertc at robertcollins.net>
branch nick: repository
timestamp: Sat 2007-07-14 04:16:38 +1000
message:
  Implement KnitGraphIndex.get_versions.
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:08:43 +0000
+++ b/bzrlib/knit.py	2007-07-13 18:16:38 +0000
@@ -1216,6 +1216,7 @@
     __len__ = num_versions
 
     def get_versions(self):
+        """Get all the versions in the file. not topologically sorted."""
         return self._history
 
     def idx_to_name(self, idx):
@@ -1386,6 +1387,14 @@
     def num_versions(self):
         return len(list(self._graph_index.iter_all_entries()))
 
+    __len__ = num_versions
+
+    def get_versions(self):
+        """Get all the versions in the file. not topologically sorted."""
+        return [node[0] for node in self._graph_index.iter_all_entries()]
+    
+
+
 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:08:43 +0000
+++ b/bzrlib/tests/test_knit.py	2007-07-13 18:16:38 +0000
@@ -1624,3 +1624,9 @@
     def test_num_versions(self):
         index = self.two_graph_index()
         self.assertEqual(4, index.num_versions())
+
+    def test_get_versions(self):
+        index = self.two_graph_index()
+        self.assertEqual(set(['tail', 'tip', 'parent', 'separate']),
+            set(index.get_versions()))
+




More information about the bazaar-commits mailing list