Re: [PATCH 8 of 8 v2] help: mark boolean flags with a ^ and explain that they can be negated (RFC)

2016-09-06 Thread Pierre-Yves David



On 08/31/2016 07:10 PM, Augie Fackler wrote:

On Wed, Aug 31, 2016 at 12:13 PM, Matt Mackall  wrote:

On Tue, 2016-08-30 at 16:16 -0400, Augie Fackler wrote:

# HG changeset patch
# User Augie Fackler 
# Date 147258 14400
#  Tue Aug 30 15:14:04 2016 -0400
# Node ID 5efc13a760938ff5fd8e4553dd8e06d06b98025b
# Parent  fd68fb86c29873eb32c4a2bd28f7ac0abe3dc172
help: mark boolean flags with a ^ and explain that they can be negated (RFC)




 options ([+] can be repeated, flags marked ^ can be negated with --no-):


I like the general idea.


The format here is a bit inconsistent. Perhaps:

  options ([+] can be repeated, [?] are flags):


What  about [&], "?" is a bit confusing to me as we often use it for 
optional/extend help thingy. "&" is often related to boolean/bit 
operation and seems to fit here.



I think actually sticking ^ on the option name itself is a little bizarre and
might lead to some minor confusion.

Also, we should probably figure out a way to have aliases for some of these
options so we can fully normalize the scheme. Consider:


+   -y --noninteractive^   do not prompt, automatically pick the first choice


Having --no-noninteractive seems really sad. We could make --noninteractive
hidden and then advertise --no-interactive as the long version.

Also, I don't think --no-no-backup is a good idea. --backup should be its
negation.


These cases are a bit problematic, because we don't really have a way
to specify default-true flags. Would it be good enough to blacklist
anything that starts with no- and noninteractive for now?


Can you elaborate on this. I saw your changeset making it forbiden as a 
default value (because it was silly) but is seems like we found 
non-silly usecase. Is there a technical reason why we don't want default 
value to True?




+  --version^  output version information and exit
+   -h --help^ display help and exit


Wat. That's maybe a little too generalized.


Heh. Yeah. I can blacklist specific flags, I guess.


If this is a common issue, we could consider using some special marker 
(or special default value) in the option definition. But the list will 
probably be short and that won't be worth the trouble.


--
Pierre-Yves David
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


Re: [PATCH 8 of 8 v2] help: mark boolean flags with a ^ and explain that they can be negated (RFC)

2016-09-01 Thread Matt Mackall
On Wed, 2016-08-31 at 13:10 -0400, Augie Fackler wrote:
> On Wed, Aug 31, 2016 at 12:13 PM, Matt Mackall  wrote:
> > 
> > On Tue, 2016-08-30 at 16:16 -0400, Augie Fackler wrote:
> > > 
> > > # HG changeset patch
> > > # User Augie Fackler 
> > > # Date 147258 14400
> > > #  Tue Aug 30 15:14:04 2016 -0400
> > > # Node ID 5efc13a760938ff5fd8e4553dd8e06d06b98025b
> > > # Parent  fd68fb86c29873eb32c4a2bd28f7ac0abe3dc172
> > > help: mark boolean flags with a ^ and explain that they can be negated
> > > (RFC)
> > 
> > > 
> > >  options ([+] can be repeated, flags marked ^ can be negated with --no-):
> > The format here is a bit inconsistent. Perhaps:
> > 
> >   options ([+] can be repeated, [?] are flags):
> > 
> > I think actually sticking ^ on the option name itself is a little bizarre
> > and
> > might lead to some minor confusion.
> > 
> > Also, we should probably figure out a way to have aliases for some of these
> > options so we can fully normalize the scheme. Consider:
> > 
> > > 
> > > +   -y --noninteractive^   do not prompt, automatically pick the first
> > > choice
> > Having --no-noninteractive seems really sad. We could make --noninteractive
> > hidden and then advertise --no-interactive as the long version.
> > 
> > Also, I don't think --no-no-backup is a good idea. --backup should be its
> > negation.
> These cases are a bit problematic, because we don't really have a way
> to specify default-true flags.

I was thinking --no-backup would be detected as an inverse. So the parser would
synthesize a --backup option and if it was used bare, opts["no_backup"] would be
set to False rather than None. Maybe that's too convoluted though.

>  Would it be good enough to blacklist
> anything that starts with no- and noninteractive for now?

Yep. Though it's a bit of a shame for fancyopts to acquire such knowledge.

-- 
Mathematics is the supreme nostalgia of our time.

___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


Re: [PATCH 8 of 8 v2] help: mark boolean flags with a ^ and explain that they can be negated (RFC)

2016-08-31 Thread timeless
>   options ([+] can be repeated, [?] are flags):

This is closer to how I was envisioning it.

> Having --no-noninteractive seems really sad. We could make --noninteractive
> hidden and then advertise --no-interactive as the long version.

Agreed

> Also, I don't think --no-no-backup is a good idea. --backup should be its
> negation.

Agreed
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


Re: [PATCH 8 of 8 v2] help: mark boolean flags with a ^ and explain that they can be negated (RFC)

2016-08-30 Thread timeless
In principle you shouldn't use multi occur to guard this.

 if multioccur:
-header += (_(" ([+] can be repeated)"))
+m = _(
+" ([+] can be repeated, flags marked ^ can be negated with
--no-)")
+header += (m)

It's too hard for me you write the correct logic (you can use a set and
dictionary).
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


[PATCH 8 of 8 v2] help: mark boolean flags with a ^ and explain that they can be negated (RFC)

2016-08-30 Thread Augie Fackler
# HG changeset patch
# User Augie Fackler 
# Date 147258 14400
#  Tue Aug 30 15:14:04 2016 -0400
# Node ID 5efc13a760938ff5fd8e4553dd8e06d06b98025b
# Parent  fd68fb86c29873eb32c4a2bd28f7ac0abe3dc172
help: mark boolean flags with a ^ and explain that they can be negated (RFC)

This patch is an RFC - it does not update test expectations other than
in one file so the changes can be bikeshod. I'm not really in love
with this solution, but I don't have anything better either (credit
and/or blame for this idea actually goes to timeless.)

diff --git a/mercurial/help.py b/mercurial/help.py
--- a/mercurial/help.py
+++ b/mercurial/help.py
@@ -87,11 +87,16 @@ def optrst(header, options, verbose):
 multioccur = True
 elif (default is not None) and not isinstance(default, bool):
 lo += " %s" % optlabel
+else:
+lo += '^'
+multioccur = True
 
 data.append((so, lo, desc))
 
 if multioccur:
-header += (_(" ([+] can be repeated)"))
+m = _(
+" ([+] can be repeated, flags marked ^ can be negated with --no-)")
+header += (m)
 
 rst = ['\n%s:\n\n' % header]
 rst.extend(minirst.maketable(data, 1))
diff --git a/tests/test-help.t b/tests/test-help.t
--- a/tests/test-help.t
+++ b/tests/test-help.t
@@ -311,26 +311,27 @@ Test short command list with verbose opt
update, up, checkout, co
  update working directory (or switch revisions)
   
-  global options ([+] can be repeated):
+  global options ([+] can be repeated, flags marked ^ can be negated with
+  --no-):
   
-R --repository REPO   repository root directory or name of overlay bundle
   file
   --cwd DIR   change working directory
-   -y --noninteractivedo not prompt, automatically pick the first choice 
for
+   -y --noninteractive^   do not prompt, automatically pick the first choice 
for
   all prompts
-   -q --quiet suppress output
-   -v --verbose   enable additional output
+   -q --quiet^suppress output
+   -v --verbose^  enable additional output
   --config CONFIG [+] set/override config option (use 'section.name=value')
-  --debug enable debugging output
-  --debugger  start debugger
+  --debug^enable debugging output
+  --debugger^ start debugger
   --encoding ENCODE   set the charset encoding (default: ascii)
   --encodingmode MODE set the charset encoding mode (default: strict)
-  --traceback always print a traceback on exception
-  --time  time how long the command takes
-  --profile   print command execution profile
-  --version   output version information and exit
-   -h --help  display help and exit
-  --hiddenconsider hidden changesets
+  --traceback^always print a traceback on exception
+  --time^ time how long the command takes
+  --profile^  print command execution profile
+  --version^  output version information and exit
+   -h --help^ display help and exit
+  --hidden^   consider hidden changesets
   
   (use "hg help" for the full list of commands)
 
@@ -349,12 +350,12 @@ Test short command list with verbose opt
   
   Returns 0 if all files are successfully added.
   
-  options ([+] can be repeated):
+  options ([+] can be repeated, flags marked ^ can be negated with --no-):
   
-I --include PATTERN [+] include names matching the given patterns
-X --exclude PATTERN [+] exclude names matching the given patterns
-   -S --subreposrecurse into subrepositories
-   -n --dry-run do not perform actions, just print output
+   -S --subrepos^   recurse into subrepositories
+   -n --dry-run^do not perform actions, just print output
   
   (some details hidden, use --verbose to show complete help)
 
@@ -400,33 +401,34 @@ Verbose help for add
   
   Returns 0 if all files are successfully added.
   
-  options ([+] can be repeated):
+  options ([+] can be repeated, flags marked ^ can be negated with --no-):
   
-I --include PATTERN [+] include names matching the given patterns
-X --exclude PATTERN [+] exclude names matching the given patterns
-   -S --subreposrecurse into subrepositories
-   -n --dry-run do not perform actions, just print output
-  
-  global options ([+] can be repeated):
+   -S --subrepos^   recurse into subrepositories
+   -n --dry-run^do not perform actions, just print output
+  
+  global options ([+] can be repeated, flags marked ^ can be negated with
+  --no-):
   
-R --repository REPO   repository root directory or name of overlay bundle
   file
   --cwd DIR   change working directory
-   -y