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

login
register
mail settings
Submitter Pierre-Yves David
Date Dec. 20, 2012, 2:08 p.m.
Message ID <49e81a2c56e10861cc90.1356012514@crater2.logilab.fr>
Download mbox | patch
Permalink /patch/205/
State Accepted
Commit 6db318a15a128a831e96f1c0c424e6cf8df47721
Headers show

Comments

Pierre-Yves David - Dec. 20, 2012, 2:08 p.m.
# 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.

Patch

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", "")