# HG changeset patch # User Durham Goode # Date 2015-02-11 04:06:12 # Node ID 656f93ce66d57776843748387680429ea6cb674a # Parent 203a078da052b0476656b8b01ae7f8b809b16b0f 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. 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)