Patchwork [4,of,5,evolve-ext] evolve: add selector for trouble types

login
register
mail settings
Submitter Laurent Charignon
Date May 13, 2015, 5:04 p.m.
Message ID <f7b2e0e5e05e76d181c9.1431536662@lcharignon-mbp.local>
Download mbox | patch
Permalink /patch/9057/
State Changes Requested
Headers show

Comments

Laurent Charignon - May 13, 2015, 5:04 p.m.
# HG changeset patch
# User Laurent Charignon <lcharignon@fb.com>
# Date 1431532715 25200
#      Wed May 13 08:58:35 2015 -0700
# Node ID f7b2e0e5e05e76d181c99e6ed3fbcc9508cc0c33
# Parent  96db44ca62d46ac9b57042885e40adb8c1fd9e4e
evolve: add selector for trouble types

This patch adds command line flags to select the kind of troubles to solve.
It is limited to --rev. The default of --rev remains solving all three kinds of
troubles.
Pierre-Yves David - May 14, 2015, 12:16 a.m.
On 05/13/2015 10:04 AM, Laurent Charignon wrote:
> # HG changeset patch
> # User Laurent Charignon <lcharignon@fb.com>
> # Date 1431532715 25200
> #      Wed May 13 08:58:35 2015 -0700
> # Node ID f7b2e0e5e05e76d181c99e6ed3fbcc9508cc0c33
> # Parent  96db44ca62d46ac9b57042885e40adb8c1fd9e4e
> evolve: add selector for trouble types
>
> This patch adds command line flags to select the kind of troubles to solve.
> It is limited to --rev. The default of --rev remains solving all three kinds of
> troubles.
>
> diff --git a/hgext/evolve.py b/hgext/evolve.py
> --- a/hgext/evolve.py
> +++ b/hgext/evolve.py
> @@ -1243,6 +1243,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, 'with --rev: solves only bumped changesets'),
> +    ('', 'divergent', False, 'with --rev: solves only divergent changesets'),
> +    ('', 'unstable', False, 'with --rev: solves only unstable changesets'),

Why are we stricting this to the --rev case? Can't we apply this in all 
cases

>       ('a', 'all', False, 'evolve all troubled changesets in the repo '
>                           '(implies any)'),
>       ('c', 'continue', False, 'continue an interrupted evolution'),
> @@ -1281,6 +1284,7 @@
>       dryrunopt = opts['dry_run']
>       confirmopt = opts['confirm']
>       revopt = opts['rev']
> +    troubletypes = ['bumped', 'divergent', 'unstable']
>       ui.setconfig('ui', 'forcemerge', opts.get('tool', ''), 'evolve')
>       troubled = set(repo.revs('troubled()'))
>
> @@ -1304,7 +1308,12 @@
>       # Rev specified on the commands line
>       if revopt:
>           revs = repo.revs(revopt)
> -        troubled = repo.revs('troubled()')
> +        # () as we use these in a revset
> +        specifictypes = [t + '()' for t in troubletypes if opts[t]]
> +        if specifictypes:
> +            troubled = repo.revs(' or '.join(specifictypes))
> +        else:
> +            troubled = repo.revs('troubled()')
>           _revs = revs & troubled
>           if not _revs:
>               ui.write_err("No troubled changes in the specified revset\n")
> diff --git a/tests/test-evolve.t b/tests/test-evolve.t
> --- a/tests/test-evolve.t
> +++ b/tests/test-evolve.t
> @@ -1001,7 +1001,9 @@
>     |
>     o  0	: a0 - test
>
> -  $ hg evolve --rev "14::"
> +  $ hg evolve --rev "14::" --bumped
> +  No troubled changes in the specified revset

This message is wrong. There is trouble in the specified revisions. But 
there is no bumped one in there. We need a working that:

1) make the filter clear
2) maybe point that other troubles affect (in the "do you want --any) 
fashion.
Laurent Charignon - May 14, 2015, 12:29 a.m.
On 5/13/15, 5:16 PM, "Pierre-Yves David" <pierre-yves.david@ens-lyon.org>
wrote:

>
>
>On 05/13/2015 10:04 AM, Laurent Charignon wrote:
>> # HG changeset patch
>> # User Laurent Charignon <lcharignon@fb.com>
>> # Date 1431532715 25200
>> #      Wed May 13 08:58:35 2015 -0700
>> # Node ID f7b2e0e5e05e76d181c99e6ed3fbcc9508cc0c33
>> # Parent  96db44ca62d46ac9b57042885e40adb8c1fd9e4e
>> evolve: add selector for trouble types
>>
>> This patch adds command line flags to select the kind of troubles to
>>solve.
>> It is limited to --rev. The default of --rev remains solving all three
>>kinds of
>> troubles.
>>
>> diff --git a/hgext/evolve.py b/hgext/evolve.py
>> --- a/hgext/evolve.py
>> +++ b/hgext/evolve.py
>> @@ -1243,6 +1243,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, 'with --rev: solves only bumped changesets'),
>> +    ('', 'divergent', False, 'with --rev: solves only divergent
>>changesets'),
>> +    ('', 'unstable', False, 'with --rev: solves only unstable
>>changesets'),
>
>Why are we stricting this to the --rev case? Can't we apply this in all
>Cases

Since we look for divergent twice in --all or --any, I was not sure how to
prioritize the flag over both lookups.
So I limited it to this simple case.
What implementation do you suggest?
>
>>       ('a', 'all', False, 'evolve all troubled changesets in the repo '
>>                           '(implies any)'),
>>       ('c', 'continue', False, 'continue an interrupted evolution'),
>> @@ -1281,6 +1284,7 @@
>>       dryrunopt = opts['dry_run']
>>       confirmopt = opts['confirm']
>>       revopt = opts['rev']
>> +    troubletypes = ['bumped', 'divergent', 'unstable']
>>       ui.setconfig('ui', 'forcemerge', opts.get('tool', ''), 'evolve')
>>       troubled = set(repo.revs('troubled()'))
>>
>> @@ -1304,7 +1308,12 @@
>>       # Rev specified on the commands line
>>       if revopt:
>>           revs = repo.revs(revopt)
>> -        troubled = repo.revs('troubled()')
>> +        # () as we use these in a revset
>> +        specifictypes = [t + '()' for t in troubletypes if opts[t]]
>> +        if specifictypes:
>> +            troubled = repo.revs(' or '.join(specifictypes))
>> +        else:
>> +            troubled = repo.revs('troubled()')
>>           _revs = revs & troubled
>>           if not _revs:
>>               ui.write_err("No troubled changes in the specified
>>revset\n")
>> diff --git a/tests/test-evolve.t b/tests/test-evolve.t
>> --- a/tests/test-evolve.t
>> +++ b/tests/test-evolve.t
>> @@ -1001,7 +1001,9 @@
>>     |
>>     o  0	: a0 - test
>>
>> -  $ hg evolve --rev "14::"
>> +  $ hg evolve --rev "14::" --bumped
>> +  No troubled changes in the specified revset
>
>This message is wrong. There is trouble in the specified revisions. But
>there is no bumped one in there. We need a working that:
>
>1) make the filter clear
>2) maybe point that other troubles affect (in the "do you want --any)
>fashion.

Sounds good, that will be in V2

>
>-- 
>Pierre-Yves David

Patch

diff --git a/hgext/evolve.py b/hgext/evolve.py
--- a/hgext/evolve.py
+++ b/hgext/evolve.py
@@ -1243,6 +1243,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, 'with --rev: solves only bumped changesets'),
+    ('', 'divergent', False, 'with --rev: solves only divergent changesets'),
+    ('', 'unstable', False, 'with --rev: solves only unstable changesets'),
     ('a', 'all', False, 'evolve all troubled changesets in the repo '
                         '(implies any)'),
     ('c', 'continue', False, 'continue an interrupted evolution'),
@@ -1281,6 +1284,7 @@ 
     dryrunopt = opts['dry_run']
     confirmopt = opts['confirm']
     revopt = opts['rev']
+    troubletypes = ['bumped', 'divergent', 'unstable']
     ui.setconfig('ui', 'forcemerge', opts.get('tool', ''), 'evolve')
     troubled = set(repo.revs('troubled()'))
 
@@ -1304,7 +1308,12 @@ 
     # Rev specified on the commands line
     if revopt:
         revs = repo.revs(revopt)
-        troubled = repo.revs('troubled()')
+        # () as we use these in a revset
+        specifictypes = [t + '()' for t in troubletypes if opts[t]]
+        if specifictypes:
+            troubled = repo.revs(' or '.join(specifictypes))
+        else:
+            troubled = repo.revs('troubled()')
         _revs = revs & troubled
         if not _revs:
             ui.write_err("No troubled changes in the specified revset\n")
diff --git a/tests/test-evolve.t b/tests/test-evolve.t
--- a/tests/test-evolve.t
+++ b/tests/test-evolve.t
@@ -1001,7 +1001,9 @@ 
   |
   o  0	: a0 - test
   
-  $ hg evolve --rev "14::"
+  $ hg evolve --rev "14::" --bumped
+  No troubled changes in the specified revset
+  $ hg evolve --rev "14::" --unstable
   move:[15] add gg
   atop:[18] a3
   move:[16] add gh