# HG changeset patch # User Martin von Zweigbergk # Date 2018-12-19 17:20:32 # Node ID fcc0a7ac9ebd0a1f97e593457470dd785f0b2151 # Parent e5d37558098a98105d661b94bc4f59804d70847e help: show "[no-]" only for default-on Flags As Anton (av6) pointed out, the "[no-]" is confusing for action flags like `hg bookmark --delete`. We could come up with a way of indicating which flags are action flags (e.g. use None for the default value instead of False). However, it's probably also unlikely that users will want to negate even non-action flags like --hidden. One of the more common flags where the "[no-]" prefix would be useful is `hg evolve --update`. The reason it's helpful there is that it defaults to on. So I think we can simply include "[no-]" only for flags that are on by default (and thus require the user to add the "[no-]" for the option to have any effect). Note that there are use cases for negating flags that already off by default. For example, you may have an alias for `hg log -G --hidden -T foo` and now want to pass "--no-hidden" to that alias. However, I think that users who want that are likely to be advanced enough that they've already learnt about the "no-" prefix by seeing it somewhere else. Differential Revision: https://phab.mercurial-scm.org/D5454 diff --git a/mercurial/help.py b/mercurial/help.py --- a/mercurial/help.py +++ b/mercurial/help.py @@ -160,7 +160,7 @@ def optrst(header, options, verbose): if shortopt: so = '-' + shortopt lo = '--' + longopt - if isinstance(default, bool): + if default is True: lo = '--[no-]' + longopt if isinstance(default, fancyopts.customopt): diff --git a/tests/test-extension.t b/tests/test-extension.t --- a/tests/test-extension.t +++ b/tests/test-extension.t @@ -716,7 +716,7 @@ hide outer repo --profile print command execution profile --version output version information and exit -h --help display help and exit - --[no-]hidden consider hidden changesets (default: off) + --hidden consider hidden changesets (default: off) --pager TYPE when to paginate (boolean, always, auto, or never) (default: auto) @@ -755,7 +755,7 @@ hide outer repo --profile print command execution profile --version output version information and exit -h --help display help and exit - --[no-]hidden consider hidden changesets (default: off) + --hidden consider hidden changesets (default: off) --pager TYPE when to paginate (boolean, always, auto, or never) (default: auto) @@ -1043,7 +1043,7 @@ extension help itself --profile print command execution profile --version output version information and exit -h --help display help and exit - --[no-]hidden consider hidden changesets (default: off) + --hidden consider hidden changesets (default: off) --pager TYPE when to paginate (boolean, always, auto, or never) (default: auto) @@ -1080,7 +1080,7 @@ Make sure that single '-v' option shows --profile print command execution profile --version output version information and exit -h --help display help and exit - --[no-]hidden consider hidden changesets (default: off) + --hidden consider hidden changesets (default: off) --pager TYPE when to paginate (boolean, always, auto, or never) (default: auto) @@ -1155,7 +1155,7 @@ help options '-v' and '-v -e' should be --profile print command execution profile --version output version information and exit -h --help display help and exit - --[no-]hidden consider hidden changesets (default: off) + --hidden consider hidden changesets (default: off) --pager TYPE when to paginate (boolean, always, auto, or never) (default: auto) @@ -1191,7 +1191,7 @@ help options '-v' and '-v -e' should be --profile print command execution profile --version output version information and exit -h --help display help and exit - --[no-]hidden consider hidden changesets (default: off) + --hidden consider hidden changesets (default: off) --pager TYPE when to paginate (boolean, always, auto, or never) (default: auto) diff --git a/tests/test-fix.t b/tests/test-fix.t --- a/tests/test-fix.t +++ b/tests/test-fix.t @@ -104,13 +104,12 @@ Help text for fix. options ([+] can be repeated): - --[no-]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 --[no-]working-dir fix the working directory (default: off) - --[no-]whole always fix every line of a file (default: off) + --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 (default: off) + --whole always fix every line of a file (default: off) (some details hidden, use --verbose to show complete help) diff --git a/tests/test-help.t b/tests/test-help.t --- a/tests/test-help.t +++ b/tests/test-help.t @@ -440,7 +440,7 @@ Test short command list with verbose opt --profile print command execution profile --version output version information and exit -h --help display help and exit - --[no-]hidden consider hidden changesets (default: off) + --hidden consider hidden changesets (default: off) --pager TYPE when to paginate (boolean, always, auto, or never) (default: auto) @@ -540,7 +540,7 @@ Verbose help for add --profile print command execution profile --version output version information and exit -h --help display help and exit - --[no-]hidden consider hidden changesets (default: off) + --hidden consider hidden changesets (default: off) --pager TYPE when to paginate (boolean, always, auto, or never) (default: auto) @@ -905,7 +905,7 @@ Test command with no help text xxxxxxxxxxxxxxxxxxxxxxx (default: 3) -n -- normal desc --newline VALUE line1 line2 - --[no-]default-off enable X (default: off) + --default-off enable X (default: off) --[no-]default-on enable Y (default: on) --callableopt VALUE adds foo --customopt VALUE adds bar @@ -2889,7 +2889,7 @@ Dish up an empty repo; serve it cold. --help display help and exit - --[no-]hidden + --hidden consider hidden changesets (default: off) --pager TYPE @@ -3093,7 +3093,7 @@ Dish up an empty repo; serve it cold. --help display help and exit - --[no-]hidden + --hidden consider hidden changesets (default: off) --pager TYPE diff --git a/tests/test-narrow-trackedcmd.t b/tests/test-narrow-trackedcmd.t --- a/tests/test-narrow-trackedcmd.t +++ b/tests/test-narrow-trackedcmd.t @@ -99,20 +99,19 @@ Testing the --import-rules flag of `hg t options ([+] can be repeated): - --addinclude VALUE [+] new paths to include - --removeinclude VALUE [+] old paths to no longer include - --addexclude VALUE [+] new paths to exclude - --import-rules VALUE import narrowspecs from a file - --removeexclude VALUE [+] old paths to no longer exclude - --[no-]clear whether to replace the existing - narrowspec (default: off) - --[no-]force-delete-local-changes forces deletion of local changes when - 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 web.cacerts config) + --addinclude VALUE [+] new paths to include + --removeinclude VALUE [+] old paths to no longer include + --addexclude VALUE [+] new paths to exclude + --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 (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 + web.cacerts config) (use 'hg tracked -h' to show more help) [255] diff --git a/tests/test-shelve.t b/tests/test-shelve.t --- a/tests/test-shelve.t +++ b/tests/test-shelve.t @@ -75,7 +75,7 @@ shelve has a help message --cleanup delete all shelved changes --date DATE shelve with the specified commit date -d --delete delete the named shelved change(s) - -e --[no-]edit invoke editor on commit messages (default: off) + -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 diff --git a/tests/test-uncommit.t b/tests/test-uncommit.t --- a/tests/test-uncommit.t +++ b/tests/test-uncommit.t @@ -34,7 +34,7 @@ Help for uncommit options ([+] can be repeated): - --[no-]keep allow an empty commit after uncommiting (default: + --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