Comments
Patch
@@ -396,6 +396,22 @@ class revbranchcache(object):
return self.branchinfo(rev)[0]
+ def branchfast(self, rev):
+ """Return branch name for rev, using and updating persistent cache.
+ The cache must be loaded first."""
+ node = self._repo.changelog.node(rev)
+ cachenode, branchidx = struct.unpack_from(bcrecfmt, self._records,
+ rev * bcrecsize)
+ branchidx &= bcbranchidxmask
+ if cachenode == node and branchidx < len(self._nameslocal):
+ b = self._nameslocal[branchidx]
+ if b:
+ return b
+ b = encoding.tolocal(self._namesutf8[branchidx])
+ self._nameslocal[branchidx] = b
+ return b
+ return self.branchinfo(rev)[0]
+
def save(self):
"""Save branch cache if it is dirty."""
if self._dirty:
@@ -478,7 +478,8 @@ def branch(repo, subset, x):
a regular expression. To match a branch that actually starts with `re:`,
use the prefix `literal:`.
"""
- branch = repo.revbranchcache.branch
+ branch = repo.revbranchcache.load()
+ branch = repo.revbranchcache.branchfast
try:
b = getstring(x, '')
except error.ParseError: