Rev 2662: Change the revision index name to NAME.rix. in http://people.ubuntu.com/~robertc/baz2.0/repository

Robert Collins robertc at robertcollins.net
Mon Jul 16 08:29:34 BST 2007


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

------------------------------------------------------------
revno: 2662
revision-id: robertc at robertcollins.net-20070716072932-jg6juekv52scgwu3
parent: robertc at robertcollins.net-20070716070718-oil05krb6maikoik
committer: Robert Collins <robertc at robertcollins.net>
branch nick: repository
timestamp: Mon 2007-07-16 17:29:32 +1000
message:
  Change the revision index name to NAME.rix.
modified:
  bzrlib/repofmt/knitrepo.py     knitrepo.py-20070206081537-pyy4a00xdas0j4pf-1
  bzrlib/tests/test_repository.py test_repository.py-20060131075918-65c555b881612f4d
=== modified file 'bzrlib/repofmt/knitrepo.py'
--- a/bzrlib/repofmt/knitrepo.py	2007-07-16 07:07:18 +0000
+++ b/bzrlib/repofmt/knitrepo.py	2007-07-16 07:29:32 +0000
@@ -344,7 +344,8 @@
         for name in sorted(self.repo._revision_indices.names(), cmp=_cmp, reverse=True):
             # TODO: maybe this should expose size to us  to allow
             # sorting of the indices for better performance ?
-            indices.append(GraphIndex(index_transport, name))
+            index_name = self.name_to_index_name(name)
+            indices.append(GraphIndex(index_transport, index_name))
         if self.repo.control_files._lock_mode == 'w':
             # allow writing: queue writes to a new index
             indices.append(InMemoryGraphIndex(1))
@@ -367,7 +368,8 @@
         # have we done anything?
         if getattr(self.repo, '_revision_knit', None):
             index_transport = self.get_indices_transport()
-            new_index_name = self.repo._revision_indices.allocate()
+            new_name = self.repo._revision_indices.allocate()
+            new_index_name = self.name_to_index_name(new_name)
             index_transport.put_file(new_index_name,
                 self.repo._revision_write_index.finish())
             self.repo._revision_indices.save()
@@ -378,6 +380,10 @@
             # - clearly we need a remove_index call too.
             del self.repo._revision_all_indices._indices[-1]
 
+    def name_to_index_name(self, name):
+        """The revision index is the name + .rix."""
+        return name + '.rix'
+
     def reset(self):
         """Clear all cached data."""
         self.repo._revision_knit = None

=== modified file 'bzrlib/tests/test_repository.py'
--- a/bzrlib/tests/test_repository.py	2007-07-16 07:07:18 +0000
+++ b/bzrlib/tests/test_repository.py	2007-07-16 07:29:32 +0000
@@ -503,7 +503,7 @@
 
     def test_disk_layout(self):
         format = self.get_format()
-        repo =self.make_repository('.', format=format)
+        repo = self.make_repository('.', format=format)
         # in case of side effects of locking.
         repo.lock_write()
         repo.unlock()
@@ -553,7 +553,7 @@
 
     def test_shared_disk_layout(self):
         format = self.get_format()
-        repo =self.make_repository('.', shared=True, format=format)
+        repo = self.make_repository('.', shared=True, format=format)
         # we want:
         # format 'Bazaar-NG Knit Repository Format 1'
         # lock: is a directory
@@ -571,7 +571,7 @@
 
     def test_shared_no_tree_disk_layout(self):
         format = self.get_format()
-        repo =self.make_repository('.', shared=True, format=format)
+        repo = self.make_repository('.', shared=True, format=format)
         repo.set_make_working_trees(False)
         # we want:
         # format 'Bazaar-NG Knit Repository Format 1'
@@ -591,6 +591,15 @@
         self.assertTrue(S_ISDIR(t.stat('knits').st_mode))
         self.check_databases(t)
 
+    def test_add_revision_creates_zero_dot_rix(self):
+        """Adding a revision makes a 0.rix (Revision IndeX) file."""
+        format = self.get_format()
+        tree = self.make_branch_and_tree('.', format=format)
+        trans = tree.branch.repository.bzrdir.get_repository_transport(None)
+        self.assertFalse(trans.has('indices/0.rix'))
+        tree.commit('foobarbaz')
+        self.assertTrue(trans.has('indices/0.rix'))
+
 
 class TestExperimentalSubtrees(TestExperimentalNoSubtrees):
 



More information about the bazaar-commits mailing list