[PATCH 3 of 3 evolve-ext] evolve: add selector for trouble types

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



On 06/04/2015 03:07 PM, Laurent Charignon wrote:
> # HG changeset patch
> # User Laurent Charignon <lcharignon at fb.com>
> # Date 1433455399 25200
> #      Thu Jun 04 15:03:19 2015 -0700
> # Node ID d7ddf1ce95bfcca394f702d1616d14587a6d7b91
> # Parent  c56ec61b8dcdf856e6c693046e2ef2ded2142b47
> evolve: add selector for trouble types

types feels wrong here, it has a strong connotation in the computer 
world. You could use 'category' or 'kind' but 'trouble' is probably fine.

> This patch adds command line flags to select the kind of troubles to solve.

This highlight that 'kind' is a good alternative.

> Before this patch evolve was solving any kind of troubled. With this patch

any kind of troubles (or any troubles)

> evolve --all and evolve --rev can be configured to only solve only some type
> of troubles (divergent, bumped or unstable). To give this choice to the
> user we add three new command line flags to the evolve command: --bumped,
> --divergent and --unstable.

This patch probably deserve an update of the function help.

Is your next patches about

> diff --git a/hgext/evolve.py b/hgext/evolve.py
> --- a/hgext/evolve.py
> +++ b/hgext/evolve.py
> @@ -1310,6 +1310,9 @@
>           'ask for confirmation before performing the action'),
>       ('A', 'any', False, 'also consider troubled changesets unrelated to current working directory'),
>       ('r', 'rev', '', 'solves troubles of these revisions'),
> +    ('', 'bumped', False, 'solves only bumped changesets'),

'bumped changesets' does not make so much senses as changesets can have 
multiple trouble. Only 'evolve' would be a more appropriate verbs for 
changesets.

But you probably want to keep 'solve' switch the things to something 
like: "solves 'bumped' troubles".

> +    ('', 'divergent', False, 'solves only divergent changesets'),
> +    ('', 'unstable', False, 'solves only unstable changesets'),
>       ('a', 'all', False, 'evolve all troubled changesets in the repo '
>                           '(implies any)'),
>       ('c', 'continue', False, 'continue an interrupted evolution'),
> @@ -1348,6 +1351,8 @@
>       dryrunopt = opts['dry_run']
>       confirmopt = opts['confirm']
>       revopt = opts['rev']
> +    troubletypes = ['bumped', 'divergent', 'unstable']

Same feedback on types

> +    specifictypes = [t for t in troubletypes if opts[t]] or troubletypes

meh for the 'or' usage. Can use use a if statemetn (on multiple line)
(same feedback on types)
>       ui.setconfig('ui', 'forcemerge', opts.get('tool', ''), 'evolve')
>       troubled = set(repo.revs('troubled()'))
>
> @@ -1372,7 +1377,7 @@
>           return graftcmd(ui, repo, old_obsolete=True, **{'continue': True})
>       # --rev or --all
>       if revopt or allopt:
> -        troubled = repo.revs('troubled()')
> +        troubled = repo.revs(' or '.join(t + '()' for t in specifictypes))

            Maybe Consider hitting obsolete.getset(repo, types) instead, 
it will return a set.

>           _revs = repo.revs(revopt) & troubled if revopt else troubled
>           if not _revs:
>               _handlenotrouble(ui, repo, startnode, dryrunopt)
> @@ -1389,7 +1394,7 @@
>               progresscb()
>               _cleanup(ui, repo, startnode, showprogress)
>           return
> -    nexttrouble = _picknexttroubled(ui, repo, anyopt)
> +    nexttrouble = _picknexttroubled(ui, repo, specifictypes, anyopt)
>       # No trouble to resolve
>       if not nexttrouble:
>           return _handlenotrouble(ui, repo, startnode, dryrunopt)
> @@ -1413,19 +1418,22 @@
>       else:
>           assert False  # WHAT? unknown troubles
>
> -def _picknexttroubled(ui, repo, pickany=False, progresscb=None):
> +def _picknexttroubled(ui, repo, types, pickany=False, progresscb=None):
>       """Pick a the next trouble changeset to solve"""

You probably want to update the docstring

>       if progresscb: progresscb()
> -    tro = _stabilizableunstable(repo, repo['.'])
> +    if 'unstable' in types:
> +        tro = _stabilizableunstable(repo, repo['.'])
>       if tro is None:
>           wdp = repo['.']
> -        if 'divergent' in wdp.troubles():
> +        if 'divergent' in wdp.troubles() and 'divergent' in types:
>               tro = wdp
>       if tro is None and pickany:
> -        troubled = list(repo.set('unstable()'))
> -        if not troubled:
> +        troubled = None
> +        if 'unstable' in types:
> +            troubled = list(repo.set('unstable()'))
> +        if not troubled and 'bumped' in types:
>               troubled = list(repo.set('bumped()'))
> -        if not troubled:
> +        if not troubled and 'divergent' in types:
>               troubled = list(repo.set('divergent()'))
>           if troubled:
>               tro = troubled[0]
> diff --git a/tests/test-evolve.t b/tests/test-evolve.t
> --- a/tests/test-evolve.t
> +++ b/tests/test-evolve.t
> @@ -1020,7 +1020,10 @@
>     nothing to evolve here
>     (2 troubled changesets, do you want --any ?)
>
> -  $ hg evolve --rev "14::"
> +  $ hg evolve --rev "14::" --bumped
> +  nothing to evolve here
> +  (2 troubled changesets, do you want --any ?)
> +  $ hg evolve --rev "14::" --unstable
>     move:[15] add gg
>     atop:[18] a3
>     move:[16] add gh


-- 
Pierre-Yves David


More information about the Mercurial-devel mailing list