branchmap: read and write key part related to filtered revision
authorPierre-Yves David <pierre-yves.david@logilab.fr>
Tue, 01 Jan 2013 18:19:24 +0100
changeset 18184 8d48af68e2ae
parent 18183 e1caaeb5a2ed
child 18185 5a047276764e
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.
mercurial/branchmap.py
--- 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)))