comparison mercurial/branchmap.py @ 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
comparison
equal deleted inserted replaced
42005:b137a6793c51 42006:111de135fc76
160 if closednodes is None: 160 if closednodes is None:
161 self._closednodes = set() 161 self._closednodes = set()
162 else: 162 else:
163 self._closednodes = closednodes 163 self._closednodes = closednodes
164 self._entries = dict(entries) 164 self._entries = dict(entries)
165 # whether closed nodes are verified or not
166 self._closedverified = False
167 # branches for which nodes are verified
168 self._verifiedbranches = set()
165 169
166 def __iter__(self): 170 def __iter__(self):
167 return iter(self._entries) 171 return iter(self._entries)
168 172
169 def __setitem__(self, key, value): 173 def __setitem__(self, key, value):
229 node = bin(node) 233 node = bin(node)
230 if not cl.hasnode(node): 234 if not cl.hasnode(node):
231 raise ValueError( 235 raise ValueError(
232 r'node %s does not exist' % pycompat.sysstr(hex(node))) 236 r'node %s does not exist' % pycompat.sysstr(hex(node)))
233 self._entries.setdefault(label, []).append(node) 237 self._entries.setdefault(label, []).append(node)
238 self._verifiedbranches.add(label)
234 if state == 'c': 239 if state == 'c':
235 self._closednodes.add(node) 240 self._closednodes.add(node)
241 self._closedverified = True
236 242
237 @staticmethod 243 @staticmethod
238 def _filename(repo): 244 def _filename(repo):
239 """name of a branchcache file for a given repo or repoview""" 245 """name of a branchcache file for a given repo or repoview"""
240 filename = "branch2" 246 filename = "branch2"