Patchwork [5,of,6] revbranchcache: move cache writing to the transaction finalizer

login
register
mail settings
Submitter Durham Goode
Date March 17, 2015, 3:36 a.m.
Message ID <2b0ed15d3e874a69f0ee.1426563377@dev2000.prn2.facebook.com>
Download mbox | patch
Permalink /patch/8112/
State Accepted
Commit 656f93ce66d57776843748387680429ea6cb674a
Headers show

Comments

Durham Goode - March 17, 2015, 3:36 a.m.
# HG changeset patch
# User Durham Goode <durham@fb.com>
# Date 1423627572 28800
#      Tue Feb 10 20:06:12 2015 -0800
# Node ID 2b0ed15d3e874a69f0ee5cd5b0f04cd8f0ecab41
# Parent  af07ccb20f1f8b31fdc2a4e482d4872501a98190
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.

Patch

diff --git a/mercurial/branchmap.py b/mercurial/branchmap.py
--- a/mercurial/branchmap.py
+++ b/mercurial/branchmap.py
@@ -414,7 +414,11 @@  class revbranchcache(object):
         self._rbcrevs[rbcrevidx:rbcrevidx + _rbcrecsize] = rec
         self._rbcrevslen = min(self._rbcrevslen, rev)
 
-    def write(self):
+        tr = self._repo.currenttransaction()
+        if tr:
+            tr.addfinalize('write-revbranchcache', self.write)
+
+    def write(self, tr=None):
         """Save branch cache if it is dirty."""
         repo = self._repo
         if self._rbcnamescount < len(self._names):
diff --git a/mercurial/statichttprepo.py b/mercurial/statichttprepo.py
--- a/mercurial/statichttprepo.py
+++ b/mercurial/statichttprepo.py
@@ -144,6 +144,7 @@  class statichttprepository(localrepo.loc
         self._revbranchcache = None
         self.encodepats = None
         self.decodepats = None
+        self._transref = None
 
     def _restrictcapabilities(self, caps):
         caps = super(statichttprepository, self)._restrictcapabilities(caps)