Patchwork [3,of,5,evolve-ext-V2] evolve: simplify the evolve function

login
register
mail settings
Submitter Laurent Charignon
Date May 6, 2015, 12:42 a.m.
Message ID <d443bbbe9a7d0a55e1e4.1430872954@lcharignon-mbp.local>
Download mbox | patch
Permalink /patch/8921/
State Accepted
Headers show

Comments

Laurent Charignon - May 6, 2015, 12:42 a.m.
# HG changeset patch
# User Laurent Charignon <lcharignon@fb.com>
# Date 1430429137 25200
#      Thu Apr 30 14:25:37 2015 -0700
# Node ID d443bbbe9a7d0a55e1e4027204b56c639f5074a9
# Parent  ced767d4eeff2d68680cdd60ed36139f3087eaf2
evolve: simplify the evolve function

We compute the troubles once and use it in two places instead of recomputing
them just to count them.
Pierre-Yves David - May 6, 2015, 7:30 a.m.
On 05/05/2015 05:42 PM, Laurent Charignon wrote:
> # HG changeset patch
> # User Laurent Charignon <lcharignon@fb.com>
> # Date 1430429137 25200
> #      Thu Apr 30 14:25:37 2015 -0700
> # Node ID d443bbbe9a7d0a55e1e4027204b56c639f5074a9
> # Parent  ced767d4eeff2d68680cdd60ed36139f3087eaf2
> 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
> @@ -1258,10 +1258,11 @@
>       dryrunopt = opts['dry_run']
>       confirmopt = opts['confirm']
>       ui.setconfig('ui', 'forcemerge', opts.get('tool', ''), 'evolve')
> +    troubled = set(repo.revs('troubled()'))

I'm a bit sad we have to turn that into a set. Do we really have to?
(I took the patch anyway)
Laurent Charignon - May 6, 2015, 4:41 p.m.
On 5/6/15, 12:30 AM, "Pierre-Yves David" <pierre-yves.david@ens-lyon.org>
wrote:

>
>
>On 05/05/2015 05:42 PM, Laurent Charignon wrote:
>> # HG changeset patch
>> # User Laurent Charignon <lcharignon@fb.com>
>> # Date 1430429137 25200
>> #      Thu Apr 30 14:25:37 2015 -0700
>> # Node ID d443bbbe9a7d0a55e1e4027204b56c639f5074a9
>> # Parent  ced767d4eeff2d68680cdd60ed36139f3087eaf2
>> 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
>> @@ -1258,10 +1258,11 @@
>>       dryrunopt = opts['dry_run']
>>       confirmopt = opts['confirm']
>>       ui.setconfig('ui', 'forcemerge', opts.get('tool', ''), 'evolve')
>> +    troubled = set(repo.revs('troubled()'))
>
>I'm a bit sad we have to turn that into a set. Do we really have to?
>(I took the patch anyway)

Based on how it is used, I don't think we have too.
I will fix it in a coming patch.

Thanks for pointing this out,

Laurent
>
>-- 
>Pierre-Yves David

Patch

diff --git a/hgext/evolve.py b/hgext/evolve.py
--- a/hgext/evolve.py
+++ b/hgext/evolve.py
@@ -1258,10 +1258,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():
@@ -1318,14 +1319,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)
-
 def _picknexttroubled(ui, repo, pickany=False, progresscb=None):
     """Pick a the next trouble changeset to solve"""
     if progresscb: progresscb()