Patchwork D6157: branchcache: have a hasnode function to validate nodes

login
register
mail settings
Submitter phabricator
Date March 23, 2019, 3:42 p.m.
Message ID <69c5bb3bfab7d1d8d9579d9711569a77@localhost.localdomain>
Download mbox | patch
Permalink /patch/39373/
State Not Applicable
Headers show

Comments

phabricator - March 23, 2019, 3:42 p.m.
This revision was automatically updated to reflect the committed changes.
Closed by commit rHGb5511845f9d5: branchcache: have a hasnode function to validate nodes (authored by pulkit, committed by ).

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D6157?vs=14561&id=14589

REVISION DETAIL
  https://phab.mercurial-scm.org/D6157

AFFECTED FILES
  mercurial/branchmap.py

CHANGE DETAILS




To: pulkit, #hg-reviewers
Cc: mercurial-devel

Patch

diff --git a/mercurial/branchmap.py b/mercurial/branchmap.py
--- a/mercurial/branchmap.py
+++ b/mercurial/branchmap.py
@@ -150,7 +150,10 @@ 
     """
 
     def __init__(self, entries=(), tipnode=nullid, tiprev=nullrev,
-                 filteredhash=None, closednodes=None):
+                 filteredhash=None, closednodes=None, hasnode=None):
+        """ hasnode is a function which can be used to verify whether changelog
+        has a given node or not. If it's not provided, we assume that every node
+        we have exists in changelog """
         self.tipnode = tipnode
         self.tiprev = tiprev
         self.filteredhash = filteredhash
@@ -166,6 +169,9 @@ 
         self._closedverified = False
         # branches for which nodes are verified
         self._verifiedbranches = set()
+        self._hasnode = hasnode
+        if self._hasnode is None:
+            self._hasnode = lambda x: True
 
     def __iter__(self):
         return iter(self._entries)
@@ -193,9 +199,11 @@ 
             last, lrev = cachekey[:2]
             last, lrev = bin(last), int(lrev)
             filteredhash = None
+            hasnode = repo.changelog.hasnode
             if len(cachekey) > 2:
                 filteredhash = bin(cachekey[2])
-            bcache = cls(tipnode=last, tiprev=lrev, filteredhash=filteredhash)
+            bcache = cls(tipnode=last, tiprev=lrev, filteredhash=filteredhash,
+                         hasnode=hasnode)
             if not bcache.validfor(repo):
                 # invalidate the cache
                 raise ValueError(r'tip differs')