[PATCH STABLE] revbranchcache: special case nullrev

Durham Goode durham at fb.com
Sat May 23 04:59:30 UTC 2015


# HG changeset patch
# User Durham Goode <durham at fb.com>
# Date 1432357020 25200
#      Fri May 22 21:57:00 2015 -0700
# Node ID 912ff2370836f46461218a68212c3c253d2bc5c7
# Parent  f2b98dacb37ddd6713b11a1a871fcdbbc5fd8bb2
revbranchcache: special case nullrev

hg log -r 'branch(.)' was causing a stack trace if the user was on the nullrev
because it tried to access position -1 in the rev branch cache. This patch
special cases the nullrev to avoid the cache.

diff --git a/mercurial/branchmap.py b/mercurial/branchmap.py
--- a/mercurial/branchmap.py
+++ b/mercurial/branchmap.py
@@ -338,6 +338,9 @@ class revbranchcache(object):
     def branchinfo(self, rev):
         """Return branch name and close flag for rev, using and updating
         persistent cache."""
+        if rev == nullrev:
+            return self._branchinfo(rev)
+
         changelog = self._repo.changelog
         rbcrevidx = rev * _rbcrecsize
 
diff --git a/tests/test-revset.t b/tests/test-revset.t
--- a/tests/test-revset.t
+++ b/tests/test-revset.t
@@ -1630,6 +1630,12 @@ test or-ed indirect predicates (issue377
   5
   6
 
+  $ hg branch -q default
+  $ echo a >> a
+  $ hg ci -qm 'default branch commit'
+  $ log 'branch(null)'
+  10
+
 tests for 'remote()' predicate:
 #.  (csets in remote) (id)            (remote)
 1.  less than local   current branch  "default"


More information about the Mercurial-devel mailing list