# HG changeset patch # User Pierre-Yves David # Date 1327941975 -3600 # Node ID 308406677e9d1d05fdba9a33797745c38fa0fdac # Parent ee1c8385e5b0b4d080cfa28460bf36c57f3e6e92 phases: allow phase name in phases.new-commit settings Before this commit only phase index where accepted diff -r ee1c8385e5b0 -r 308406677e9d mercurial/localrepo.py --- a/mercurial/localrepo.py Mon Jan 30 15:17:08 2012 +0100 +++ b/mercurial/localrepo.py Mon Jan 30 17:46:15 2012 +0100 @@ -1268,8 +1268,7 @@ 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 -r ee1c8385e5b0 -r 308406677e9d mercurial/phases.py --- 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) + diff -r ee1c8385e5b0 -r 308406677e9d tests/test-phases.t --- a/tests/test-phases.t Mon Jan 30 15:17:08 2012 +0100 +++ b/tests/test-phases.t Mon Jan 30 17:46:15 2012 +0100 @@ -42,7 +42,7 @@ 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