diff --git a/mercurial/localrepo.py b/mercurial/localrepo.py --- a/mercurial/localrepo.py +++ b/mercurial/localrepo.py @@ -1268,8 +1268,7 @@ class localrepository(repo.repository): parent2=xp2, pending=p) self.changelog.finalize(trp) # set the new commit is proper phase - targetphase = self.ui.configint('phases', 'new-commit', - phases.draft) + targetphase = phases.newcommitphase(self.ui) if targetphase: # retract boundary do not alter parent changeset. # if a parent have higher the resulting phase will diff --git a/mercurial/phases.py b/mercurial/phases.py --- a/mercurial/phases.py +++ b/mercurial/phases.py @@ -298,3 +298,20 @@ def newheads(repo, heads, roots): 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) + diff --git a/tests/test-phases.t b/tests/test-phases.t --- a/tests/test-phases.t +++ b/tests/test-phases.t @@ -42,7 +42,7 @@ Draft commit are properly created over p Test creating changeset as secret - $ mkcommit E --config phases.new-commit=2 + $ mkcommit E --config phases.new-commit='secret' $ hglog 4 2 E 3 1 D