hgext/evolve.py
changeset 145 928f217c1701
parent 142 c2f7a8530e51
child 146 e80a6c8ad452
--- a/hgext/evolve.py	Thu Mar 08 14:15:53 2012 +0100
+++ b/hgext/evolve.py	Thu Mar 08 14:35:57 2012 +0100
@@ -163,16 +163,34 @@
 
 @command('^stabilize',
     [
-     ('n', 'dry-run', False, 'Do nothing but printing what should be done')
+     ('n', 'dry-run', False, 'Do nothing but printing what should be done'),
+     ('-A', 'any', False, 'Stabilize unstable change on any topological branch'),
     ],
     '')
 def stabilize(ui, repo, **opts):
-    """move changeset out of they unstable state"""
+    """move changeset out of they unstable state
+
+    By default only works on changeset that will be rebase on ancestors of the
+    current working directory parent (included)"""
+
     obsolete = extensions.find('obsolete')
-    unstable = list(repo.set('unstable()'))
+
+    if opts['any']:
+        rvstargets = 'unstable()'
+    else:
+        rvstargets = 'unstable() and ((suspended() and obsancestors(::.))::)'
+
+    unstable = list(repo.set(rvstargets))
     if not unstable:
-        ui.write_err(_('no unstable changeset\n'))
-        return 1
+        unstable = opts['any'] and () or list(repo.set('unstable()'))
+        if unstable:
+            ui.write_err(_('nothing to stabilize here\n'))
+            ui.status(_('(%i unstable changesets, do you want --any ?)\n')
+                      % len(unstable))
+            return 2
+        else:
+            ui.write_err(_('no unstable changeset\n'))
+            return 1
     node = unstable[0]
     obs = node.parents()[0]
     if not obs.obsolete():