[PATCH 01 of 18 V2] branchmap: read return None in case of failure

Pierre-Yves David pierre-yves.david at ens-lyon.org
Fri Jan 4 01:04:04 UTC 2013


# HG changeset patch
# User Pierre-Yves David <pierre-yves.david at ens-lyon.org>
# Date 1356201671 -3600
# Node ID 584a4a3d20906768dbb3fc57f77cbfc0a41bc75e
# Parent  2c1276825e938872ebc099c191eb202f0dbadfcc
branchmap: read return None in case of failure

This makes a clear distinction between having read a valid cache on disk or not.
This will help caches of various filtering level to collaborate.

diff --git a/mercurial/branchmap.py b/mercurial/branchmap.py
--- a/mercurial/branchmap.py
+++ b/mercurial/branchmap.py
@@ -20,11 +20,11 @@ def read(repo):
     try:
         f = repo.opener(_filename(repo))
         lines = f.read().split('\n')
         f.close()
     except (IOError, OSError):
-        return branchcache()
+        return None
 
     try:
         cachekey = lines.pop(0).split(" ", 2)
         last, lrev = cachekey[:2]
         last, lrev = bin(last), int(lrev)
@@ -51,11 +51,11 @@ def read(repo):
             msg = 'invalid branchheads cache'
             if repo.filtername is not None:
                 msg += ' (%s)' % repo.filtername
             msg += ': %s\n'
             repo.ui.warn(msg % inst)
-        partial = branchcache()
+        partial = None
     return partial
 
 
 
 def updatecache(repo):
@@ -63,10 +63,12 @@ def updatecache(repo):
     filtername = repo.filtername
     partial = repo._branchcaches.get(filtername)
 
     if partial is None or not partial.validfor(repo):
         partial = read(repo)
+        if partial is None:
+            partial = branchcache()
 
     catip = repo._cacheabletip()
     # if partial.tiprev == catip: cache is already up to date
     # if partial.tiprev >  catip: we have uncachable element in `partial` can't
     #                             write on disk



More information about the Mercurial-devel mailing list