##// END OF EJS Templates
branchcache: lazily validate nodes from the branchmap...
Pulkit Goyal -
r42290:65786549 default
parent child Browse files
Show More
@@ -210,16 +210,20 b' class branchcache(object):'
210 self._entries[key] = value
210 self._entries[key] = value
211
211
212 def __getitem__(self, key):
212 def __getitem__(self, key):
213 self._verifybranch(key)
213 return self._entries[key]
214 return self._entries[key]
214
215
215 def __contains__(self, key):
216 def __contains__(self, key):
217 self._verifybranch(key)
216 return key in self._entries
218 return key in self._entries
217
219
218 def iteritems(self):
220 def iteritems(self):
221 self._verifyall()
219 return self._entries.iteritems()
222 return self._entries.iteritems()
220
223
221 def hasbranch(self, label):
224 def hasbranch(self, label):
222 """ checks whether a branch of this name exists or not """
225 """ checks whether a branch of this name exists or not """
226 self._verifybranch(label)
223 return label in self._entries
227 return label in self._entries
224
228
225 @classmethod
229 @classmethod
@@ -262,7 +266,6 b' class branchcache(object):'
262 def load(self, repo, lineiter):
266 def load(self, repo, lineiter):
263 """ fully loads the branchcache by reading from the file using the line
267 """ fully loads the branchcache by reading from the file using the line
264 iterator passed"""
268 iterator passed"""
265 cl = repo.changelog
266 for line in lineiter:
269 for line in lineiter:
267 line = line.rstrip('\n')
270 line = line.rstrip('\n')
268 if not line:
271 if not line:
@@ -272,14 +275,9 b' class branchcache(object):'
272 raise ValueError(r'invalid branch state')
275 raise ValueError(r'invalid branch state')
273 label = encoding.tolocal(label.strip())
276 label = encoding.tolocal(label.strip())
274 node = bin(node)
277 node = bin(node)
275 if not cl.hasnode(node):
276 raise ValueError(
277 r'node %s does not exist' % pycompat.sysstr(hex(node)))
278 self._entries.setdefault(label, []).append(node)
278 self._entries.setdefault(label, []).append(node)
279 self._verifiedbranches.add(label)
280 if state == 'c':
279 if state == 'c':
281 self._closednodes.add(node)
280 self._closednodes.add(node)
282 self._closedverified = True
283
281
284 @staticmethod
282 @staticmethod
285 def _filename(repo):
283 def _filename(repo):
@@ -306,6 +304,7 b' class branchcache(object):'
306 otherwise return last closed head and true.'''
304 otherwise return last closed head and true.'''
307 tip = heads[-1]
305 tip = heads[-1]
308 closed = True
306 closed = True
307 self._verifyclosed()
309 for h in reversed(heads):
308 for h in reversed(heads):
310 if h not in self._closednodes:
309 if h not in self._closednodes:
311 tip = h
310 tip = h
@@ -320,9 +319,11 b' class branchcache(object):'
320 return self._branchtip(self[branch])[0]
319 return self._branchtip(self[branch])[0]
321
320
322 def iteropen(self, nodes):
321 def iteropen(self, nodes):
322 self._verifyclosed()
323 return (n for n in nodes if n not in self._closednodes)
323 return (n for n in nodes if n not in self._closednodes)
324
324
325 def branchheads(self, branch, closed=False):
325 def branchheads(self, branch, closed=False):
326 self._verifybranch(branch)
326 heads = self._entries[branch]
327 heads = self._entries[branch]
327 if not closed:
328 if not closed:
328 heads = list(self.iteropen(heads))
329 heads = list(self.iteropen(heads))
@@ -334,10 +335,12 b' class branchcache(object):'
334
335
335 def iterheads(self):
336 def iterheads(self):
336 """ returns all the heads """
337 """ returns all the heads """
338 self._verifyall()
337 return self._entries.itervalues()
339 return self._entries.itervalues()
338
340
339 def copy(self):
341 def copy(self):
340 """return an deep copy of the branchcache object"""
342 """return an deep copy of the branchcache object"""
343 self._verifyall()
341 return type(self)(
344 return type(self)(
342 self._entries, self.tipnode, self.tiprev, self.filteredhash,
345 self._entries, self.tipnode, self.tiprev, self.filteredhash,
343 self._closednodes)
346 self._closednodes)
General Comments 0
You need to be logged in to leave comments. Login now