changeset 40967:8604f130eb43

help: show "default: off" for boolean flags that default to off Differential Revision: https://phab.mercurial-scm.org/D5431
author Martin von Zweigbergk <martinvonz@google.com>
date Fri, 14 Dec 2018 13:33:12 -0800
parents 05abb5fb146a
children f6187e60f792
files mercurial/help.py tests/test-extension.t tests/test-fix.t tests/test-help.t tests/test-narrow-trackedcmd.t tests/test-shelve.t tests/test-uncommit.t
diffstat 7 files changed, 22 insertions(+), 20 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/help.py	Fri Dec 14 13:20:00 2018 -0800
+++ b/mercurial/help.py	Fri Dec 14 13:33:12 2018 -0800
@@ -163,14 +163,14 @@
 
         if isinstance(default, fancyopts.customopt):
             default = default.getdefaultvalue()
-        if default and not callable(default):
+        if (default and not callable(default)) or default is False:
             # default is of unknown type, and in Python 2 we abused
             # the %s-shows-repr property to handle integers etc. To
             # match that behavior on Python 3, we do str(default) and
             # then convert it to bytes.
             defaultstr = pycompat.bytestr(default)
-            if default is True:
-                defaultstr = _("on")
+            if isinstance(default, bool):
+                defaultstr = _("on") if default else _("off")
             desc += _(" (default: %s)") % defaultstr
 
         if isinstance(default, list):
--- a/tests/test-extension.t	Fri Dec 14 13:20:00 2018 -0800
+++ b/tests/test-extension.t	Fri Dec 14 13:33:12 2018 -0800
@@ -716,7 +716,7 @@
       --profile           print command execution profile
       --version           output version information and exit
    -h --help              display help and exit
-      --hidden            consider hidden changesets
+      --hidden            consider hidden changesets (default: off)
       --pager TYPE        when to paginate (boolean, always, auto, or never)
                           (default: auto)
 
@@ -755,7 +755,7 @@
       --profile           print command execution profile
       --version           output version information and exit
    -h --help              display help and exit
-      --hidden            consider hidden changesets
+      --hidden            consider hidden changesets (default: off)
       --pager TYPE        when to paginate (boolean, always, auto, or never)
                           (default: auto)
 
@@ -1043,7 +1043,7 @@
       --profile           print command execution profile
       --version           output version information and exit
    -h --help              display help and exit
-      --hidden            consider hidden changesets
+      --hidden            consider hidden changesets (default: off)
       --pager TYPE        when to paginate (boolean, always, auto, or never)
                           (default: auto)
 
@@ -1080,7 +1080,7 @@
       --profile           print command execution profile
       --version           output version information and exit
    -h --help              display help and exit
-      --hidden            consider hidden changesets
+      --hidden            consider hidden changesets (default: off)
       --pager TYPE        when to paginate (boolean, always, auto, or never)
                           (default: auto)
 
@@ -1155,7 +1155,7 @@
       --profile           print command execution profile
       --version           output version information and exit
    -h --help              display help and exit
-      --hidden            consider hidden changesets
+      --hidden            consider hidden changesets (default: off)
       --pager TYPE        when to paginate (boolean, always, auto, or never)
                           (default: auto)
 
@@ -1191,7 +1191,7 @@
       --profile           print command execution profile
       --version           output version information and exit
    -h --help              display help and exit
-      --hidden            consider hidden changesets
+      --hidden            consider hidden changesets (default: off)
       --pager TYPE        when to paginate (boolean, always, auto, or never)
                           (default: auto)
 
--- a/tests/test-fix.t	Fri Dec 14 13:20:00 2018 -0800
+++ b/tests/test-fix.t	Fri Dec 14 13:33:12 2018 -0800
@@ -104,12 +104,12 @@
   
   options ([+] can be repeated):
   
-      --all          fix all non-public non-obsolete revisions
+      --all          fix all non-public non-obsolete revisions (default: off)
       --base REV [+] revisions to diff against (overrides automatic selection,
                      and applies to every revision being fixed)
    -r --rev REV [+]  revisions to fix
-   -w --working-dir  fix the working directory
-      --whole        always fix every line of a file
+   -w --working-dir  fix the working directory (default: off)
+      --whole        always fix every line of a file (default: off)
   
   (some details hidden, use --verbose to show complete help)
 
--- a/tests/test-help.t	Fri Dec 14 13:20:00 2018 -0800
+++ b/tests/test-help.t	Fri Dec 14 13:33:12 2018 -0800
@@ -440,7 +440,7 @@
       --profile           print command execution profile
       --version           output version information and exit
    -h --help              display help and exit
-      --hidden            consider hidden changesets
+      --hidden            consider hidden changesets (default: off)
       --pager TYPE        when to paginate (boolean, always, auto, or never)
                           (default: auto)
   
@@ -540,7 +540,7 @@
       --profile           print command execution profile
       --version           output version information and exit
    -h --help              display help and exit
-      --hidden            consider hidden changesets
+      --hidden            consider hidden changesets (default: off)
       --pager TYPE        when to paginate (boolean, always, auto, or never)
                           (default: auto)
 
@@ -905,7 +905,7 @@
                                     xxxxxxxxxxxxxxxxxxxxxxx (default: 3)
    -n --                            normal desc
       --newline VALUE               line1 line2
-      --default-off                 enable X
+      --default-off                 enable X (default: off)
       --default-on                  enable Y (default: on)
       --callableopt VALUE           adds foo
       --customopt VALUE             adds bar
@@ -2890,7 +2890,7 @@
   <td>display help and exit</td></tr>
   <tr><td></td>
   <td>--hidden</td>
-  <td>consider hidden changesets</td></tr>
+  <td>consider hidden changesets (default: off)</td></tr>
   <tr><td></td>
   <td>--pager TYPE</td>
   <td>when to paginate (boolean, always, auto, or never) (default: auto)</td></tr>
@@ -3094,7 +3094,7 @@
   <td>display help and exit</td></tr>
   <tr><td></td>
   <td>--hidden</td>
-  <td>consider hidden changesets</td></tr>
+  <td>consider hidden changesets (default: off)</td></tr>
   <tr><td></td>
   <td>--pager TYPE</td>
   <td>when to paginate (boolean, always, auto, or never) (default: auto)</td></tr>
--- a/tests/test-narrow-trackedcmd.t	Fri Dec 14 13:20:00 2018 -0800
+++ b/tests/test-narrow-trackedcmd.t	Fri Dec 14 13:33:12 2018 -0800
@@ -105,8 +105,9 @@
       --import-rules VALUE         import narrowspecs from a file
       --removeexclude VALUE [+]    old paths to no longer exclude
       --clear                      whether to replace the existing narrowspec
+                                   (default: off)
       --force-delete-local-changes forces deletion of local changes when
-                                   narrowing
+                                   narrowing (default: off)
    -e --ssh CMD                    specify ssh command to use
       --remotecmd CMD              specify hg command to run on the remote side
       --insecure                   do not verify server certificate (ignoring
--- a/tests/test-shelve.t	Fri Dec 14 13:20:00 2018 -0800
+++ b/tests/test-shelve.t	Fri Dec 14 13:33:12 2018 -0800
@@ -75,7 +75,7 @@
       --cleanup             delete all shelved changes
       --date DATE           shelve with the specified commit date
    -d --delete              delete the named shelved change(s)
-   -e --edit                invoke editor on commit messages
+   -e --edit                invoke editor on commit messages (default: off)
    -l --list                list current shelves
    -m --message TEXT        use text as shelve message
    -n --name NAME           use the given name for the shelved commit
--- a/tests/test-uncommit.t	Fri Dec 14 13:20:00 2018 -0800
+++ b/tests/test-uncommit.t	Fri Dec 14 13:33:12 2018 -0800
@@ -34,7 +34,8 @@
   
   options ([+] can be repeated):
   
-      --keep                allow an empty commit after uncommiting
+      --keep                allow an empty commit after uncommiting (default:
+                            off)
    -I --include PATTERN [+] include names matching the given patterns
    -X --exclude PATTERN [+] exclude names matching the given patterns