diff --git a/mercurial/branchmap.py b/mercurial/branchmap.py --- a/mercurial/branchmap.py +++ b/mercurial/branchmap.py @@ -96,6 +96,10 @@ def updatecache(repo): if revs: partial.update(repo, revs) partial.write(repo) + + if repo._revbranchcache is not None: + repo._revbranchcache.write(repo) + assert partial.validfor(repo), filtername repo._branchcaches[repo.filtername] = partial @@ -134,7 +138,6 @@ class branchcache(dict): self._closednodes = set() else: self._closednodes = closednodes - self._revbranchcache = None def _hashfiltered(self, repo): """build hash of revision filtered in the current cache @@ -226,9 +229,6 @@ class branchcache(dict): repo.ui.debug("couldn't write branch cache: %s\n" % inst) # Abort may be raise by read only opener pass - if self._revbranchcache: - self._revbranchcache.write(repo.unfiltered()) - self._revbranchcache = None def update(self, repo, revgen): """Given a branchhead cache, self, that may have extra nodes or be @@ -240,9 +240,8 @@ class branchcache(dict): # collect new branch entries newbranches = {} urepo = repo.unfiltered() - self._revbranchcache = revbranchcache(urepo) - getbranchinfo = self._revbranchcache.branchinfo ucl = urepo.changelog + getbranchinfo = repo.revbranchcache().branchinfo for r in revgen: branch, closesbranch = getbranchinfo(ucl, r) newbranches.setdefault(branch, []).append(r) diff --git a/mercurial/localrepo.py b/mercurial/localrepo.py --- a/mercurial/localrepo.py +++ b/mercurial/localrepo.py @@ -279,6 +279,7 @@ class localrepository(object): self._branchcaches = {} + self._revbranchcache = None self.filterpats = {} self._datafilters = {} self._transref = self._lockref = self._wlockref = None @@ -726,6 +727,12 @@ class localrepository(object): branchmap.updatecache(self) return self._branchcaches[self.filtername] + @unfilteredmethod + def revbranchcache(self): + if not self._revbranchcache: + self._revbranchcache = branchmap.revbranchcache(self.unfiltered()) + return self._revbranchcache + def branchtip(self, branch, ignoremissing=False): '''return the tip node for a given branch diff --git a/mercurial/statichttprepo.py b/mercurial/statichttprepo.py --- a/mercurial/statichttprepo.py +++ b/mercurial/statichttprepo.py @@ -141,6 +141,7 @@ class statichttprepository(localrepo.loc self._tags = None self.nodetagscache = None self._branchcaches = {} + self._revbranchcache = None self.encodepats = None self.decodepats = None