[PATCH 04 of 10 V2] bundlerepo: use _cacheabletip mechanism in bundlerepo

pierre-yves.david at logilab.fr pierre-yves.david at logilab.fr
Thu Dec 20 08:08:34 CST 2012


# HG changeset patch
# User Pierre-Yves David <pierre-yves.david at logilab.fr>
# Date 1356002264 -3600
# Node ID 49e81a2c56e10861cc907520e734e63f02cbf18a
# Parent  7fb0f8672f361e05e78cce6c95c02928f752ddb6
bundlerepo: use _cacheabletip mechanism in bundlerepo

Instead of preventing any cache write we allow writing cache for all content of
the original repo.

The motivation for this change is to drop the custom _writebranchcache of
bundlerepo to help extraction of the branchmap logic out of localrepo.

diff --git a/mercurial/bundlerepo.py b/mercurial/bundlerepo.py
--- a/mercurial/bundlerepo.py
+++ b/mercurial/bundlerepo.py
@@ -30,10 +30,11 @@ class bundlerevlog(revlog.revlog):
         #
         revlog.revlog.__init__(self, opener, indexfile)
         self.bundle = bundle
         self.basemap = {}
         n = len(self)
+        self.disktiprev = n - 1
         chain = None
         self.bundlenodes = []
         while True:
             chunkdata = bundle.deltachunk(chain)
             if not chunkdata:
@@ -282,13 +283,15 @@ class bundlerepository(localrepo.localre
         return bundlepeer(self)
 
     def getcwd(self):
         return os.getcwd() # always outside the repo
 
-    def _writebranchcache(self, branches, tip, tiprev):
-        # don't overwrite the disk cache with bundle-augmented data
-        pass
+    def _cacheabletip(self):
+        # we should not cache data from the bundle on disk
+        ret = super(bundlerepository, self)._cacheabletip()
+        return min(self.changelog.disktiprev, ret)
+
 
 def instance(ui, path, create):
     if create:
         raise util.Abort(_('cannot create new bundle repository'))
     parentpath = ui.config("bundle", "mainreporoot", "")


More information about the Mercurial-devel mailing list