Patchwork help: hide command line options marked as "advanced"

login
register
mail settings
Submitter Jun Wu
Date Nov. 1, 2016, 2:51 p.m.
Message ID <c32f7fddef8a6774c987.1478011899@x1c>
Download mbox | patch
Permalink /patch/17242/
State Superseded
Delegated to: Jun Wu
Headers show

Comments

Jun Wu - Nov. 1, 2016, 2:51 p.m.
# HG changeset patch
# User Jun Wu <quark@fb.com>
# Date 1478011845 0
#      Tue Nov 01 14:50:45 2016 +0000
# Node ID c32f7fddef8a6774c987b08ddd91e118c33b7836
# Parent  264f00b3e5f045ac5b58d79e2a3976585f4e7739
# Available At https://bitbucket.org/quark-zju/hg-draft
#              hg pull https://bitbucket.org/quark-zju/hg-draft -r c32f7fddef8a
help: hide command line options marked as "advanced"

Previously, we have keywords like "(DEPRECATED)" and "(EXPERIMENTAL)" to
hide command line options in non-verbose help output.

However, sometimes an option is neither deprecated nor experimental. It's
well-tested and working, but just not designed to average users. This patch
adds a keyword "(ADVANCED)" to fit in such use cases.

Thanks rom1dep for the suggestion of the word "advanced".
Jun Wu - Nov. 1, 2016, 3:02 p.m.
Excerpts from Jun Wu's message of 2016-11-01 14:51:39 +0000:
> # HG changeset patch
> # User Jun Wu <quark@fb.com>
> # Date 1478011845 0
> #      Tue Nov 01 14:50:45 2016 +0000
> # Node ID c32f7fddef8a6774c987b08ddd91e118c33b7836
> # Parent  264f00b3e5f045ac5b58d79e2a3976585f4e7739
> # Available At https://bitbucket.org/quark-zju/hg-draft 
> #              hg pull https://bitbucket.org/quark-zju/hg-draft  -r c32f7fddef8a
> help: hide command line options marked as "advanced"
> 
> Previously, we have keywords like "(DEPRECATED)" and "(EXPERIMENTAL)" to
> hide command line options in non-verbose help output.
> 
> However, sometimes an option is neither deprecated nor experimental. It's
> well-tested and working, but just not designed to average users. This patch
> adds a keyword "(ADVANCED)" to fit in such use cases.
> 
> Thanks rom1dep for the suggestion of the word "advanced".
> 
> diff --git a/mercurial/help.py b/mercurial/help.py
> --- a/mercurial/help.py
> +++ b/mercurial/help.py
> @@ -34,12 +34,14 @@ from .hgweb import (
>  )
>  
> -_exclkeywords = [
> +_exclkeywords = set([
> +    "(ADVANCED)",
>      "(DEPRECATED)",
>      "(EXPERIMENTAL)",
> -    # i18n: "(DEPRECATED)" is a keyword, must be translated consistently
> +    # i18n: "(ADVANCED)", "(DEPRECATED)", "(EXPERIMENTAL)" are keywords, must

I noticed "# i18n:" has special meaning and the change is wrong. I will mark
this as "Superseded" and send a V2.

> +    # be translated consistently
> +    _("(ADVANCED)"),
>      _("(DEPRECATED)"),
> -    # i18n: "(EXPERIMENTAL)" is a keyword, must be translated consistently
>      _("(EXPERIMENTAL)"),
> -    ]
> +    ])
>  
>  def listexts(header, exts, indent=1, showdeprecated=False):
> diff --git a/tests/test-help.t b/tests/test-help.t
> --- a/tests/test-help.t
> +++ b/tests/test-help.t
> @@ -684,4 +684,5 @@ this is a section and erroring out weird
>    >     'hg nohelp',
>    >     norepo=True)
> +  > @command('debugoptADV', [('', 'aopt', None, 'option is (ADVANCED)')])
>    > @command('debugoptDEP', [('', 'dopt', None, 'option is (DEPRECATED)')])
>    > @command('debugoptEXP', [('', 'eopt', None, 'option is (EXPERIMENTAL)')])
> @@ -897,4 +898,5 @@ Test list of internal help commands
>     debugobsolete
>                   create arbitrary obsolete marker
> +   debugoptADV   (no help text available)
>     debugoptDEP   (no help text available)
>     debugoptEXP   (no help text available)
> @@ -1108,5 +1110,13 @@ Test list of commands with command with 
>  
>  
> -test deprecated and experimental options are hidden in command help
> +test advanced, deprecated and experimental options are hidden in command help
> +  $ hg help debugoptADV
> +  hg debugoptADV
> +  
> +  (no help text available)
> +  
> +  options:
> +  
> +  (some details hidden, use --verbose to show complete help)
>    $ hg help debugoptDEP
>    hg debugoptDEP
> @@ -1127,5 +1137,7 @@ test deprecated and experimental options
>    (some details hidden, use --verbose to show complete help)
>  
> -test deprecated and experimental options is shown with -v
> +test advanced, deprecated and experimental options is shown with -v

I will change "is" to "are" as well.

> +  $ hg help -v debugoptADV | grep aopt
> +    --aopt option is (ADVANCED)
>    $ hg help -v debugoptDEP | grep dopt
>      --dopt option is (DEPRECATED)

Patch

diff --git a/mercurial/help.py b/mercurial/help.py
--- a/mercurial/help.py
+++ b/mercurial/help.py
@@ -34,12 +34,14 @@  from .hgweb import (
 )
 
-_exclkeywords = [
+_exclkeywords = set([
+    "(ADVANCED)",
     "(DEPRECATED)",
     "(EXPERIMENTAL)",
-    # i18n: "(DEPRECATED)" is a keyword, must be translated consistently
+    # i18n: "(ADVANCED)", "(DEPRECATED)", "(EXPERIMENTAL)" are keywords, must
+    # be translated consistently
+    _("(ADVANCED)"),
     _("(DEPRECATED)"),
-    # i18n: "(EXPERIMENTAL)" is a keyword, must be translated consistently
     _("(EXPERIMENTAL)"),
-    ]
+    ])
 
 def listexts(header, exts, indent=1, showdeprecated=False):
diff --git a/tests/test-help.t b/tests/test-help.t
--- a/tests/test-help.t
+++ b/tests/test-help.t
@@ -684,4 +684,5 @@  this is a section and erroring out weird
   >     'hg nohelp',
   >     norepo=True)
+  > @command('debugoptADV', [('', 'aopt', None, 'option is (ADVANCED)')])
   > @command('debugoptDEP', [('', 'dopt', None, 'option is (DEPRECATED)')])
   > @command('debugoptEXP', [('', 'eopt', None, 'option is (EXPERIMENTAL)')])
@@ -897,4 +898,5 @@  Test list of internal help commands
    debugobsolete
                  create arbitrary obsolete marker
+   debugoptADV   (no help text available)
    debugoptDEP   (no help text available)
    debugoptEXP   (no help text available)
@@ -1108,5 +1110,13 @@  Test list of commands with command with 
 
 
-test deprecated and experimental options are hidden in command help
+test advanced, deprecated and experimental options are hidden in command help
+  $ hg help debugoptADV
+  hg debugoptADV
+  
+  (no help text available)
+  
+  options:
+  
+  (some details hidden, use --verbose to show complete help)
   $ hg help debugoptDEP
   hg debugoptDEP
@@ -1127,5 +1137,7 @@  test deprecated and experimental options
   (some details hidden, use --verbose to show complete help)
 
-test deprecated and experimental options is shown with -v
+test advanced, deprecated and experimental options is shown with -v
+  $ hg help -v debugoptADV | grep aopt
+    --aopt option is (ADVANCED)
   $ hg help -v debugoptDEP | grep dopt
     --dopt option is (DEPRECATED)