[PATCH] revset: cleanup of algorithm used in `destination()` predicate

Pierre-Yves David pierre-yves.david at ens-lyon.org
Wed Sep 7 10:54:44 EDT 2016



On 09/07/2016 04:10 PM, Hannes Oldenburg wrote:
> # HG changeset patch
> # User Hannes Oldenburg <hannes.christian.oldenburg at gmail.com>
> # Date 1473247581 0
> #      Wed Sep 07 11:26:21 2016 +0000
> # Node ID dacd359aca5a1094d830958ab853bf83b5ca6631
> # Parent  f148bfa40489269be2e48046734f81065129847a
> revset: cleanup of algorithm used in `destination()` predicate

Can you include a bit more details in the changeset description about 
what this cleanup is about and why it is correct ?

> diff -r f148bfa40489 -r dacd359aca5a mercurial/revset.py
> --- a/mercurial/revset.py	Tue Jul 05 09:37:07 2016 +0200
> +++ b/mercurial/revset.py	Wed Sep 07 11:26:21 2016 +0000
> @@ -851,28 +851,20 @@
>      # transitive transplants and rebases to yield the same results as transitive
>      # grafts.
>      for r in subset:
> -        src = _getrevsource(repo, r)
> -        lineage = None
> -
> -        while src is not None:
> -            if lineage is None:
> -                lineage = list()
> -
> +        lineage = list()
> +        found = False
> +        while r is not None and not found:
>              lineage.append(r)
> -
> +            r = _getrevsource(repo, r)
>              # The visited lineage is a match if the current source is in the arg
>              # set.  Since every candidate dest is visited by way of iterating
>              # subset, any dests further back in the lineage will be tested by a
>              # different iteration over subset.  Likewise, if the src was already
>              # selected, the current lineage can be selected without going back
>              # further.
> -            if src in sources or src in dests:
> -                dests.update(lineage)
> -                break
> -
> -            r = src
> -            src = _getrevsource(repo, r)
> -
> +            found = r in sources or r in dests
> +        if found:
> +            dests.update(lineage)
>      return subset.filter(dests.__contains__,
>                           condrepr=lambda: '<destination %r>' % sorted(dests))
>
> _______________________________________________
> Mercurial-devel mailing list
> Mercurial-devel at mercurial-scm.org
> https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
>

-- 
Pierre-Yves David


More information about the Mercurial-devel mailing list