comparison mercurial/branchmap.py @ 24377:656f93ce66d5

revbranchcache: move cache writing to the transaction finalizer Instead of writing the revbranchcache during updatecache (which often happens too early, before the cache is even populated), let's run it as part of the transaction finalizer. It still won't be written for read-only operations, but that's no worse than it is today. A future commit will remove the actual write that happens in updatecache(). This is also good prep for when all caches get moved into the transaction.
author Durham Goode <durham@fb.com>
date Tue, 10 Feb 2015 20:06:12 -0800
parents 203a078da052
children 9347c15d8136
comparison
equal deleted inserted replaced
24376:203a078da052 24377:656f93ce66d5
412 rec = array('c') 412 rec = array('c')
413 rec.fromstring(pack(_rbcrecfmt, node, branchidx)) 413 rec.fromstring(pack(_rbcrecfmt, node, branchidx))
414 self._rbcrevs[rbcrevidx:rbcrevidx + _rbcrecsize] = rec 414 self._rbcrevs[rbcrevidx:rbcrevidx + _rbcrecsize] = rec
415 self._rbcrevslen = min(self._rbcrevslen, rev) 415 self._rbcrevslen = min(self._rbcrevslen, rev)
416 416
417 def write(self): 417 tr = self._repo.currenttransaction()
418 if tr:
419 tr.addfinalize('write-revbranchcache', self.write)
420
421 def write(self, tr=None):
418 """Save branch cache if it is dirty.""" 422 """Save branch cache if it is dirty."""
419 repo = self._repo 423 repo = self._repo
420 if self._rbcnamescount < len(self._names): 424 if self._rbcnamescount < len(self._names):
421 try: 425 try:
422 if self._rbcnamescount != 0: 426 if self._rbcnamescount != 0: