hgext/evolve.py
changeset 1325 1fe3da0b4601
parent 1324 739208d1ee62
child 1326 ae678c98b685
--- a/hgext/evolve.py	Tue May 05 14:25:35 2015 -0700
+++ b/hgext/evolve.py	Tue May 05 14:25:59 2015 -0700
@@ -1222,13 +1222,13 @@
     if repo['.'] != startnode:
         ui.status(_('working directory is now at %s\n') % repo['.'])
 
-
 @command('^evolve|stabilize|solve',
     [('n', 'dry-run', False,
         'do not perform actions, just print what would be done'),
      ('', 'confirm', False,
         'ask for confirmation before performing the action'),
     ('A', 'any', False, 'also consider troubled changesets unrelated to current working directory'),
+    ('r', 'rev', '', 'revset to find troubles in'),
     ('a', 'all', False, 'evolve all troubled changesets in the repo '
                         '(implies any)'),
     ('c', 'continue', False, 'continue an interrupted evolution'),
@@ -1259,12 +1259,14 @@
     The working directory is updated to the newly created revision.
     """
 
+    # Options
     contopt = opts['continue']
     anyopt = opts['any']
     allopt = opts['all']
     startnode = repo['.']
     dryrunopt = opts['dry_run']
     confirmopt = opts['confirm']
+    revopt = opts['rev']
     ui.setconfig('ui', 'forcemerge', opts.get('tool', ''), 'evolve')
     troubled = set(repo.revs('troubled()'))
 
@@ -1274,7 +1276,7 @@
     showprogress = allopt
 
     def progresscb():
-        if allopt:
+        if revopt or allopt:
             ui.progress('evolve', seen, unit='changesets', total=count)
 
     # Continuation handling
@@ -1285,9 +1287,25 @@
             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 = set(repo.revs(revopt))
+        troubled = set(repo.revs('troubled()'))
+        _revs = revs & troubled
+        if not _revs:
+            ui.write_err("No troubled changes in the specified revset")
+        else:
+            # For the progress bar to show
+            count = len(_revs)
+            for rev in _revs:
+                progresscb()
+                _solveone(ui, repo, repo[rev], dryrunopt, confirmopt, 
+                        progresscb)
+                seen += 1
+            progresscb()
+            _cleanup(ui, repo, startnode, showprogress)
+            return
     nexttrouble = _picknexttroubled(ui, repo, anyopt or allopt)
- 
     # No trouble to resolve
     if not nexttrouble:
         return handlenotrouble(ui, repo, startnode, dryrunopt)