[PATCH 4 of 8 V2] revset: update origin() predicate so everything is more consistent with grafts

Patrick Mézard patrick at mezard.eu
Thu Jun 21 04:19:59 CDT 2012


Le 08/06/12 06:58, Matt Harbison a écrit :
> # HG changeset patch
> # User Matt Harbison <matt_harbison at yahoo.com>
> # Date 1337735103 14400
> # Node ID 2cf3fa0007c22037a8e3a1beaecec29d0bbc03ed
> # Parent  9eb8327a534e2f16d66b036771ebaceac93d4b2a
> revset: update origin() predicate so everything is more consistent with grafts
> 
> This links the source markers transitively, since the graft implementation
> essentially does this when it maintains the original source in each cset it
> creates.  Graft used to save the revision specified on the command line, but was
> changed between 2.0 and 2.0.1 in dc9fb7015d7f on Matt's suggestion [1].  The
> goal here is to provide a consistent definition of origin, regardless of what
> command was used and how it is implemented.

[...]

> diff --git a/mercurial/revset.py b/mercurial/revset.py
> --- a/mercurial/revset.py
> +++ b/mercurial/revset.py
> @@ -888,7 +888,19 @@
>      else:
>          s = tuple(p.rev() for p in repo[None].parents())
>  
> -    return [r for r in xrange(0, len(repo)) if _getrevsource(repo, r) in s]
> +    l = list()
> +
> +    for r in xrange(0, len(repo)):

Use subset as mentioned in a previous message. Note you cannot assume anything about subset order, and probably have to sort it.

> +        src = _getrevsource(repo, r)
> +
> +        if src is not -1:

if src != -1:

> +            # Select r if src is already selected (ie r was transitively copied
> +            # from a given origin), or if src is itself a given origin that was
> +            # NOT copied (to exclude a transplanted cset as an origin).
> +            if src in l or (src in s and _getrevsource(repo, src) is None):
> +                l.append(r)

Couldn't "src in l" become expensive? What about turning it into a set and replace the last statement with:

return [r for r in subset if r in l]

to preserve the input subset order?

> +
> +    return l
>  
>  def outgoing(repo, subset, x):
>      """``outgoing([path])``


More information about the Mercurial-devel mailing list