diff --git a/mercurial/branchmap.py b/mercurial/branchmap.py --- a/mercurial/branchmap.py +++ b/mercurial/branchmap.py @@ -278,7 +278,7 @@ newbranches = {} getbranchinfo = repo.revbranchcache().branchinfo for r in revgen: - branch, closesbranch = getbranchinfo(r) + branch, closesbranch = getbranchinfo(r, changelog=cl) newbranches.setdefault(branch, []).append(r) if closesbranch: self._closednodes.add(cl.node(r)) @@ -404,10 +404,10 @@ self._rbcrevslen = len(self._repo.changelog) self._rbcrevs = bytearray(self._rbcrevslen * _rbcrecsize) - def branchinfo(self, rev): + def branchinfo(self, rev, changelog=None): """Return branch name and close flag for rev, using and updating persistent cache.""" - changelog = self._repo.changelog + changelog = changelog or self._repo.changelog rbcrevidx = rev * _rbcrecsize # avoid negative index, changelog.read(nullrev) is fast without cache @@ -416,7 +416,7 @@ # if requested rev isn't allocated, grow and cache the rev info if len(self._rbcrevs) < rbcrevidx + _rbcrecsize: - return self._branchinfo(rev) + return self._branchinfo(rev, changelog=changelog) # fast path: extract data from cache, use it if node is matching reponode = changelog.node(rev)[:_rbcnodelen] @@ -444,11 +444,11 @@ self._rbcrevslen = min(self._rbcrevslen, truncate) # fall back to slow path and make sure it will be written to disk - return self._branchinfo(rev) + return self._branchinfo(rev, changelog=changelog) - def _branchinfo(self, rev): + def _branchinfo(self, rev, changelog=None): """Retrieve branch info from changelog and update _rbcrevs""" - changelog = self._repo.changelog + changelog = changelog or self._repo.changelog b, close = changelog.branchinfo(rev) if b in self._namesreverse: branchidx = self._namesreverse[b] @@ -459,7 +459,7 @@ reponode = changelog.node(rev) if close: branchidx |= _rbccloseflag - self._setcachedata(rev, reponode, branchidx) + self._setcachedata(rev, reponode, branchidx, changelog) return b, close def setdata(self, branch, rev, node, close): @@ -482,14 +482,16 @@ if r'branchinfo' in vars(self): del self.branchinfo - def _setcachedata(self, rev, node, branchidx): + def _setcachedata(self, rev, node, branchidx, changelog=None): """Writes the node's branch data to the in-memory cache data.""" if rev == nullrev: return + + changelog = changelog or self._repo.changelog rbcrevidx = rev * _rbcrecsize if len(self._rbcrevs) < rbcrevidx + _rbcrecsize: self._rbcrevs.extend('\0' * - (len(self._repo.changelog) * _rbcrecsize - + (len(changelog) * _rbcrecsize - len(self._rbcrevs))) pack_into(_rbcrecfmt, self._rbcrevs, rbcrevidx, node, branchidx) self._rbcrevslen = min(self._rbcrevslen, rev)