mercurial/phases.py
branchstable
changeset 16030 308406677e9d
parent 16025 6697498bdd83
child 16051 2aa5b51f310f
--- a/mercurial/phases.py	Mon Jan 30 15:17:08 2012 +0100
+++ b/mercurial/phases.py	Mon Jan 30 17:46:15 2012 +0100
@@ -298,3 +298,20 @@
                       heads, roots, roots, heads)
     return [c.node() for c in revset]
 
+
+def newcommitphase(ui):
+    """helper to get the target phase of new commit
+
+    Handle all possible values for the phases.new-commit options.
+
+    """
+    v = ui.config('phases', 'new-commit', draft)
+    try:
+        return phasenames.index(v)
+    except ValueError:
+        try:
+            return int(v)
+        except ValueError:
+            msg = _("phases.new-commit: not a valid phase name ('%s')")
+            raise error.ConfigError(msg % v)
+