changeset 18184:8d48af68e2ae

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.
author Pierre-Yves David <pierre-yves.david@logilab.fr>
date Tue, 01 Jan 2013 18:19:24 +0100
parents e1caaeb5a2ed
children 5a047276764e
files mercurial/branchmap.py
diffstat 1 files changed, 11 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/branchmap.py	Tue Jan 01 13:05:22 2013 -0600
+++ b/mercurial/branchmap.py	Tue Jan 01 18:19:24 2013 +0100
@@ -18,9 +18,14 @@
         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')
@@ -113,7 +118,10 @@
     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)))