##// END OF EJS Templates
branchmap: add a cache validation cache, avoid expensive re-hash on every use...
Kyle Lippincott -
r46088:89f0d9f8 default
parent child Browse files
Show More
@@ -403,9 +403,21 b' class changelog(revlog.revlog):'
403 self._delayed = False
403 self._delayed = False
404 self._delaybuf = None
404 self._delaybuf = None
405 self._divert = False
405 self._divert = False
406 self.filteredrevs = frozenset()
406 self._filteredrevs = frozenset()
407 self._filteredrevs_hashcache = {}
407 self._copiesstorage = opener.options.get(b'copies-storage')
408 self._copiesstorage = opener.options.get(b'copies-storage')
408
409
410 @property
411 def filteredrevs(self):
412 return self._filteredrevs
413
414 @filteredrevs.setter
415 def filteredrevs(self, val):
416 # Ensure all updates go through this function
417 assert isinstance(val, frozenset)
418 self._filteredrevs = val
419 self._filteredrevs_hashcache = {}
420
409 def delayupdate(self, tr):
421 def delayupdate(self, tr):
410 """delay visibility of index updates to other readers"""
422 """delay visibility of index updates to other readers"""
411
423
@@ -364,13 +364,15 b' def filteredhash(repo, maxrev):'
364 cl = repo.changelog
364 cl = repo.changelog
365 if not cl.filteredrevs:
365 if not cl.filteredrevs:
366 return None
366 return None
367 key = None
367 key = cl._filteredrevs_hashcache.get(maxrev)
368 revs = sorted(r for r in cl.filteredrevs if r <= maxrev)
368 if not key:
369 if revs:
369 revs = sorted(r for r in cl.filteredrevs if r <= maxrev)
370 s = hashutil.sha1()
370 if revs:
371 for rev in revs:
371 s = hashutil.sha1()
372 s.update(b'%d;' % rev)
372 for rev in revs:
373 key = s.digest()
373 s.update(b'%d;' % rev)
374 key = s.digest()
375 cl._filteredrevs_hashcache[maxrev] = key
374 return key
376 return key
375
377
376
378
General Comments 0
You need to be logged in to leave comments. Login now