[PATCH STABLE] revbranchcache: special case nullrev

Pierre-Yves David pierre-yves.david at ens-lyon.org
Sat May 23 12:40:01 CDT 2015



On 05/22/2015 11:59 PM, Durham Goode wrote:
> # 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

This is a fix for to http://bz.selenic.com/show_bug.cgi?id=4683

We probably want to handle wdir in the same goes to prefer futur other 
traceback for our user.

> 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)
> +

as nullid is immutable, we can probably just return ('default', False) here.

-- 
Pierre-Yves David


More information about the Mercurial-devel mailing list