[PATCH 1 of 2] context: fix repo[n] not to make invalid changectx if n is out of range

Pierre-Yves David pierre-yves.david at ens-lyon.org
Mon Feb 2 08:25:54 CST 2015



On 02/02/2015 02:15 PM, Yuya Nishihara wrote:
> # HG changeset patch
> # User Yuya Nishihara <yuya at tcha.org>
> # Date 1420883783 -32400
> #      Sat Jan 10 18:56:23 2015 +0900
> # Node ID 184aa519a7a72ab10361d91f66455e3cea8f4f50
> # Parent  3667bc21b8773715d9472a3b4e034b77e62c6451
> context: fix repo[n] not to make invalid changectx if n is out of range
>
> This problem was spotted by ba89f7b542c9 (and eb763217152a), so it uses
> fullreposet(repo) instead. This fix is necessary to rewrite "rev()" revset
> without using fullreposet.
>
> diff --git a/mercurial/context.py b/mercurial/context.py
> --- a/mercurial/context.py
> +++ b/mercurial/context.py
> @@ -371,6 +371,8 @@ class changectx(basectx):
>
>           try:
>               if isinstance(changeid, int):
> +                if changeid < nullrev or changeid >= len(repo.changelog):

len(repo.changelog) can be more expensive than you expect this is has to 
take filtering into account (iirc), you probably want `changeid in 
repo.changelog`


-- 
Pierre-Yves David


More information about the Mercurial-devel mailing list