hgext/evolve.py
changeset 1449 9be1cadf7a07
parent 1448 3c113c097339
child 1451 73eb4f33f9dc
--- a/hgext/evolve.py	Wed Jun 24 19:42:01 2015 -0700
+++ b/hgext/evolve.py	Wed Jun 24 20:06:45 2015 -0700
@@ -2005,10 +2005,15 @@
 @command('^next',
          [('B', 'move-bookmark', False,
              _('Move active bookmark after update')),
-          ('', 'merge', False, _('bring uncommited change along'))],
+          ('', 'merge', False, _('bring uncommited change along')),
+          ('', 'evolve', False, _('evolve the next changeset if necessary'))],
          '[-B]')
 def cmdnext(ui, repo, **opts):
-    """update to child and display summary lines"""
+    """update to next child
+
+    You can use the --evolve flag to get unstable children evolved on demand.
+
+    The summary line of the destination is displayed for clarity"""
     wkctx = repo[None]
     wparents = wkctx.parents()
     if len(wparents) != 1:
@@ -2042,13 +2047,28 @@
         ui.warn(_('explicitly update to one of them\n'))
         result = 1
     else:
-        ui.warn(_('no children\n'))
         aspchildren = _aspiringchildren(repo, [repo['.'].rev()])
-        if aspchildren:
-            msg = _('(%i unstable changesets to be evolved here, '
-                    'do you want to evolve?)\n')
-            ui.warn(msg % len(aspchildren))
-        result = 1
+        if not opts['evolve']:
+            ui.warn(_('no children\n'))
+            if aspchildren:
+                msg = _('(%i unstable changesets to be evolved here, '
+                        'do you want --evolve?)\n')
+                ui.warn(msg % len(aspchildren))
+            result = 1
+        elif 1 < len(aspchildren):
+            ui.warn("ambigious next (unstable) changeset:\n")
+            for c in aspchildren:
+                displayer.show(repo[c])
+            ui.warn(_('(run "hg evolve --rev REV" on one of them)\n'))
+            return 1
+        else:
+            cmdutil.bailifchanged(repo)
+            result = _solveone(ui, repo, repo[aspchildren[0]], False,
+                               False, lambda:None, category='unstable')
+            if not result:
+                ui.status(_('working directory now at %s\n') % repo['.'])
+            return result
+        return 1
     return result
 
 def _reachablefrombookmark(repo, revs, mark):