[PATCH v2] histedit: select the lowest rev when looking for a root in a revset

Matt Mackall mpm at selenic.com
Wed Mar 19 13:56:02 CDT 2014


On Wed, 2014-03-19 at 11:32 -0700, David Soria Parra wrote:
> # HG changeset patch
> # User David Soria Parra <davidsp at fb.com>
> # Date 1394751906 25200
> #      Thu Mar 13 16:05:06 2014 -0700
> # Node ID cd5d791af790d7a8bac50ebf4a66e71f1b51a25b
> # Parent  c152e538b85b099ce20b51104b8b7dd3666aad7c
> histedit: select the lowest rev when looking for a root in a revset
> 
> When we specify a revision or a revset we just get the last element from the
> list. For revsets this can lead to unintended effects where you specify a
> revset like only() but instead histedit selects the highest revision in the
> set as root. Therefore we should always use the lowest revision number as
> root.
> 
> diff --git a/hgext/histedit.py b/hgext/histedit.py
> --- a/hgext/histedit.py
> +++ b/hgext/histedit.py
> @@ -565,8 +565,11 @@
>                  remote = None
>              root = findoutgoing(ui, repo, remote, force, opts)
>          else:
> -            root = revs[0]
> -            root = scmutil.revsingle(repo, root).node()
> +            rev = '.'
> +            revrange = scmutil.revrange(repo, [revs[0]])
> +            if len(revrange) > 0:
> +                rev = sorted(revrange)[0]
> +            root = repo[rev].node()

I think what actually matters here is that:

- we choose the root of the provided set
- and there is only one root

That'd be something like:

 rootrevs = repo.set('roots(%ld)', revs)
 if len(rootrevs) != 1:
     ...

This will also catch both bifurcated and disjoint sets. I presume
there's another check somewhere else that will check for linearity of
the root's descendants.


-- 
Mathematics is the supreme nostalgia of our time.




More information about the Mercurial-devel mailing list