Patchwork [3,of,5] phase: handle phase with no command flag

login
register
mail settings
Submitter Boris Feld
Date Aug. 24, 2018, 10:35 p.m.
Message ID <93824739fc0d33ce7853.1535150139@FB-lair>
Download mbox | patch
Permalink /patch/34038/
State Accepted
Headers show

Comments

Boris Feld - Aug. 24, 2018, 10:35 p.m.
# HG changeset patch
# User Boris Feld <boris.feld@octobus.net>
# Date 1534979719 -7200
#      Thu Aug 23 01:15:19 2018 +0200
# Node ID 93824739fc0d33ce7853ccfd57818df694f5593f
# Parent  5ec0b78876f2fc334c57d664a67d342859fc2b47
# EXP-Topic internal-phase.prepare
# Available At https://bitbucket.org/octobus/mercurial-devel/
#              hg pull https://bitbucket.org/octobus/mercurial-devel/ -r 93824739fc0d
phase: handle phase with no command flag

Before this changeset, all existing phases have a corresponding flag on the `hg
phase` command. (eg: `hg phase --draft`).

After this changeset, a phase can exists without having an associated flag.
This is useful to introduce a new internal phase that we do not want to expose
to user.
Yuya Nishihara - Aug. 25, 2018, 8:30 a.m.
On Sat, 25 Aug 2018 00:35:39 +0200, Boris Feld wrote:
> # HG changeset patch
> # User Boris Feld <boris.feld@octobus.net>
> # Date 1534979719 -7200
> #      Thu Aug 23 01:15:19 2018 +0200
> # Node ID 93824739fc0d33ce7853ccfd57818df694f5593f
> # Parent  5ec0b78876f2fc334c57d664a67d342859fc2b47
> # EXP-Topic internal-phase.prepare
> # Available At https://bitbucket.org/octobus/mercurial-devel/
> #              hg pull https://bitbucket.org/octobus/mercurial-devel/ -r 93824739fc0d
> phase: handle phase with no command flag
> 
> Before this changeset, all existing phases have a corresponding flag on the `hg
> phase` command. (eg: `hg phase --draft`).
> 
> After this changeset, a phase can exists without having an associated flag.
> This is useful to introduce a new internal phase that we do not want to expose
> to user.
> 
> diff --git a/mercurial/commands.py b/mercurial/commands.py
> --- a/mercurial/commands.py
> +++ b/mercurial/commands.py
> @@ -4030,7 +4030,7 @@ def phase(ui, repo, *revs, **opts):
>      # search for a unique phase argument
>      targetphase = None
>      for idx, name in enumerate(phases.phasenames):
> -        if opts[name]:
> +        if opts.get(name, False):

Really minor nit, but I'd rather add an explicit list of non-internal phase
names.

Patch

diff --git a/mercurial/commands.py b/mercurial/commands.py
--- a/mercurial/commands.py
+++ b/mercurial/commands.py
@@ -4030,7 +4030,7 @@  def phase(ui, repo, *revs, **opts):
     # search for a unique phase argument
     targetphase = None
     for idx, name in enumerate(phases.phasenames):
-        if opts[name]:
+        if opts.get(name, False):
             if targetphase is not None:
                 raise error.Abort(_('only one phase can be specified'))
             targetphase = idx