[PATCH 1 of 6 V3] branchmap: read and write key part related to filtered revision
Pierre-Yves David
pierre-yves.david at ens-lyon.org
Tue Jan 1 16:14:39 CST 2013
# HG changeset patch
# User Pierre-Yves David <pierre-yves.david at logilab.fr>
# Date 1357060764 -3600
# Node ID d5a9f27529d3f7c6fdf3e927847b82f29c888573
# Parent 9916d104c485e744dad50d63398d540f429e0caa
branchmap: read and write key part related to filtered revision
Now that we have a third part for the cache key we need to write and read it on
disk. It is only written when there is filtered revision. This keep the format
compatible with older version.
Notes that, at this state, filtered repository does not use any disk caches yet.
diff --git a/mercurial/branchmap.py b/mercurial/branchmap.py
--- a/mercurial/branchmap.py
+++ b/mercurial/branchmap.py
@@ -16,13 +16,18 @@ def read(repo):
f.close()
except (IOError, OSError):
return branchcache()
try:
- last, lrev = lines.pop(0).split(" ", 1)
+ cachekey = lines.pop(0).split(" ", 2)
+ last, lrev = cachekey[:2]
last, lrev = bin(last), int(lrev)
- partial = branchcache(tipnode=last, tiprev=lrev)
+ filteredhash = None
+ if len(cachekey) > 2:
+ filteredhash = bin(cachekey[2])
+ partial = branchcache(tipnode=last, tiprev=lrev,
+ filteredhash=filteredhash)
if not partial.validfor(repo):
# invalidate the cache
raise ValueError('tip differs')
for l in lines:
if not l:
@@ -111,11 +116,14 @@ class branchcache(dict):
def write(self, repo):
try:
f = repo.opener("cache/branchheads", "w", atomictemp=True)
- f.write("%s %s\n" % (hex(self.tipnode), self.tiprev))
+ cachekey = [hex(self.tipnode), str(self.tiprev)]
+ if self.filteredhash is not None:
+ cachekey.append(hex(self.filteredhash))
+ f.write(" ".join(cachekey) + '\n')
for label, nodes in self.iteritems():
for node in nodes:
f.write("%s %s\n" % (hex(node), encoding.fromlocal(label)))
f.close()
except (IOError, OSError):
More information about the Mercurial-devel
mailing list