[PATCH 3 of 5] rebase: replace revset with a manual computation

David Soria Parra dsp at experimentalworks.net
Wed Nov 13 00:20:02 CST 2013


On 11/11/2013 08:14 PM, Durham Goode wrote:
> diff --git a/mercurial/repair.py b/mercurial/repair.py
> --- a/mercurial/repair.py
> +++ b/mercurial/repair.py
> @@ -7,7 +7,7 @@
>  # GNU General Public License version 2 or any later version.
>  
>  from mercurial import changegroup
> -from mercurial.node import short
> +from mercurial.node import short, nullrev
>  from mercurial.i18n import _
>  import os
>  import errno
> @@ -91,11 +91,17 @@
>      savebases = [cl.node(r) for r in saverevs]
>      stripbases = [cl.node(r) for r in tostrip]
>  
> -    # For a set s, max(parents(s) - s) is the same as max(heads(::s - s)), but
> -    # is much faster
> -    newbmtarget = repo.revs('max(parents(%ld) - (%ld))', tostrip, tostrip)
> -    if newbmtarget:
> -        newbmtarget = repo[newbmtarget[0]].node()
> +    # bookmarks should go to the max parent
> +    maxparent = nullrev
> +    cl = repo.changelog
> +    for rev in tostrip:
> +        for prev in cl.parentrevs(rev):
> +            if prev > maxparent and not prev in tostrip:
> +                maxparent = prev
> +
> +    newbmtarget = maxparent
> +    if newbmtarget != nullrev:
> +        newbmtarget = repo[newbmtarget].node()

Maybe a bit picky, but I think it might be better to have add a comment
saying this is an optimization of max(parents(tostrop) - (tostrop)), so
nobody wants to change it back to revset later.

David



More information about the Mercurial-devel mailing list