diff mercurial/branchmap.py @ 25266:38117278f295 stable

revbranchcache: return uncached branchinfo for nullrev (issue4683) This fixes the crash caused by "branch(null)" revset. No cache should be necessary for nullrev because changelog.branchinfo(nullrev) does not involve IO operation. Note that the problem of "branch(wdir())" isn't addressed by this patch. "wdir()" will raise TypeError in many places because of None. This is the reason why "wdir()" is still experimental.
author Yuya Nishihara <yuya@tcha.org>
date Sat, 23 May 2015 11:14:00 +0900
parents 75688a6f0bca
children 328739ea70c3
line wrap: on
line diff
--- a/mercurial/branchmap.py	Sun May 24 10:29:33 2015 +0900
+++ b/mercurial/branchmap.py	Sat May 23 11:14:00 2015 +0900
@@ -341,6 +341,10 @@
         changelog = self._repo.changelog
         rbcrevidx = rev * _rbcrecsize
 
+        # avoid negative index, changelog.read(nullrev) is fast without cache
+        if rev == nullrev:
+            return changelog.branchinfo(rev)
+
         # if requested rev is missing, add and populate all missing revs
         if len(self._rbcrevs) < rbcrevidx + _rbcrecsize:
             self._rbcrevs.extend('\0' * (len(changelog) * _rbcrecsize -