changeset 42006:111de135fc76

branchcache: add attributes to track which nodes are verified Half of the cost of loading branchcache comes from verifiying all the nodes it has. We don't need to verify all the nodes in all the cases. Sometimes we need to verify only a set of nodes for a set of branches. We can ignore nodes of other branches as we are not going to read them. This patch introduces two attributes to branchcache class. _verifiedbranches is a set which will tell the branches for which it's head nodes are verified. _closedverified is a boolean which will tell whether all closednodes are verified or not. Another idea which I had was to keep a set of nodes which are verified, but it will be more ugly and difficult to track things on node level. Differential Revision: https://phab.mercurial-scm.org/D6156
author Pulkit Goyal <pulkit@yandex-team.ru>
date Tue, 19 Mar 2019 16:20:02 +0300
parents b137a6793c51
children b5511845f9d5
files mercurial/branchmap.py
diffstat 1 files changed, 6 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/branchmap.py	Mon Mar 18 19:44:55 2019 +0300
+++ b/mercurial/branchmap.py	Tue Mar 19 16:20:02 2019 +0300
@@ -162,6 +162,10 @@
         else:
             self._closednodes = closednodes
         self._entries = dict(entries)
+        # whether closed nodes are verified or not
+        self._closedverified = False
+        # branches for which nodes are verified
+        self._verifiedbranches = set()
 
     def __iter__(self):
         return iter(self._entries)
@@ -231,8 +235,10 @@
                 raise ValueError(
                     r'node %s does not exist' % pycompat.sysstr(hex(node)))
             self._entries.setdefault(label, []).append(node)
+            self._verifiedbranches.add(label)
             if state == 'c':
                 self._closednodes.add(node)
+        self._closedverified = True
 
     @staticmethod
     def _filename(repo):