Rev 2706: Make reconcile work, and pass tests. in http://people.ubuntu.com/~robertc/baz2.0/repository

Robert Collins robertc at robertcollins.net
Sun Aug 5 10:59:15 BST 2007


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

------------------------------------------------------------
revno: 2706
revision-id: robertc at robertcollins.net-20070805095913-oir8h97dm86v5ol7
parent: robertc at robertcollins.net-20070805095835-w7zz6gijehcfs3v8
committer: Robert Collins <robertc at robertcollins.net>
branch nick: repository
timestamp: Sun 2007-08-05 19:59:13 +1000
message:
  Make reconcile work, and pass tests.
modified:
  bzrlib/reconcile.py            reweave_inventory.py-20051108164726-1e5e0934febac06e
  bzrlib/repofmt/knitrepo.py     knitrepo.py-20070206081537-pyy4a00xdas0j4pf-1
=== modified file 'bzrlib/reconcile.py'
--- a/bzrlib/reconcile.py	2006-10-05 05:37:25 +0000
+++ b/bzrlib/reconcile.py	2007-08-05 09:59:13 +0000
@@ -17,7 +17,13 @@
 """Reconcilers are able to fix some potential data errors in a branch."""
 
 
-__all__ = ['reconcile', 'Reconciler', 'RepoReconciler', 'KnitReconciler']
+__all__ = [
+    'KnitReconciler',
+    'PackReconciler',
+    'reconcile',
+    'Reconciler',
+    'RepoReconciler',
+    ]
 
 
 from bzrlib import ui
@@ -77,6 +83,11 @@
 class RepoReconciler(object):
     """Reconciler that reconciles a repository.
 
+    The goal of repository reconciliation is to make any derived daata
+    consistent with the core data committed by a user. This can involve 
+    reindexing, or removing unreferenced data if that can interfere with
+    queries in a given repository.
+
     Currently this consists of an inventory reweave with revision cross-checks.
     """
 
@@ -267,9 +278,7 @@
 class KnitReconciler(RepoReconciler):
     """Reconciler that reconciles a knit format repository.
 
-    This will detect garbage inventories and remove them.
-
-    Inconsistent parentage is checked for in the revision weave.
+    This will detect garbage inventories and remove them in thorough mode.
     """
 
     def _reconcile_steps(self):
@@ -337,3 +346,20 @@
         self.garbage_inventories = len(garbage)
         for revision_id in garbage:
             mutter('Garbage inventory {%s} found.', revision_id)
+
+
+class PackReconciler(RepoReconciler):
+    """Reconciler that reconciles a pack based repository.
+
+    Garbage inventories do not affect ancestry queries, and removal is
+    considerably more expensive as there is no separate versioned file for
+    them, so they are not cleaned. In short it is currently a no-op.
+
+    In future this may be a good place to hook in annotation cache checking,
+    index recreation etc.
+    """
+
+    def _reconcile_steps(self):
+        """Perform the steps to reconcile this repository."""
+        if self.thorough:
+            pass

=== modified file 'bzrlib/repofmt/knitrepo.py'
--- a/bzrlib/repofmt/knitrepo.py	2007-08-05 08:29:34 +0000
+++ b/bzrlib/repofmt/knitrepo.py	2007-08-05 09:59:13 +0000
@@ -810,6 +810,23 @@
     def get_inventory_weave(self):
         return self._inv_thunk.get_weave()
 
+    @needs_write_lock
+    def reconcile(self, other=None, thorough=False):
+        """Reconcile this repository."""
+        from bzrlib.reconcile import PackReconciler
+        reconciler = PackReconciler(self, thorough=thorough)
+        reconciler.reconcile()
+        return reconciler
+
+    def reconcile_actions(self):
+        """Return a set of actions taken by reconcile on this repository.
+ 
+        Pack repositories currently perform no reconciliation.
+
+        :return: A set of actions. e.g. set(['inventory_gc']).
+        """
+        return set([])
+
 
 class GraphKnitRepository3(KnitRepository3):
     """Experimental graph-knit using subtrees repository."""
@@ -883,6 +900,21 @@
     def get_inventory_weave(self):
         return self._inv_thunk.get_weave()
 
+    @needs_write_lock
+    def reconcile(self, other=None, thorough=False):
+        """Reconcile this repository."""
+        from bzrlib.reconcile import PackReconciler
+        reconciler = PackReconciler(self, thorough=thorough)
+        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([])
+
 
 class RepositoryFormatKnit(MetaDirRepositoryFormat):
     """Bzr repository knit format (generalized). 



More information about the bazaar-commits mailing list