Rev 2672: * Add a new method ``bzrlib.repository.Repository.reconcile_actions`` in http://people.ubuntu.com/~robertc/baz2.0/reconcile

Robert Collins robertc at robertcollins.net
Sun Aug 5 10:53:58 BST 2007


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

------------------------------------------------------------
revno: 2672
revision-id: robertc at robertcollins.net-20070805095335-dn7artt5nlwr8kwe
parent: pqm at pqm.ubuntu.com-20070803043116-l7u1uypblmx1uxnr
committer: Robert Collins <robertc at robertcollins.net>
branch nick: reconcile
timestamp: Sun 2007-08-05 19:53:35 +1000
message:
  * Add a new method ``bzrlib.repository.Repository.reconcile_actions``
    allowing conditional test cases on the sorts of things reconcile
    will actually perform. (Robert Collins)
modified:
  NEWS                           NEWS-20050323055033-4e00b5db738777ff
  bzrlib/repository.py           rev_storage.py-20051111201905-119e9401e46257e3
  bzrlib/tests/repository_implementations/test_reconcile.py test_reconcile.py-20060223022332-572ef70a3288e369
=== modified file 'NEWS'
--- a/NEWS	2007-08-02 07:22:05 +0000
+++ b/NEWS	2007-08-05 09:53:35 +0000
@@ -195,6 +195,10 @@
     * ``bzrlib.pack.make_readv_reader`` allows readv based access to pack
       files that are stored on a transport. (Robert Collins)
 
+    * Add a new method ``bzrlib.repository.Repository.reconcile_actions``
+      allowing conditional test cases on the sorts of things reconcile
+      will actually perform. (Robert Collins)
+
   TESTING:
 
     * Remove selftest ``--clean-output``, ``--numbered-dirs`` and

=== modified file 'bzrlib/repository.py'
--- a/bzrlib/repository.py	2007-07-31 02:07:34 +0000
+++ b/bzrlib/repository.py	2007-08-05 09:53:35 +0000
@@ -801,6 +801,13 @@
         reconciler.reconcile()
         return reconciler
 
+    def reconcile_actions(self):
+        """Return a set of actions taken by reconcile on this repository.
+        
+        :return: A set of actions. e.g. set(['inventory_gc']).
+        """
+        return set(['inventory_gc'])
+
     @needs_read_lock
     def revision_tree(self, revision_id):
         """Return Tree for a revision on this branch.

=== modified file 'bzrlib/tests/repository_implementations/test_reconcile.py'
--- a/bzrlib/tests/repository_implementations/test_reconcile.py	2007-07-19 06:34:09 +0000
+++ b/bzrlib/tests/repository_implementations/test_reconcile.py	2007-08-05 09:53:35 +0000
@@ -123,10 +123,15 @@
         # and no backup weave should have been needed/made.
         self.checkNoBackupInventory(d)
 
-    def test_reconile_empty(self):
+    def test_reconcile_empty(self):
         # in an empty repo, theres nothing to do.
         self.checkEmptyReconcile()
 
+    def test_reconcile_actions(self):
+        """reconcile_actions() returns a set naming what a repo reconciles."""
+        repo = self.make_repository('repo')
+        self.assertNotEqual(None, set(repo.reconcile_actions()))
+
     def test_reconcile_empty_thorough(self):
         # reconcile should accept thorough=True
         self.checkEmptyReconcile(thorough=True)
@@ -135,6 +140,10 @@
         # smoke test for the all in one ui tool
         bzrdir_url = self.get_url('inventory_without_revision')
         bzrdir = bzrlib.bzrdir.BzrDir.open(bzrdir_url)
+        repo = bzrdir.open_repository()
+        if 'inventory_gc' not in repo.reconcile_actions():
+            # irrelevant test.
+            return
         reconcile(bzrdir)
         # now the backup should have it but not the current inventory
         repo = bzrdir.open_repository()
@@ -145,11 +154,14 @@
         d_url = self.get_url('inventory_without_revision')
         d = bzrlib.bzrdir.BzrDir.open(d_url)
         repo = d.open_repository()
+        if 'inventory_gc' not in repo.reconcile_actions():
+            # irrelevant test.
+            return
         self.checkUnreconciled(d, repo.reconcile())
         reconciler = repo.reconcile(thorough=True)
         # no bad parents
         self.assertEqual(0, reconciler.inconsistent_parents)
-        # and one garbage inventoriy
+        # and one garbage inventory
         self.assertEqual(1, reconciler.garbage_inventories)
         self.check_missing_was_removed(repo)
 
@@ -157,10 +169,14 @@
             **kwargs):
         # actual low level test.
         repo = aBzrDir.open_repository()
-        if ([None, 'missing', 'references_missing'] 
+        if ([None, 'missing', 'references_missing']
             != repo.get_ancestry('references_missing')):
             # the repo handles ghosts without corruption, so reconcile has
-            # nothing to do here
+            # nothing to do here 
+            # specifically, this test has the inventory 'missing' present
+            # and the revision 'missing' missing, so clearly 'missing' 
+            # cannot be reported in the present ancestry -> missing
+            # is something that can be filled as a ghost.
             expected_inconsistent_parents = 0
         else:
             expected_inconsistent_parents = 1
@@ -190,6 +206,9 @@
         # other tests use the lower level repo.reconcile()
         d_url = self.get_url('inventory_without_revision_and_ghost')
         d = bzrlib.bzrdir.BzrDir.open(d_url)
+        if 'inventory_gc' not in d.open_repository().reconcile_actions():
+            # irrelevant test.
+            return
         def reconcile():
             reconciler = Reconciler(d)
             reconciler.reconcile()
@@ -201,6 +220,9 @@
         d_url = self.get_url('inventory_without_revision_and_ghost')
         d = bzrlib.bzrdir.BzrDir.open(d_url)
         repo = d.open_repository()
+        if 'inventory_gc' not in repo.reconcile_actions():
+            # irrelevant test.
+            return
         # nothing should have been altered yet : inventories without
         # revisions are not data loss incurring for current format
         self.check_thorough_reweave_missing_revision(d, repo.reconcile,
@@ -327,8 +349,8 @@
         g = repo.get_revision_graph()
         self.assertEqual(('1', '2'), g['wrong-first-parent'])
 
-    def test_reconcile_wrong_order_secondary(self):
-        # a wrong order in secondary parents is ignored.
+    def test_reconcile_wrong_order_secondary_inventory(self):
+        # a wrong order in the parents for inventories is ignored.
         t = get_transport(self.get_url()).clone('reversed-secondary-parents')
         d = bzrlib.bzrdir.BzrDir.open_from_transport(t)
         repo = d.open_repository()



More information about the bazaar-commits mailing list