[PATCH 1 of 3 evolve-ext] evolve: make evolve --all reuse code of evolve --rev

Pierre-Yves David pierre-yves.david at ens-lyon.org
Fri Jun 5 01:35:32 CDT 2015



On 06/04/2015 03:07 PM, Laurent Charignon wrote:
> # HG changeset patch
> # User Laurent Charignon <lcharignon at fb.com>
> # Date 1433452413 25200
> #      Thu Jun 04 14:13:33 2015 -0700
> # Node ID 28f278575b4ce96477f34b1b40f7a80f31084039
> # Parent  82dd98428b8d85ea0c9acefebcff40ea59902c66
> evolve: make evolve --all reuse code of evolve --rev
>
> Before this patch, evolve --all has its own code path making the evolve function
> more complex than it had to. This patch makes evolve --all reuse the code of
> evolve --rev to simplify the evolve function.

This is going to misbehave when we have multiple troubles on a single 
revisions. We probably wants to get patch-3 features firsts.

1) adds the flags.
2) get --rev to try to solve each eligible troubles on each revs
3) solve instability only by default
4) use --rev infra for --all
5) use --rev infra for no argument case

Minor style nits below too.

> diff --git a/hgext/evolve.py b/hgext/evolve.py
> --- a/hgext/evolve.py
> +++ b/hgext/evolve.py
> @@ -1360,6 +1360,8 @@
>           if revopt or allopt:
>               ui.progress('evolve', seen, unit='changesets', total=count)
>
> +    if allopt and revopt:
> +        raise util.Abort('cannot specify both "--all" and "--rev"')
>       # Continuation handling
>       if contopt:
>           if anyopt:
> @@ -1368,11 +1370,10 @@
>               raise util.Abort('cannot specify both "--all" and "--continue"')
>           graftcmd = commands.table['graft'][0]
>           return graftcmd(ui, repo, old_obsolete=True, **{'continue': True})
> -    # Rev specified on the commands line
> -    if revopt:
> -        revs = repo.revs(revopt)
> +    # --rev or --all
> +    if revopt or allopt:
>           troubled = repo.revs('troubled()')
> -        _revs = revs & troubled
> +        _revs = repo.revs(revopt) & troubled if revopt else troubled

I do not feel like the if/else construct really help legibility here. 
can we have  a multi line if statement instead?

>           if not _revs:
>               ui.write_err("No troubled changes in the specified revisions\n")
>           else:
> @@ -1388,23 +1389,12 @@
>               progresscb()
>               _cleanup(ui, repo, startnode, showprogress)
>           return
> -    nexttrouble = _picknexttroubled(ui, repo, anyopt or allopt)
> +    nexttrouble = _picknexttroubled(ui, repo, anyopt)
>       # No trouble to resolve
>       if not nexttrouble:
>           return _handlenotrouble(ui, repo, startnode, dryrunopt)
>
> -    if allopt:
> -        # Resolving all the troubles
> -        while nexttrouble:
> -            progresscb()
> -            _solveone(ui, repo, nexttrouble, dryrunopt, confirmopt, progresscb)
> -            seen += 1
> -            progresscb()
> -            nexttrouble= _picknexttroubled(ui, repo, anyopt or allopt)
> -    else:
> -        # Resolving a single trouble
> -        _solveone(ui, repo, nexttrouble, dryrunopt, confirmopt, progresscb)
> -
> +    _solveone(ui, repo, nexttrouble, dryrunopt, confirmopt, progresscb)
>       _cleanup(ui, repo, startnode, showprogress)
>
>
> _______________________________________________
> Mercurial-devel mailing list
> Mercurial-devel at selenic.com
> https://selenic.com/mailman/listinfo/mercurial-devel
>

-- 
Pierre-Yves David


More information about the Mercurial-devel mailing list