evolve: simplify the evolve function
authorLaurent Charignon <lcharignon@fb.com>
Thu, 30 Apr 2015 14:25:37 -0700
changeset 1323 603104c880f7
parent 1322 f3e0686a63a1
child 1324 739208d1ee62
evolve: simplify the evolve function We compute the troubles once and use it in two places instead of recomputing them just to count them.
hgext/evolve.py
--- a/hgext/evolve.py	Tue May 05 17:15:06 2015 -0700
+++ b/hgext/evolve.py	Thu Apr 30 14:25:37 2015 -0700
@@ -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()