[PATCH 2 of 4 evolve-ext] evolve: simplify the evolve function

Pierre-Yves David pierre-yves.david at ens-lyon.org
Tue May 5 16:54:08 CDT 2015



On 05/05/2015 02:29 PM, Laurent Charignon wrote:
> # HG changeset patch
> # User Laurent Charignon <lcharignon at fb.com>
> # Date 1430429137 25200
> #      Thu Apr 30 14:25:37 2015 -0700
> # Node ID 1a06c8c24ea35697471e2108581a6be71773c8e0
> # Parent  1dd10a7e485b881c472ead204407e85e9b64fa54
> evolve: simplify the evolve function
>
> We compute the troubles once and use it in two places instead of recomputing
> them just to count them.
>
> diff --git a/hgext/evolve.py b/hgext/evolve.py
> --- a/hgext/evolve.py
> +++ b/hgext/evolve.py
> @@ -1256,10 +1256,11 @@
>       dryrunopt = opts['dry_run']
>       confirmopt = opts['confirm']
>       ui.setconfig('ui', 'forcemerge', opts.get('tool', ''), 'evolve')
> +    troubled = set(repo.revs('troubled()'))
>
>       # Progress handling
>       seen = 1
> -    count = allopt and _counttroubled(ui, repo) or 1
> +    count = allopt and len(troubled) or 1
>       showprogress = allopt
>
>       def progresscb():
> @@ -1316,14 +1317,6 @@
>       else:
>           assert False  # WHAT? unknown troubles
>
> -def _counttroubled(ui, repo):
> -    """Count the amount of troubled changesets"""
> -    troubled = set()
> -    troubled.update(getrevs(repo, 'unstable'))
> -    troubled.update(getrevs(repo, 'bumped'))
> -    troubled.update(getrevs(repo, 'divergent'))
> -    return len(troubled)

I just had a look at the 'troubled' revset implementation and it is 
highly inefficient :) Can you move the _counttroubled approach in the 
revset computation before dropping the calls (basically, build the big 
set, use it a base set and & it to the subset.)

-- 
Pierre-Yves David


More information about the Mercurial-devel mailing list