diff --git a/mercurial/branchmap.py b/mercurial/branchmap.py --- a/mercurial/branchmap.py +++ b/mercurial/branchmap.py @@ -397,13 +397,13 @@ self._names = [] self._rbcnamescount = len(self._names) # number of names read at # _rbcsnameslen - self._namesreverse = dict((b, r) for r, b in enumerate(self._names)) + self._namesreverse = None def _clear(self): self._rbcsnameslen = 0 del self._names[:] self._rbcnamescount = 0 - self._namesreverse.clear() + self._namesreverse = None self._rbcrevslen = len(self._repo.changelog) self._rbcrevs = bytearray(self._rbcrevslen * _rbcrecsize) @@ -453,6 +453,8 @@ """Retrieve branch info from changelog and update _rbcrevs""" changelog = self._repo.changelog b, close = changelog.branchinfo(rev) + if self._namesreverse is None: + self._namesreverse = dict((b, r) for r, b in enumerate(self._names)) if b in self._namesreverse: branchidx = self._namesreverse[b] else: @@ -467,6 +469,8 @@ def setdata(self, branch, rev, node, close): """add new data information to the cache""" + if self._namesreverse is None: + self._namesreverse = dict((b, r) for r, b in enumerate(self._names)) if branch in self._namesreverse: branchidx = self._namesreverse[branch] else: