D224: build: Delaying version computation on macOS builds.

2017-08-03 Thread rdamazio (Rodrigo Damazio Bovendorp)
rdamazio added a comment.


  Updated description

REPOSITORY
  rHG Mercurial

REVISION DETAIL
  https://phab.mercurial-scm.org/D224

To: rdamazio, #hg-reviewers
Cc: martinvonz, mercurial-devel
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


D224: build: Allow Makefile to be recursively invoked on MacOS X

2017-08-03 Thread rdamazio (Rodrigo Damazio Bovendorp)
rdamazio created this revision.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.

REVISION SUMMARY
  The way HGVER is evaluated now, it'll be evaluated at the beginning of the
  make execution - with this change, it's evaluated when it gets to that 
command,
  which will ensure it's always run at the right directory.

REPOSITORY
  rHG Mercurial

REVISION DETAIL
  https://phab.mercurial-scm.org/D224

AFFECTED FILES
  Makefile

CHANGE DETAILS

diff --git a/Makefile b/Makefile
--- a/Makefile
+++ b/Makefile
@@ -186,7 +186,7 @@
  PREFIX=/usr/local \
  clean install
mkdir -p $${OUTPUTDIR:-dist}
-   HGVER=$(shell python contrib/genosxversion.py $(OSXVERSIONFLAGS) 
build/mercurial/Library/Python/2.7/site-packages/mercurial/__version__.py ) && \
+   HGVER=$$(shell python contrib/genosxversion.py $(OSXVERSIONFLAGS) 
build/mercurial/Library/Python/2.7/site-packages/mercurial/__version__.py ) && \
OSXVER=$$(sw_vers -productVersion | cut -d. -f1,2) && \
pkgbuild --filter \\.DS_Store --root build/mercurial/ \
  --identifier org.mercurial-scm.mercurial \



To: rdamazio, #hg-reviewers
Cc: mercurial-devel
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


D224: build: Delaying version computation on macOS builds.

2017-08-04 Thread rdamazio (Rodrigo Damazio Bovendorp)
This revision was automatically updated to reflect the committed changes.
Closed by commit rHGf22513c3717d: build: Delaying version computation on macOS 
builds. (authored by rdamazio).

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D224?vs=530=547

REVISION DETAIL
  https://phab.mercurial-scm.org/D224

AFFECTED FILES
  Makefile

CHANGE DETAILS

diff --git a/Makefile b/Makefile
--- a/Makefile
+++ b/Makefile
@@ -186,7 +186,7 @@
  PREFIX=/usr/local \
  clean install
mkdir -p $${OUTPUTDIR:-dist}
-   HGVER=$(shell python contrib/genosxversion.py $(OSXVERSIONFLAGS) 
build/mercurial/Library/Python/2.7/site-packages/mercurial/__version__.py ) && \
+   HGVER=$$(shell python contrib/genosxversion.py $(OSXVERSIONFLAGS) 
build/mercurial/Library/Python/2.7/site-packages/mercurial/__version__.py ) && \
OSXVER=$$(sw_vers -productVersion | cut -d. -f1,2) && \
pkgbuild --filter \\.DS_Store --root build/mercurial/ \
  --identifier org.mercurial-scm.mercurial \



To: rdamazio, #hg-reviewers, martinvonz
Cc: martinvonz, mercurial-devel
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


D1270: help: adding a topic on flags

2017-11-13 Thread rdamazio (Rodrigo Damazio Bovendorp)
This revision was automatically updated to reflect the committed changes.
Closed by commit rHGb0262b25ab48: help: adding a topic on flags (authored by 
rdamazio, committed by ).

CHANGED PRIOR TO COMMIT
  https://phab.mercurial-scm.org/D1270?vs=3359=3445#toc

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D1270?vs=3359=3445

REVISION DETAIL
  https://phab.mercurial-scm.org/D1270

AFFECTED FILES
  contrib/wix/help.wxs
  mercurial/help.py
  mercurial/help/flags.txt
  tests/test-globalopts.t
  tests/test-help.t
  tests/test-hgweb-json.t

CHANGE DETAILS

diff --git a/tests/test-hgweb-json.t b/tests/test-hgweb-json.t
--- a/tests/test-hgweb-json.t
+++ b/tests/test-hgweb-json.t
@@ -1581,6 +1581,10 @@
 "topic": "filesets"
   },
   {
+"summary": "Command-line flags",
+"topic": "flags"
+  },
+  {
 "summary": "Glossary",
 "topic": "glossary"
   },
diff --git a/tests/test-help.t b/tests/test-help.t
--- a/tests/test-help.t
+++ b/tests/test-help.t
@@ -110,6 +110,7 @@
environment   Environment Variables
extensionsUsing Additional Features
filesets  Specifying File Sets
+   flags Command-line flags
glossary  Glossary
hgignore  Syntax for Mercurial Ignore Files
hgweb Configuring hgweb
@@ -188,6 +189,7 @@
environment   Environment Variables
extensionsUsing Additional Features
filesets  Specifying File Sets
+   flags Command-line flags
glossary  Glossary
hgignore  Syntax for Mercurial Ignore Files
hgweb Configuring hgweb
@@ -865,6 +867,7 @@
environment   Environment Variables
extensionsUsing Additional Features
filesets  Specifying File Sets
+   flags Command-line flags
glossary  Glossary
hgignore  Syntax for Mercurial Ignore Files
hgweb Configuring hgweb
@@ -2013,6 +2016,13 @@
   Specifying File Sets
   
   
+  
+  flags
+  
+  
+  Command-line flags
+  
+  
   
   glossary
   
diff --git a/tests/test-globalopts.t b/tests/test-globalopts.t
--- a/tests/test-globalopts.t
+++ b/tests/test-globalopts.t
@@ -355,6 +355,7 @@
environment   Environment Variables
extensionsUsing Additional Features
filesets  Specifying File Sets
+   flags Command-line flags
glossary  Glossary
hgignore  Syntax for Mercurial Ignore Files
hgweb Configuring hgweb
@@ -439,6 +440,7 @@
environment   Environment Variables
extensionsUsing Additional Features
filesets  Specifying File Sets
+   flags Command-line flags
glossary  Glossary
hgignore  Syntax for Mercurial Ignore Files
hgweb Configuring hgweb
diff --git a/mercurial/help/flags.txt b/mercurial/help/flags.txt
new file mode 100644
--- /dev/null
+++ b/mercurial/help/flags.txt
@@ -0,0 +1,104 @@
+Most Mercurial commands accept various flags.
+
+Flag names
+==
+
+Flags for each command are listed in :hg:`help` for that command.
+Additionally, some flags, such as --repository, are global and can be used with
+any command - those are seen in :hg:`help -v`, and can be specified before or
+after the command.
+
+Every flag has at least a long name, such as --repository. Some flags may also
+have a short one-letter name, such as the equivalent -R. Using the short or 
long
+name is equivalent and has the same effect.
+
+Flags that have a short name can also be bundled together - for instance, to
+specify both --edit (short -e) and --interactive (short -i), one could use::
+
+hg commit -ei
+
+If any of the bundled flags takes a value (i.e. is not a boolean), it must be
+last, followed by the value::
+
+hg commit -im 'Message'
+
+Flag types
+==
+
+Mercurial command-line flags can be strings, numbers, booleans, or lists of
+strings.
+
+Specifying flag values
+==
+
+The following syntaxes are allowed, assuming a flag 'flagname' with short name
+'f'::
+
+--flagname=foo
+--flagname foo
+-f foo
+-ffoo
+
+This syntax applies to all non-boolean flags (strings, numbers or lists).
+
+Specifying boolean flags
+
+
+Boolean flags do not take a value parameter. To specify a boolean, use the flag
+name to set it to true, or the same name prefixed with 'no-' to set it to
+false::
+
+hg commit --interactive
+hg commit --no-interactive
+
+Specifying list flags
+=
+
+List flags take multiple values. To specify them, pass the flag multiple 
times::
+
+hg files --include mercurial --include tests
+
+Setting flag defaults
+=
+
+In order to set a default value for a flag in an hgrc file, it is recommended 
to
+use aliases::
+
+[alias]
+commit = commit --interactive
+
+For more information on hgrc files, see :hg:`help config`.
+
+Overriding flags on the command line
+
+
+If the same 

D1270: help: adding a topic on flags

2017-11-09 Thread rdamazio (Rodrigo Damazio Bovendorp)
rdamazio marked 4 inline comments as done.
rdamazio added inline comments.

INLINE COMMENTS

> martinvonz wrote in flags.txt:67
> Do we recommend overriding the command like this or should the left side be 
> called something else (maybe "icommit")? I really don't know what we 
> recommend here, so don't take my question to imply that you shouldn't do it 
> the way you have done it.

That's my interpretation of what "hg help commit" says, but if you want me to 
change it let me know.

REPOSITORY
  rHG Mercurial

REVISION DETAIL
  https://phab.mercurial-scm.org/D1270

To: rdamazio, #hg-reviewers
Cc: av6, dlax, martinvonz, mercurial-devel
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


D1270: help: adding a topic on flags

2017-11-09 Thread rdamazio (Rodrigo Damazio Bovendorp)
rdamazio updated this revision to Diff 3359.
rdamazio marked 4 inline comments as done.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D1270?vs=3334=3359

REVISION DETAIL
  https://phab.mercurial-scm.org/D1270

AFFECTED FILES
  contrib/wix/help.wxs
  mercurial/help.py
  mercurial/help/flags.txt
  tests/test-globalopts.t
  tests/test-help.t
  tests/test-hgweb-json.t

CHANGE DETAILS

diff --git a/tests/test-hgweb-json.t b/tests/test-hgweb-json.t
--- a/tests/test-hgweb-json.t
+++ b/tests/test-hgweb-json.t
@@ -1581,6 +1581,10 @@
 "topic": "filesets"
   },
   {
+"summary": "Command-line flags",
+"topic": "flags"
+  },
+  {
 "summary": "Glossary",
 "topic": "glossary"
   },
diff --git a/tests/test-help.t b/tests/test-help.t
--- a/tests/test-help.t
+++ b/tests/test-help.t
@@ -110,6 +110,7 @@
environment   Environment Variables
extensionsUsing Additional Features
filesets  Specifying File Sets
+   flags Command-line flags
glossary  Glossary
hgignore  Syntax for Mercurial Ignore Files
hgweb Configuring hgweb
@@ -188,6 +189,7 @@
environment   Environment Variables
extensionsUsing Additional Features
filesets  Specifying File Sets
+   flags Command-line flags
glossary  Glossary
hgignore  Syntax for Mercurial Ignore Files
hgweb Configuring hgweb
@@ -865,6 +867,7 @@
environment   Environment Variables
extensionsUsing Additional Features
filesets  Specifying File Sets
+   flags Command-line flags
glossary  Glossary
hgignore  Syntax for Mercurial Ignore Files
hgweb Configuring hgweb
@@ -2013,6 +2016,13 @@
   Specifying File Sets
   
   
+  
+  flags
+  
+  
+  Command-line flags
+  
+  
   
   glossary
   
diff --git a/tests/test-globalopts.t b/tests/test-globalopts.t
--- a/tests/test-globalopts.t
+++ b/tests/test-globalopts.t
@@ -355,6 +355,7 @@
environment   Environment Variables
extensionsUsing Additional Features
filesets  Specifying File Sets
+   flags Command-line flags
glossary  Glossary
hgignore  Syntax for Mercurial Ignore Files
hgweb Configuring hgweb
@@ -439,6 +440,7 @@
environment   Environment Variables
extensionsUsing Additional Features
filesets  Specifying File Sets
+   flags Command-line flags
glossary  Glossary
hgignore  Syntax for Mercurial Ignore Files
hgweb Configuring hgweb
diff --git a/mercurial/help/flags.txt b/mercurial/help/flags.txt
new file mode 100644
--- /dev/null
+++ b/mercurial/help/flags.txt
@@ -0,0 +1,107 @@
+Most Mercurial commands accept various flags.
+
+Flag names
+==
+
+Flags for each command are listed in :hg:`help` for that command.
+Additionally, some flags, such as --repository, are global and can be used with
+any command - those are seen in :hg:`help -v`, and can be specified before or
+after the command.
+
+Every flag has at least a long name, such as --repository. Some flags may also
+have a short one-letter name, such as the equivalent -R. Using the short or 
long
+name is equivalent and has the same effect.
+
+Flags that have a short name can also be bundled together - for instance, to
+specify both --edit (short -e) and --interactive (short -i), one could use::
+
+hg commit -ei
+
+If any of the bundled flags takes a value (i.e. is not a boolean), it must be
+last, followed by the value::
+
+hg commit -im 'Message'
+
+Flag types
+==
+
+Mercurial command-line flags can be strings, numbers, booleans, or lists of
+strings.
+
+Specifying flag values
+==
+
+The following syntaxes are allowed, assuming a flag 'flagname' with short name
+'f'::
+
+--flagname=foo
+--flagname foo
+-f=foo
+-f foo
+-ffoo
+
+This syntax applies to all non-boolean flags (strings, numbers or lists).
+
+Specifying boolean flags
+
+
+Boolean flags do not take a value parameter. To specify a boolean, use the flag
+name to set it to true, or the same name prefixed with 'no-' to set it to
+false::
+
+hg commit --interactive
+hg commit --no-interactive
+
+Specifying list flags
+=
+
+List flags take multiple values. To specify them, pass the flag multiple 
times::
+
+hg files --include mercurial --include tests
+
+Setting flag defaults
+=
+
+In order to set a default value for a flag in an hgrc file, it is recommended 
to
+use aliases::
+
+[alias]
+commit = commit --interactive
+
+For more information on hgrc files, see :hg:`help config`.
+
+Overriding flags on the command line
+
+
+If the same non-list flag is specified multiple times on the command line, the
+latest specification is used::
+
+hg commit -m "Ignored value" -m "Used value"
+
+This 

D1270: help: adding a topic on flags

2017-11-08 Thread rdamazio (Rodrigo Damazio Bovendorp)
rdamazio added a comment.


  In https://phab.mercurial-scm.org/D1270#21058, @martinvonz wrote:
  
  > We're in code freeze for approximately two more days, so this will have to 
wait until ~Thursday. Still, thanks for the patch. I'm happy to include 
something like this. Things that struck me as missing:
  >
  > 1. Long vs short form (that e.g. "--verbose" and "-v" are equivalent if the 
refer to the same flag, which they do)
  > 2. Non-list, non-boolean flags that take arguments, such as "--rev", and 
that "--rev=tip", "--rev tip", "-r=tip", "-r tip", and "-rtip" are equivalent
  > 3. Short flags can be combined: "-pvr tip" is valid
  > 4. Later flags override earlier flags
  >
  >   We don't necessarily have to include all that in the first patch.
  
  
  Tried to address all of these.

INLINE COMMENTS

> av6 wrote in flags.txt:7
> This "lists of strings" caught my attention, but it took me some time to 
> figure out what's the matter. I don't feel strongly, but here are some points:
> 
> 1. it's not clear what a "list of strings" is and how to specify it: is it a 
> comma-separated list?
> 2. it's not a type that //one// command-line flag can take (i.e. no 
> `--flag=foo,bar` or anything), you must use multiple flags on command line to 
> build this list, so it's unlike the 3 previous types
> 3. I don't think we have anywhere (in the code) a list of integers or 
> booleans right now, but nothing prevents this in future, or in an extension
> 
> I think this data type is a result of looking at the internals that allow 
> some python variables (associated with handling command line flags in the 
> code) to be lists, but because our CLI is not python, this phrase is more 
> distracting than helpful. I think taking the note that's in `hg help` and 
> explaining it is better: "[+] can be repeated" (essentially merging 
> "​Specifying list flags" and "Overriding flag defaults").

That's the whole point of the "Specifying list flags" section below, and in 
fact what motivated me to send this patch.
I don't think the code supports parsing a list as numbers or booleans, right 
now.

> av6 wrote in flags.txt:35
> This is a weird-looking macro. Does it work when rendered into e.g. HTML (can 
> be seen hgweb)? I've only seen this format:
> 
>   :hg:`help config`

Assume that I don't know what I'm doing, as far as the format of this file is 
concerned :) I just tried hgweb and fixed a few things.

> av6 wrote in flags.txt:49
> There are also global flags, they are hidden by default too. I guess you can 
> put them into these 3 categories, but I don't think of --quiet or --verbose 
> as advanced (much less experimental or deprecated). Just a nitpick.

--verbose is used to show those flags in hg help, it's not that that flag 
itself is advanced.

REPOSITORY
  rHG Mercurial

REVISION DETAIL
  https://phab.mercurial-scm.org/D1270

To: rdamazio, #hg-reviewers
Cc: av6, dlax, martinvonz, mercurial-devel
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


D1270: help: adding a topic on flags

2017-11-08 Thread rdamazio (Rodrigo Damazio Bovendorp)
rdamazio updated this revision to Diff 3334.
rdamazio marked 4 inline comments as done.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D1270?vs=3168=3334

REVISION DETAIL
  https://phab.mercurial-scm.org/D1270

AFFECTED FILES
  contrib/wix/help.wxs
  mercurial/help.py
  mercurial/help/flags.txt
  tests/test-globalopts.t
  tests/test-help.t
  tests/test-hgweb-json.t

CHANGE DETAILS

diff --git a/tests/test-hgweb-json.t b/tests/test-hgweb-json.t
--- a/tests/test-hgweb-json.t
+++ b/tests/test-hgweb-json.t
@@ -1581,6 +1581,10 @@
 "topic": "filesets"
   },
   {
+"summary": "Command-line flags",
+"topic": "flags"
+  },
+  {
 "summary": "Glossary",
 "topic": "glossary"
   },
diff --git a/tests/test-help.t b/tests/test-help.t
--- a/tests/test-help.t
+++ b/tests/test-help.t
@@ -110,6 +110,7 @@
environment   Environment Variables
extensionsUsing Additional Features
filesets  Specifying File Sets
+   flags Command-line flags
glossary  Glossary
hgignore  Syntax for Mercurial Ignore Files
hgweb Configuring hgweb
@@ -188,6 +189,7 @@
environment   Environment Variables
extensionsUsing Additional Features
filesets  Specifying File Sets
+   flags Command-line flags
glossary  Glossary
hgignore  Syntax for Mercurial Ignore Files
hgweb Configuring hgweb
@@ -865,6 +867,7 @@
environment   Environment Variables
extensionsUsing Additional Features
filesets  Specifying File Sets
+   flags Command-line flags
glossary  Glossary
hgignore  Syntax for Mercurial Ignore Files
hgweb Configuring hgweb
@@ -2013,6 +2016,13 @@
   Specifying File Sets
   
   
+  
+  flags
+  
+  
+  Command-line flags
+  
+  
   
   glossary
   
diff --git a/tests/test-globalopts.t b/tests/test-globalopts.t
--- a/tests/test-globalopts.t
+++ b/tests/test-globalopts.t
@@ -355,6 +355,7 @@
environment   Environment Variables
extensionsUsing Additional Features
filesets  Specifying File Sets
+   flags Command-line flags
glossary  Glossary
hgignore  Syntax for Mercurial Ignore Files
hgweb Configuring hgweb
@@ -439,6 +440,7 @@
environment   Environment Variables
extensionsUsing Additional Features
filesets  Specifying File Sets
+   flags Command-line flags
glossary  Glossary
hgignore  Syntax for Mercurial Ignore Files
hgweb Configuring hgweb
diff --git a/mercurial/help/flags.txt b/mercurial/help/flags.txt
new file mode 100644
--- /dev/null
+++ b/mercurial/help/flags.txt
@@ -0,0 +1,105 @@
+Most Mercurial commands accept various flags.
+
+Flag names
+==
+
+Flags for each command are listed in :hg:`help` for that command.
+Additionally, some flags, such as --repository, are global and can be used with
+any command - those are seen in :hg:`help -v`, and can be specified.
+
+Every flag has at least a long name, such as --repository. Some flags may also
+have a short one-letter name, such as the equivalent -R. Using the short or 
long
+name is equivalent and has the same effect.
+
+Flags that have a short name can also be bundled together - for instance, to
+specify both --edit (short -e) and --interactive (short -i), one could use::
+
+hg commit -ei
+
+If any of the bundled flags takes a value (i.e. is not a boolean), it must be
+last, followed by the value::
+
+hg commit -im 'Message'
+
+Flag types
+==
+
+Mercurial command-line flags can be strings, numbers, booleans, or lists of
+strings.
+
+Specifying flag values
+==
+
+The following syntaxes are allowed, assuming a flag 'flagname' with short name
+'f'::
+
+--flagname=foo
+--flagname foo
+-f=foo
+-f foo
+
+This syntax applies to all non-boolean flags (strings, numbers or lists).
+
+Specifying boolean flags
+
+
+Boolean flags do not take a value parameter. To specify a boolean, use the flag
+name to set it to true, or the same name prefixed with 'no-' to set it to
+false::
+
+hg commit --interactive
+hg commit --no-interactive
+
+Specifying list flags
+=
+
+List flags take multiple values. To specify them, pass the flag multiple 
times::
+
+hg files --include mercurial --include tests
+
+Setting flag defaults
+=
+
+In order to set a default value for a flag in an hgrc file, it is recommended 
to
+use aliases::
+
+[alias]
+commit = commit --interactive
+
+For more information on hgrc files, see :hg:`help config`.
+
+Overriding flags on the command line
+
+
+If the same non-list flag is specified multiple times on the command line, the
+latest specification is used::
+
+hg commit -m "Ignored value" -m "Used value"
+
+This includes the use of aliases - e.g., if one 

D1270: help: adding a topic on flags

2017-10-30 Thread rdamazio (Rodrigo Damazio Bovendorp)
rdamazio created this revision.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.

REVISION SUMMARY
  This is a short topic to explain how command-line flags can be specified.
  
  Some users have been confused by hg offerring different flag syntax than some
  other libraries, so it'd be nice to point them to this rather than explaining
  it every time.

REPOSITORY
  rHG Mercurial

REVISION DETAIL
  https://phab.mercurial-scm.org/D1270

AFFECTED FILES
  contrib/wix/help.wxs
  mercurial/help.py
  mercurial/help/flags.txt
  tests/test-globalopts.t
  tests/test-help.t
  tests/test-hgweb-json.t

CHANGE DETAILS

diff --git a/tests/test-hgweb-json.t b/tests/test-hgweb-json.t
--- a/tests/test-hgweb-json.t
+++ b/tests/test-hgweb-json.t
@@ -1581,6 +1581,10 @@
 "topic": "filesets"
   },
   {
+"summary": "Command-line flags",
+"topic": "flags"
+  },
+  {
 "summary": "Glossary",
 "topic": "glossary"
   },
diff --git a/tests/test-help.t b/tests/test-help.t
--- a/tests/test-help.t
+++ b/tests/test-help.t
@@ -110,6 +110,7 @@
environment   Environment Variables
extensionsUsing Additional Features
filesets  Specifying File Sets
+   flags Command-line flags
glossary  Glossary
hgignore  Syntax for Mercurial Ignore Files
hgweb Configuring hgweb
@@ -188,6 +189,7 @@
environment   Environment Variables
extensionsUsing Additional Features
filesets  Specifying File Sets
+   flags Command-line flags
glossary  Glossary
hgignore  Syntax for Mercurial Ignore Files
hgweb Configuring hgweb
@@ -865,6 +867,7 @@
environment   Environment Variables
extensionsUsing Additional Features
filesets  Specifying File Sets
+   flags Command-line flags
glossary  Glossary
hgignore  Syntax for Mercurial Ignore Files
hgweb Configuring hgweb
@@ -2010,6 +2013,13 @@
   Specifying File Sets
   
   
+  
+  flags
+  
+  
+  Command-line flags
+  
+  
   
   glossary
   
diff --git a/tests/test-globalopts.t b/tests/test-globalopts.t
--- a/tests/test-globalopts.t
+++ b/tests/test-globalopts.t
@@ -355,6 +355,7 @@
environment   Environment Variables
extensionsUsing Additional Features
filesets  Specifying File Sets
+   flags Command-line flags
glossary  Glossary
hgignore  Syntax for Mercurial Ignore Files
hgweb Configuring hgweb
@@ -439,6 +440,7 @@
environment   Environment Variables
extensionsUsing Additional Features
filesets  Specifying File Sets
+   flags Command-line flags
glossary  Glossary
hgignore  Syntax for Mercurial Ignore Files
hgweb Configuring hgweb
diff --git a/mercurial/help/flags.txt b/mercurial/help/flags.txt
new file mode 100644
--- /dev/null
+++ b/mercurial/help/flags.txt
@@ -0,0 +1,53 @@
+Most Mercurial commands accept various flags.
+
+Flag types
+==
+
+Mercurial command-line flags can be strings, numbers, booleans, or lists of
+strings.
+
+Specifying boolean flags
+
+
+Boolean flags do not take a value parameter. To specify a boolean, use the flag
+name to set it to true, or the same name prefixed with 'no-' to set it to
+false::
+
+hg commit --interactive
+hg commit --no-interactive
+
+Specifying list flags
+=
+
+List flags take multiple values. To specify them, pass the flag multiple 
times::
+
+hg files --include mercurial --include tests
+
+Setting flag defaults
+=
+
+In order to set a default value for a flag in an hgrc file, set it under the
+[defaults] section of the hgrc file::
+
+[defaults]
+commit = --interactive
+
+For more information on hgrc files, see :hg:help:config.
+
+Overriding flag defaults
+
+
+Every flag has a default value, and you may also set your own defaults in hgrc
+as described above.
+Except for list flags, defaults can be overridden on the command line simplify
+by specifying the flag in that location.
+
+Hidden flags
+
+
+Some flags are not shown in a command's help by default - specifically, those
+that are deemed to be experimental, deprecated or advanced. To show all flags,
+add the --verbose flag for the help command::
+
+hg help --verbose commit
+
diff --git a/mercurial/help.py b/mercurial/help.py
--- a/mercurial/help.py
+++ b/mercurial/help.py
@@ -224,6 +224,7 @@
 (['color'], _("Colorizing Outputs"), loaddoc('color')),
 (["config", "hgrc"], _("Configuration Files"), loaddoc('config')),
 (["dates"], _("Date Formats"), loaddoc('dates')),
+(["flags"], _("Command-line flags"), loaddoc('flags')),
 (["patterns"], _("File Name Patterns"), loaddoc('patterns')),
 (['environment', 'env'], _('Environment Variables'),
  loaddoc('environment')),
diff --git a/contrib/wix/help.wxs 

D3967: dispatch: making all hg abortions be output with a specific label

2018-08-01 Thread rdamazio (Rodrigo Damazio Bovendorp)
This revision was automatically updated to reflect the committed changes.
Closed by commit rHGafc4ad706f9c: dispatch: making all hg abortions be output 
with a specific label (authored by rdamazio, committed by ).

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D3967?vs=9641=9694

REVISION DETAIL
  https://phab.mercurial-scm.org/D3967

AFFECTED FILES
  mercurial/color.py
  mercurial/commandserver.py
  mercurial/dispatch.py
  mercurial/scmutil.py
  mercurial/ui.py

CHANGE DETAILS

diff --git a/mercurial/ui.py b/mercurial/ui.py
--- a/mercurial/ui.py
+++ b/mercurial/ui.py
@@ -1420,29 +1420,41 @@
 return getpass.getpass('')
 except EOFError:
 raise error.ResponseExpected()
+
 def status(self, *msg, **opts):
 '''write status message to output (if ui.quiet is False)
 
 This adds an output label of "ui.status".
 '''
 if not self.quiet:
 opts[r'label'] = opts.get(r'label', '') + ' ui.status'
 self.write(*msg, **opts)
+
 def warn(self, *msg, **opts):
 '''write warning message to output (stderr)
 
 This adds an output label of "ui.warning".
 '''
 opts[r'label'] = opts.get(r'label', '') + ' ui.warning'
 self.write_err(*msg, **opts)
+
+def error(self, *msg, **opts):
+'''write error message to output (stderr)
+
+This adds an output label of "ui.error".
+'''
+opts[r'label'] = opts.get(r'label', '') + ' ui.error'
+self.write_err(*msg, **opts)
+
 def note(self, *msg, **opts):
 '''write note to output (if ui.verbose is True)
 
 This adds an output label of "ui.note".
 '''
 if self.verbose:
 opts[r'label'] = opts.get(r'label', '') + ' ui.note'
 self.write(*msg, **opts)
+
 def debug(self, *msg, **opts):
 '''write debug message to output (if ui.debugflag is True)
 
diff --git a/mercurial/scmutil.py b/mercurial/scmutil.py
--- a/mercurial/scmutil.py
+++ b/mercurial/scmutil.py
@@ -169,64 +169,64 @@
 reason = _('timed out waiting for lock held by %r') % inst.locker
 else:
 reason = _('lock held by %r') % inst.locker
-ui.warn(_("abort: %s: %s\n")
-% (inst.desc or stringutil.forcebytestr(inst.filename), 
reason))
+ui.error(_("abort: %s: %s\n") % (
+inst.desc or stringutil.forcebytestr(inst.filename), reason))
 if not inst.locker:
-ui.warn(_("(lock might be very busy)\n"))
+ui.error(_("(lock might be very busy)\n"))
 except error.LockUnavailable as inst:
-ui.warn(_("abort: could not lock %s: %s\n") %
-(inst.desc or stringutil.forcebytestr(inst.filename),
- encoding.strtolocal(inst.strerror)))
+ui.error(_("abort: could not lock %s: %s\n") %
+ (inst.desc or stringutil.forcebytestr(inst.filename),
+  encoding.strtolocal(inst.strerror)))
 except error.OutOfBandError as inst:
 if inst.args:
 msg = _("abort: remote error:\n")
 else:
 msg = _("abort: remote error\n")
-ui.warn(msg)
+ui.error(msg)
 if inst.args:
-ui.warn(''.join(inst.args))
+ui.error(''.join(inst.args))
 if inst.hint:
-ui.warn('(%s)\n' % inst.hint)
+ui.error('(%s)\n' % inst.hint)
 except error.RepoError as inst:
-ui.warn(_("abort: %s!\n") % inst)
+ui.error(_("abort: %s!\n") % inst)
 if inst.hint:
-ui.warn(_("(%s)\n") % inst.hint)
+ui.error(_("(%s)\n") % inst.hint)
 except error.ResponseError as inst:
-ui.warn(_("abort: %s") % inst.args[0])
+ui.error(_("abort: %s") % inst.args[0])
 msg = inst.args[1]
 if isinstance(msg, type(u'')):
 msg = pycompat.sysbytes(msg)
 if not isinstance(msg, bytes):
-ui.warn(" %r\n" % (msg,))
+ui.error(" %r\n" % (msg,))
 elif not msg:
-ui.warn(_(" empty string\n"))
+ui.error(_(" empty string\n"))
 else:
-ui.warn("\n%r\n" % pycompat.bytestr(stringutil.ellipsis(msg)))
+ui.error("\n%r\n" % pycompat.bytestr(stringutil.ellipsis(msg)))
 except error.CensoredNodeError as inst:
-ui.warn(_("abort: file censored %s!\n") % inst)
+ui.error(_("abort: file censored %s!\n") % inst)
 except error.RevlogError as inst:
-ui.warn(_("abort: %s!\n") % inst)
+ui.error(_("abort: %s!\n") % inst)
 except error.InterventionRequired as inst:
-ui.warn("%s\n" % inst)
+ui.error("%s\n" % inst)
 if inst.hint:
-ui.warn(_("(%s)\n") % inst.hint)
+ui.error(_("(%s)\n") % inst.hint)
 return 1
 except error.WdirUnsupported:
-ui.warn(_("abort: working directory revision cannot be 

D3964: macosx: fixing macOS version generation after db9d1dd01bf0

2018-07-18 Thread rdamazio (Rodrigo Damazio Bovendorp)
rdamazio added a comment.


  Er, actually, let me fix this again - this unbreaks the build but generates 
packages like 'Mercurial-"4.6.2+674-f83600efa1ca-macosx10.13.dmg'.

REPOSITORY
  rHG Mercurial

REVISION DETAIL
  https://phab.mercurial-scm.org/D3964

To: rdamazio, #hg-reviewers
Cc: mercurial-devel
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


D3964: macosx: fixing macOS version generation after dbbe45ae5ad1

2018-07-18 Thread rdamazio (Rodrigo Damazio Bovendorp)
rdamazio created this revision.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.

REVISION SUMMARY
  With the Python3 change, the string is now something like
  version = b'4.6.2+848-88be288e8ac1'
  where it was previously just:
  version = '4.6.2+848-88be288e8ac1'

REPOSITORY
  rHG Mercurial

REVISION DETAIL
  https://phab.mercurial-scm.org/D3964

AFFECTED FILES
  contrib/genosxversion.py

CHANGE DETAILS

diff --git a/contrib/genosxversion.py b/contrib/genosxversion.py
--- a/contrib/genosxversion.py
+++ b/contrib/genosxversion.py
@@ -117,9 +117,9 @@
 return
 with open(opts.versionfile) as f:
 for l in f:
-if l.startswith('version = '):
+if l.startswith('version = b'):
 # version number is entire line minus the quotes
-ver = l[len('version = ') + 1:-2]
+ver = l[len('version = b') + 1:-2]
 break
 if opts.paranoid:
 print(paranoidver(ver))



To: rdamazio, #hg-reviewers
Cc: mercurial-devel
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


D3964: macosx: fixing macOS version generation after db9d1dd01bf0

2018-07-18 Thread rdamazio (Rodrigo Damazio Bovendorp)
rdamazio added a comment.


  Hmm and nevermind, the weird package name doesn't reproduce on a vanilla hg 
build, you can go ahead and review.

REPOSITORY
  rHG Mercurial

REVISION DETAIL
  https://phab.mercurial-scm.org/D3964

To: rdamazio, #hg-reviewers
Cc: glandium, mercurial-devel
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


D3964: macosx: fixing macOS version generation after db9d1dd01bf0

2018-07-18 Thread rdamazio (Rodrigo Damazio Bovendorp)
rdamazio added a comment.


  In https://phab.mercurial-scm.org/D3964#61696, @glandium wrote:
  
  > This is python code, why is it parsing the version file instead of 
importing it?
  
  
  Great question, no idea :) I took the minimal fix approach to reduce the 
change of further breaking it.

REPOSITORY
  rHG Mercurial

REVISION DETAIL
  https://phab.mercurial-scm.org/D3964

To: rdamazio, #hg-reviewers
Cc: glandium, mercurial-devel
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


D3967: dispatch: making all hg abortions be output with a specific label

2018-07-20 Thread rdamazio (Rodrigo Damazio Bovendorp)
rdamazio created this revision.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.

REVISION SUMMARY
  This allows abortions to be highlighted specially and separately
  from warnings - for instance, red is a reasonable color for when hg
  aborts, but is overly dramatic for most warnings produced elsewhere.

REPOSITORY
  rHG Mercurial

REVISION DETAIL
  https://phab.mercurial-scm.org/D3967

AFFECTED FILES
  mercurial/color.py
  mercurial/commandserver.py
  mercurial/dispatch.py
  mercurial/scmutil.py

CHANGE DETAILS

diff --git a/mercurial/scmutil.py b/mercurial/scmutil.py
--- a/mercurial/scmutil.py
+++ b/mercurial/scmutil.py
@@ -170,63 +170,70 @@
 else:
 reason = _('lock held by %r') % inst.locker
 ui.warn(_("abort: %s: %s\n")
-% (inst.desc or stringutil.forcebytestr(inst.filename), 
reason))
+% (inst.desc or stringutil.forcebytestr(inst.filename), 
reason),
+label='ui.abort')
 if not inst.locker:
-ui.warn(_("(lock might be very busy)\n"))
+ui.warn(_("(lock might be very busy)\n"), label='ui.abort')
 except error.LockUnavailable as inst:
 ui.warn(_("abort: could not lock %s: %s\n") %
 (inst.desc or stringutil.forcebytestr(inst.filename),
- encoding.strtolocal(inst.strerror)))
+ encoding.strtolocal(inst.strerror)),
+label='ui.abort')
 except error.OutOfBandError as inst:
 if inst.args:
 msg = _("abort: remote error:\n")
 else:
 msg = _("abort: remote error\n")
-ui.warn(msg)
+ui.warn(msg, label='ui.abort')
 if inst.args:
-ui.warn(''.join(inst.args))
+ui.warn(''.join(inst.args), label='ui.abort')
 if inst.hint:
-ui.warn('(%s)\n' % inst.hint)
+ui.warn('(%s)\n' % inst.hint, label='ui.abort')
 except error.RepoError as inst:
-ui.warn(_("abort: %s!\n") % inst)
+ui.warn(_("abort: %s!\n") % inst, label='ui.abort')
 if inst.hint:
-ui.warn(_("(%s)\n") % inst.hint)
+ui.warn(_("(%s)\n") % inst.hint, label='ui.abort')
 except error.ResponseError as inst:
-ui.warn(_("abort: %s") % inst.args[0])
+ui.warn(_("abort: %s") % inst.args[0], label='ui.abort')
 msg = inst.args[1]
 if isinstance(msg, type(u'')):
 msg = pycompat.sysbytes(msg)
 if not isinstance(msg, bytes):
-ui.warn(" %r\n" % (msg,))
+ui.warn(" %r\n" % (msg,), label='ui.abort')
 elif not msg:
-ui.warn(_(" empty string\n"))
+ui.warn(_(" empty string\n"), label='ui.abort')
 else:
-ui.warn("\n%r\n" % pycompat.bytestr(stringutil.ellipsis(msg)))
+ui.warn("\n%r\n" % pycompat.bytestr(stringutil.ellipsis(msg)),
+label='ui.abort')
 except error.CensoredNodeError as inst:
-ui.warn(_("abort: file censored %s!\n") % inst)
+ui.warn(_("abort: file censored %s!\n") % inst, label='ui.abort')
 except error.RevlogError as inst:
-ui.warn(_("abort: %s!\n") % inst)
+ui.warn(_("abort: %s!\n") % inst, label='ui.abort')
 except error.InterventionRequired as inst:
-ui.warn("%s\n" % inst)
+ui.warn("%s\n" % inst, label='ui.abort')
 if inst.hint:
-ui.warn(_("(%s)\n") % inst.hint)
+ui.warn(_("(%s)\n") % inst.hint, label='ui.abort')
 return 1
 except error.WdirUnsupported:
-ui.warn(_("abort: working directory revision cannot be specified\n"))
+ui.warn(_("abort: working directory revision cannot be specified\n"),
+label='ui.abort')
 except error.Abort as inst:
-ui.warn(_("abort: %s\n") % inst)
+ui.warn(_("abort: %s\n") % inst, label='ui.abort')
 if inst.hint:
-ui.warn(_("(%s)\n") % inst.hint)
+ui.warn(_("(%s)\n") % inst.hint, label='ui.abort')
 except ImportError as inst:
-ui.warn(_("abort: %s!\n") % stringutil.forcebytestr(inst))
+ui.warn(_("abort: %s!\n") % stringutil.forcebytestr(inst),
+label='ui.abort')
 m = stringutil.forcebytestr(inst).split()[-1]
 if m in "mpatch bdiff".split():
-ui.warn(_("(did you forget to compile extensions?)\n"))
+ui.warn(_("(did you forget to compile extensions?)\n"),
+label='ui.abort')
 elif m in "zlib".split():
-ui.warn(_("(is your Python install correct?)\n"))
+ui.warn(_("(is your Python install correct?)\n"), label='ui.abort')
 except IOError as inst:
 if util.safehasattr(inst, "code"):
-ui.warn(_("abort: %s\n") % stringutil.forcebytestr(inst))
+ui.warn(_("abort: %s\n") % stringutil.forcebytestr(inst),
+label='ui.abort')
 elif 

D3967: dispatch: making all hg abortions be output with a specific label

2018-07-20 Thread rdamazio (Rodrigo Damazio Bovendorp)
rdamazio updated this revision to Diff 9641.
rdamazio marked an inline comment as done.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D3967?vs=9638=9641

REVISION DETAIL
  https://phab.mercurial-scm.org/D3967

AFFECTED FILES
  mercurial/color.py
  mercurial/commandserver.py
  mercurial/dispatch.py
  mercurial/scmutil.py
  mercurial/ui.py

CHANGE DETAILS

diff --git a/mercurial/ui.py b/mercurial/ui.py
--- a/mercurial/ui.py
+++ b/mercurial/ui.py
@@ -1422,29 +1422,41 @@
 return getpass.getpass('')
 except EOFError:
 raise error.ResponseExpected()
+
 def status(self, *msg, **opts):
 '''write status message to output (if ui.quiet is False)
 
 This adds an output label of "ui.status".
 '''
 if not self.quiet:
 opts[r'label'] = opts.get(r'label', '') + ' ui.status'
 self.write(*msg, **opts)
+
 def warn(self, *msg, **opts):
 '''write warning message to output (stderr)
 
 This adds an output label of "ui.warning".
 '''
 opts[r'label'] = opts.get(r'label', '') + ' ui.warning'
 self.write_err(*msg, **opts)
+
+def error(self, *msg, **opts):
+'''write error message to output (stderr)
+
+This adds an output label of "ui.error".
+'''
+opts[r'label'] = opts.get(r'label', '') + ' ui.error'
+self.write_err(*msg, **opts)
+
 def note(self, *msg, **opts):
 '''write note to output (if ui.verbose is True)
 
 This adds an output label of "ui.note".
 '''
 if self.verbose:
 opts[r'label'] = opts.get(r'label', '') + ' ui.note'
 self.write(*msg, **opts)
+
 def debug(self, *msg, **opts):
 '''write debug message to output (if ui.debugflag is True)
 
diff --git a/mercurial/scmutil.py b/mercurial/scmutil.py
--- a/mercurial/scmutil.py
+++ b/mercurial/scmutil.py
@@ -169,64 +169,64 @@
 reason = _('timed out waiting for lock held by %r') % inst.locker
 else:
 reason = _('lock held by %r') % inst.locker
-ui.warn(_("abort: %s: %s\n")
-% (inst.desc or stringutil.forcebytestr(inst.filename), 
reason))
+ui.error(_("abort: %s: %s\n") % (
+inst.desc or stringutil.forcebytestr(inst.filename), reason))
 if not inst.locker:
-ui.warn(_("(lock might be very busy)\n"))
+ui.error(_("(lock might be very busy)\n"))
 except error.LockUnavailable as inst:
-ui.warn(_("abort: could not lock %s: %s\n") %
-(inst.desc or stringutil.forcebytestr(inst.filename),
- encoding.strtolocal(inst.strerror)))
+ui.error(_("abort: could not lock %s: %s\n") %
+ (inst.desc or stringutil.forcebytestr(inst.filename),
+  encoding.strtolocal(inst.strerror)))
 except error.OutOfBandError as inst:
 if inst.args:
 msg = _("abort: remote error:\n")
 else:
 msg = _("abort: remote error\n")
-ui.warn(msg)
+ui.error(msg)
 if inst.args:
-ui.warn(''.join(inst.args))
+ui.error(''.join(inst.args))
 if inst.hint:
-ui.warn('(%s)\n' % inst.hint)
+ui.error('(%s)\n' % inst.hint)
 except error.RepoError as inst:
-ui.warn(_("abort: %s!\n") % inst)
+ui.error(_("abort: %s!\n") % inst)
 if inst.hint:
-ui.warn(_("(%s)\n") % inst.hint)
+ui.error(_("(%s)\n") % inst.hint)
 except error.ResponseError as inst:
-ui.warn(_("abort: %s") % inst.args[0])
+ui.error(_("abort: %s") % inst.args[0])
 msg = inst.args[1]
 if isinstance(msg, type(u'')):
 msg = pycompat.sysbytes(msg)
 if not isinstance(msg, bytes):
-ui.warn(" %r\n" % (msg,))
+ui.error(" %r\n" % (msg,))
 elif not msg:
-ui.warn(_(" empty string\n"))
+ui.error(_(" empty string\n"))
 else:
-ui.warn("\n%r\n" % pycompat.bytestr(stringutil.ellipsis(msg)))
+ui.error("\n%r\n" % pycompat.bytestr(stringutil.ellipsis(msg)))
 except error.CensoredNodeError as inst:
-ui.warn(_("abort: file censored %s!\n") % inst)
+ui.error(_("abort: file censored %s!\n") % inst)
 except error.RevlogError as inst:
-ui.warn(_("abort: %s!\n") % inst)
+ui.error(_("abort: %s!\n") % inst)
 except error.InterventionRequired as inst:
-ui.warn("%s\n" % inst)
+ui.error("%s\n" % inst)
 if inst.hint:
-ui.warn(_("(%s)\n") % inst.hint)
+ui.error(_("(%s)\n") % inst.hint)
 return 1
 except error.WdirUnsupported:
-ui.warn(_("abort: working directory revision cannot be specified\n"))
+ui.error(_("abort: working directory revision cannot be specified\n"))
 except error.Abort as inst:

D3967: dispatch: making all hg abortions be output with a specific label

2018-07-20 Thread rdamazio (Rodrigo Damazio Bovendorp)
rdamazio added a comment.


  PTAL

REPOSITORY
  rHG Mercurial

REVISION DETAIL
  https://phab.mercurial-scm.org/D3967

To: rdamazio, #hg-reviewers
Cc: martinvonz, mercurial-devel
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


D3964: macosx: fixing macOS version generation after db9d1dd01bf0

2018-07-19 Thread rdamazio (Rodrigo Damazio Bovendorp)
This revision was automatically updated to reflect the committed changes.
Closed by commit rHG25880ddf9a86: macosx: fixing macOS version generation after 
db9d1dd01bf0 (authored by rdamazio, committed by ).

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D3964?vs=9627=9633

REVISION DETAIL
  https://phab.mercurial-scm.org/D3964

AFFECTED FILES
  contrib/genosxversion.py

CHANGE DETAILS

diff --git a/contrib/genosxversion.py b/contrib/genosxversion.py
--- a/contrib/genosxversion.py
+++ b/contrib/genosxversion.py
@@ -117,9 +117,9 @@
 return
 with open(opts.versionfile) as f:
 for l in f:
-if l.startswith('version = '):
+if l.startswith('version = b'):
 # version number is entire line minus the quotes
-ver = l[len('version = ') + 1:-2]
+ver = l[len('version = b') + 1:-2]
 break
 if opts.paranoid:
 print(paranoidver(ver))



To: rdamazio, #hg-reviewers
Cc: glandium, mercurial-devel
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


D2678: help: supporting both help and doc for aliases

2018-03-26 Thread rdamazio (Rodrigo Damazio Bovendorp)
rdamazio updated this revision to Diff 7330.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D2678?vs=6980=7330

REVISION DETAIL
  https://phab.mercurial-scm.org/D2678

AFFECTED FILES
  hgext/show.py
  mercurial/configitems.py
  mercurial/dispatch.py
  mercurial/help.py
  mercurial/ui.py
  tests/test-alias.t
  tests/test-help.t

CHANGE DETAILS

diff --git a/tests/test-help.t b/tests/test-help.t
--- a/tests/test-help.t
+++ b/tests/test-help.t
@@ -777,9 +777,9 @@
   $ hg help shellalias
   hg shellalias
   
-  shell alias for:
-  
-echo hi
+  shell alias for: echo hi
+  
+  (no help text available)
   
   defined by: helpext
   
diff --git a/tests/test-alias.t b/tests/test-alias.t
--- a/tests/test-alias.t
+++ b/tests/test-alias.t
@@ -4,9 +4,13 @@
   > # should clobber ci but not commit (issue2993)
   > ci = version
   > myinit = init
+  > myinit:doc = This is my documented alias for init.
+  > myinit:help = [OPTIONS] [BLA] [BLE]
   > mycommit = commit
+  > mycommit:doc = This is my alias with only doc.
   > optionalrepo = showconfig alias.myinit
   > cleanstatus = status -c
+  > cleanstatus:help = [ONLYHELPHERE]
   > unknown = bargle
   > ambiguous = s
   > recursive = recursive
@@ -20,9 +24,13 @@
   > no--config = status --config a.config=1
   > mylog = log
   > lognull = log -r null
+  > lognull:doc = Logs the null rev
+  > lognull:help = foo bar baz
   > shortlog = log --template '{rev} {node|short} | {date|isodate}\n'
   > positional = log --template '{\$2} {\$1} | {date|isodate}\n'
   > dln = lognull --debug
+  > recursivedoc = dln
+  > recursivedoc:doc = Logs the null rev in debug mode
   > nousage = rollback
   > put = export -r 0 -o "\$FOO/%R.diff"
   > blank = !printf '\n'
@@ -53,11 +61,148 @@
   > log = -v
   > EOF
 
-
 basic
 
   $ hg myinit alias
 
+help
+
+  $ hg help -c | grep myinit
+   myinit This is my documented alias for init.
+  $ hg help -c | grep mycommit
+   mycommit   This is my alias with only doc.
+  $ hg help -c | grep cleanstatus
+   cleanstatusshow changed files in the working directory
+  $ hg help -c | grep lognull
+   lognullLogs the null rev
+  $ hg help -c | grep dln
+   dlnLogs the null rev
+  $ hg help -c | grep recursivedoc
+   recursivedoc   Logs the null rev in debug mode
+  $ hg help myinit
+  hg myinit [OPTIONS] [BLA] [BLE]
+  
+  alias for: hg init
+  
+  This is my documented alias for init.
+  
+  defined by: * (glob)
+  */* (glob) (?)
+  */* (glob) (?)
+  */* (glob) (?)
+  
+  options:
+  
+   -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)
+  
+  (some details hidden, use --verbose to show complete help)
+
+  $ hg help mycommit
+  hg mycommit [OPTION]... [FILE]...
+  
+  alias for: hg commit
+  
+  This is my alias with only doc.
+  
+  defined by: * (glob)
+  */* (glob) (?)
+  */* (glob) (?)
+  */* (glob) (?)
+  
+  options ([+] can be repeated):
+  
+   -A --addremove   mark new/missing files as added/removed before
+committing
+  --close-branchmark a branch head as closed
+  --amend   amend the parent of the working directory
+   -s --secret  use the secret phase for committing
+   -e --editinvoke editor on commit messages
+   -i --interactive use interactive mode
+   -I --include PATTERN [+] include names matching the given patterns
+   -X --exclude PATTERN [+] exclude names matching the given patterns
+   -m --message TEXTuse text as commit message
+   -l --logfile FILEread commit message from file
+   -d --date DATE   record the specified date as commit date
+   -u --user USER   record the specified user as committer
+   -S --subreposrecurse into subrepositories
+  
+  (some details hidden, use --verbose to show complete help)
+
+  $ hg help cleanstatus
+  hg cleanstatus [ONLYHELPHERE]
+  
+  alias for: hg status -c
+  
+  show changed files in the working directory
+  
+  Show status of files in the repository. If names are given, only files
+  that match are shown. Files that are clean or ignored or the source of a
+  copy/move operation, are not listed unless -c/--clean, -i/--ignored,
+  -C/--copies or -A/--all are given. Unless options described with "show
+  only ..." are given, the options -mardu are used.
+  
+  Option -q/--quiet hides untracked (unknown and ignored) files unless
+  explicitly requested with -u/--unknown or -i/--ignored.
+  
+  Note:
+ 'hg status' may appear to disagree with diff if permissions have
+ changed or a merge has occurred. The standard diff format does not
+ report permission changes and diff only reports changes relative to 
one
+ merge 

D2678: help: supporting both help and doc for aliases

2018-03-26 Thread rdamazio (Rodrigo Damazio Bovendorp)
rdamazio added a comment.


  The flakiness was just due to Python map order randomization in tests (a 
fixed PYTHONHASHSEED=3170796678 or similar reproduces it consistently by 
getting dln before lognull).
  The real issue was the added "ignoresub=True" argument which broke strict 
ordering guarantees in the return value, combined with the fact that each lazy 
alias entry makes a copy of the cmdtable *at the state when it's created*.
  
  I've fixed this in ui.configitems so it preserves ordering - PTAL. Should 
also be a tiny bit faster now.
  I've also added tests for the recursive alias case.

REPOSITORY
  rHG Mercurial

REVISION DETAIL
  https://phab.mercurial-scm.org/D2678

To: rdamazio, #hg-reviewers, durin42, pulkit
Cc: mharbison72, spectral, pulkit, mercurial-devel
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


D2623: dispatch: adding config items for overriding flag defaults

2018-03-27 Thread rdamazio (Rodrigo Damazio Bovendorp)
rdamazio added inline comments.

INLINE COMMENTS

> dploch wrote in dispatch.py:625-626
> This doesn't handle callables properly.  I wonder if the something like the 
> following would work instead:
> 
> oldopt = fancyopts._defaultopt(olddefault)
> newdefault = old.opt.newstate(olddefault, ui.config("commands", cfgitem)
> c[idx] = (opt[0], opt[1], fancyopts._withnewdefault(oldopt, newdefault), 
> opt[3])
> 
> Where '_withnewdefault' is a wrapper customopt that just changes the default.

I thought callables were meant to be used to generate the default default, not 
with overridden values?

> dploch wrote in dispatch.py:639-640
> This makes me nervous.  What if someone re-uses a customopt instance in 
> multiple commands?  i.e.:
> 
> DATE_FLAG = mypkg.dateopt()
> ...
> ('b', 'before', DATE_FLAG, '')
> ('a', 'after', 'DATE_FLAG', '')
> 
> Now, setting commands.defaults.before=2018-03-05 also silently changes the 
> default for 'after'.  I suspect we need to introduce a wrapper class like 
> what I suggest on lines 625-625, that delegates and leaves the original 
> default unchanged.  And either way, we should probably clarify in the docs on 
> customopts what expected use of the class is (i.e., should we just forbid 
> reuse, is 'oldstate' safe to mutate, etc.)

Nobody should use the same *instance* on multiple flags. Even with the current 
flags, if you use e.g. the same list on many, that'll cause problems with 
listopt.

REPOSITORY
  rHG Mercurial

REVISION DETAIL
  https://phab.mercurial-scm.org/D2623

To: rdamazio, #hg-reviewers, yuja
Cc: dploch, mercurial-devel
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


D2678: help: supporting both help and doc for aliases

2018-03-26 Thread rdamazio (Rodrigo Damazio Bovendorp)
rdamazio updated this revision to Diff 7331.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D2678?vs=7330=7331

REVISION DETAIL
  https://phab.mercurial-scm.org/D2678

AFFECTED FILES
  hgext/show.py
  mercurial/configitems.py
  mercurial/dispatch.py
  mercurial/help.py
  mercurial/ui.py
  tests/test-alias.t
  tests/test-help.t

CHANGE DETAILS

diff --git a/tests/test-help.t b/tests/test-help.t
--- a/tests/test-help.t
+++ b/tests/test-help.t
@@ -777,9 +777,9 @@
   $ hg help shellalias
   hg shellalias
   
-  shell alias for:
-  
-echo hi
+  shell alias for: echo hi
+  
+  (no help text available)
   
   defined by: helpext
   
diff --git a/tests/test-alias.t b/tests/test-alias.t
--- a/tests/test-alias.t
+++ b/tests/test-alias.t
@@ -4,9 +4,13 @@
   > # should clobber ci but not commit (issue2993)
   > ci = version
   > myinit = init
+  > myinit:doc = This is my documented alias for init.
+  > myinit:help = [OPTIONS] [BLA] [BLE]
   > mycommit = commit
+  > mycommit:doc = This is my alias with only doc.
   > optionalrepo = showconfig alias.myinit
   > cleanstatus = status -c
+  > cleanstatus:help = [ONLYHELPHERE]
   > unknown = bargle
   > ambiguous = s
   > recursive = recursive
@@ -20,9 +24,13 @@
   > no--config = status --config a.config=1
   > mylog = log
   > lognull = log -r null
+  > lognull:doc = Logs the null rev
+  > lognull:help = foo bar baz
   > shortlog = log --template '{rev} {node|short} | {date|isodate}\n'
   > positional = log --template '{\$2} {\$1} | {date|isodate}\n'
   > dln = lognull --debug
+  > recursivedoc = dln
+  > recursivedoc:doc = Logs the null rev in debug mode
   > nousage = rollback
   > put = export -r 0 -o "\$FOO/%R.diff"
   > blank = !printf '\n'
@@ -53,11 +61,148 @@
   > log = -v
   > EOF
 
-
 basic
 
   $ hg myinit alias
 
+help
+
+  $ hg help -c | grep myinit
+   myinit This is my documented alias for init.
+  $ hg help -c | grep mycommit
+   mycommit   This is my alias with only doc.
+  $ hg help -c | grep cleanstatus
+   cleanstatusshow changed files in the working directory
+  $ hg help -c | grep lognull
+   lognullLogs the null rev
+  $ hg help -c | grep dln
+   dlnLogs the null rev
+  $ hg help -c | grep recursivedoc
+   recursivedoc   Logs the null rev in debug mode
+  $ hg help myinit
+  hg myinit [OPTIONS] [BLA] [BLE]
+  
+  alias for: hg init
+  
+  This is my documented alias for init.
+  
+  defined by: * (glob)
+  */* (glob) (?)
+  */* (glob) (?)
+  */* (glob) (?)
+  
+  options:
+  
+   -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)
+  
+  (some details hidden, use --verbose to show complete help)
+
+  $ hg help mycommit
+  hg mycommit [OPTION]... [FILE]...
+  
+  alias for: hg commit
+  
+  This is my alias with only doc.
+  
+  defined by: * (glob)
+  */* (glob) (?)
+  */* (glob) (?)
+  */* (glob) (?)
+  
+  options ([+] can be repeated):
+  
+   -A --addremove   mark new/missing files as added/removed before
+committing
+  --close-branchmark a branch head as closed
+  --amend   amend the parent of the working directory
+   -s --secret  use the secret phase for committing
+   -e --editinvoke editor on commit messages
+   -i --interactive use interactive mode
+   -I --include PATTERN [+] include names matching the given patterns
+   -X --exclude PATTERN [+] exclude names matching the given patterns
+   -m --message TEXTuse text as commit message
+   -l --logfile FILEread commit message from file
+   -d --date DATE   record the specified date as commit date
+   -u --user USER   record the specified user as committer
+   -S --subreposrecurse into subrepositories
+  
+  (some details hidden, use --verbose to show complete help)
+
+  $ hg help cleanstatus
+  hg cleanstatus [ONLYHELPHERE]
+  
+  alias for: hg status -c
+  
+  show changed files in the working directory
+  
+  Show status of files in the repository. If names are given, only files
+  that match are shown. Files that are clean or ignored or the source of a
+  copy/move operation, are not listed unless -c/--clean, -i/--ignored,
+  -C/--copies or -A/--all are given. Unless options described with "show
+  only ..." are given, the options -mardu are used.
+  
+  Option -q/--quiet hides untracked (unknown and ignored) files unless
+  explicitly requested with -u/--unknown or -i/--ignored.
+  
+  Note:
+ 'hg status' may appear to disagree with diff if permissions have
+ changed or a merge has occurred. The standard diff format does not
+ report permission changes and diff only reports changes relative to 
one
+ merge 

D2678: help: supporting both help and doc for aliases

2018-03-27 Thread rdamazio (Rodrigo Damazio Bovendorp)
rdamazio updated this revision to Diff 7346.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D2678?vs=7331=7346

REVISION DETAIL
  https://phab.mercurial-scm.org/D2678

AFFECTED FILES
  hgext/show.py
  mercurial/configitems.py
  mercurial/dispatch.py
  mercurial/help.py
  mercurial/ui.py
  tests/test-alias.t
  tests/test-help.t

CHANGE DETAILS

diff --git a/tests/test-help.t b/tests/test-help.t
--- a/tests/test-help.t
+++ b/tests/test-help.t
@@ -777,9 +777,9 @@
   $ hg help shellalias
   hg shellalias
   
-  shell alias for:
-  
-echo hi
+  shell alias for: echo hi
+  
+  (no help text available)
   
   defined by: helpext
   
diff --git a/tests/test-alias.t b/tests/test-alias.t
--- a/tests/test-alias.t
+++ b/tests/test-alias.t
@@ -4,9 +4,13 @@
   > # should clobber ci but not commit (issue2993)
   > ci = version
   > myinit = init
+  > myinit:doc = This is my documented alias for init.
+  > myinit:help = [OPTIONS] [BLA] [BLE]
   > mycommit = commit
+  > mycommit:doc = This is my alias with only doc.
   > optionalrepo = showconfig alias.myinit
   > cleanstatus = status -c
+  > cleanstatus:help = [ONLYHELPHERE]
   > unknown = bargle
   > ambiguous = s
   > recursive = recursive
@@ -20,9 +24,13 @@
   > no--config = status --config a.config=1
   > mylog = log
   > lognull = log -r null
+  > lognull:doc = Logs the null rev
+  > lognull:help = foo bar baz
   > shortlog = log --template '{rev} {node|short} | {date|isodate}\n'
   > positional = log --template '{\$2} {\$1} | {date|isodate}\n'
   > dln = lognull --debug
+  > recursivedoc = dln
+  > recursivedoc:doc = Logs the null rev in debug mode
   > nousage = rollback
   > put = export -r 0 -o "\$FOO/%R.diff"
   > blank = !printf '\n'
@@ -53,11 +61,148 @@
   > log = -v
   > EOF
 
-
 basic
 
   $ hg myinit alias
 
+help
+
+  $ hg help -c | grep myinit
+   myinit This is my documented alias for init.
+  $ hg help -c | grep mycommit
+   mycommit   This is my alias with only doc.
+  $ hg help -c | grep cleanstatus
+   cleanstatusshow changed files in the working directory
+  $ hg help -c | grep lognull
+   lognullLogs the null rev
+  $ hg help -c | grep dln
+   dlnLogs the null rev
+  $ hg help -c | grep recursivedoc
+   recursivedoc   Logs the null rev in debug mode
+  $ hg help myinit
+  hg myinit [OPTIONS] [BLA] [BLE]
+  
+  alias for: hg init
+  
+  This is my documented alias for init.
+  
+  defined by: * (glob)
+  */* (glob) (?)
+  */* (glob) (?)
+  */* (glob) (?)
+  
+  options:
+  
+   -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)
+  
+  (some details hidden, use --verbose to show complete help)
+
+  $ hg help mycommit
+  hg mycommit [OPTION]... [FILE]...
+  
+  alias for: hg commit
+  
+  This is my alias with only doc.
+  
+  defined by: * (glob)
+  */* (glob) (?)
+  */* (glob) (?)
+  */* (glob) (?)
+  
+  options ([+] can be repeated):
+  
+   -A --addremove   mark new/missing files as added/removed before
+committing
+  --close-branchmark a branch head as closed
+  --amend   amend the parent of the working directory
+   -s --secret  use the secret phase for committing
+   -e --editinvoke editor on commit messages
+   -i --interactive use interactive mode
+   -I --include PATTERN [+] include names matching the given patterns
+   -X --exclude PATTERN [+] exclude names matching the given patterns
+   -m --message TEXTuse text as commit message
+   -l --logfile FILEread commit message from file
+   -d --date DATE   record the specified date as commit date
+   -u --user USER   record the specified user as committer
+   -S --subreposrecurse into subrepositories
+  
+  (some details hidden, use --verbose to show complete help)
+
+  $ hg help cleanstatus
+  hg cleanstatus [ONLYHELPHERE]
+  
+  alias for: hg status -c
+  
+  show changed files in the working directory
+  
+  Show status of files in the repository. If names are given, only files
+  that match are shown. Files that are clean or ignored or the source of a
+  copy/move operation, are not listed unless -c/--clean, -i/--ignored,
+  -C/--copies or -A/--all are given. Unless options described with "show
+  only ..." are given, the options -mardu are used.
+  
+  Option -q/--quiet hides untracked (unknown and ignored) files unless
+  explicitly requested with -u/--unknown or -i/--ignored.
+  
+  Note:
+ 'hg status' may appear to disagree with diff if permissions have
+ changed or a merge has occurred. The standard diff format does not
+ report permission changes and diff only reports changes relative to 
one
+ merge 

D2678: help: supporting both help and doc for aliases

2018-03-27 Thread rdamazio (Rodrigo Damazio Bovendorp)
rdamazio added a comment.


  Sorry about that, I had fixed this one and forgot to re-upload. Try now.

REPOSITORY
  rHG Mercurial

REVISION DETAIL
  https://phab.mercurial-scm.org/D2678

To: rdamazio, #hg-reviewers, durin42, pulkit
Cc: mharbison72, spectral, pulkit, mercurial-devel
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


D2678: help: supporting both help and doc for aliases

2018-03-28 Thread rdamazio (Rodrigo Damazio Bovendorp)
This revision was automatically updated to reflect the committed changes.
Closed by commit rHG6890b7e991a4: help: supporting both help and doc for 
aliases (authored by rdamazio, committed by ).

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D2678?vs=7346=7347

REVISION DETAIL
  https://phab.mercurial-scm.org/D2678

AFFECTED FILES
  hgext/show.py
  mercurial/configitems.py
  mercurial/dispatch.py
  mercurial/help.py
  mercurial/ui.py
  tests/test-alias.t
  tests/test-help.t

CHANGE DETAILS

diff --git a/tests/test-help.t b/tests/test-help.t
--- a/tests/test-help.t
+++ b/tests/test-help.t
@@ -777,9 +777,9 @@
   $ hg help shellalias
   hg shellalias
   
-  shell alias for:
-  
-echo hi
+  shell alias for: echo hi
+  
+  (no help text available)
   
   defined by: helpext
   
diff --git a/tests/test-alias.t b/tests/test-alias.t
--- a/tests/test-alias.t
+++ b/tests/test-alias.t
@@ -4,9 +4,13 @@
   > # should clobber ci but not commit (issue2993)
   > ci = version
   > myinit = init
+  > myinit:doc = This is my documented alias for init.
+  > myinit:help = [OPTIONS] [BLA] [BLE]
   > mycommit = commit
+  > mycommit:doc = This is my alias with only doc.
   > optionalrepo = showconfig alias.myinit
   > cleanstatus = status -c
+  > cleanstatus:help = [ONLYHELPHERE]
   > unknown = bargle
   > ambiguous = s
   > recursive = recursive
@@ -20,9 +24,13 @@
   > no--config = status --config a.config=1
   > mylog = log
   > lognull = log -r null
+  > lognull:doc = Logs the null rev
+  > lognull:help = foo bar baz
   > shortlog = log --template '{rev} {node|short} | {date|isodate}\n'
   > positional = log --template '{\$2} {\$1} | {date|isodate}\n'
   > dln = lognull --debug
+  > recursivedoc = dln
+  > recursivedoc:doc = Logs the null rev in debug mode
   > nousage = rollback
   > put = export -r 0 -o "\$FOO/%R.diff"
   > blank = !printf '\n'
@@ -53,11 +61,148 @@
   > log = -v
   > EOF
 
-
 basic
 
   $ hg myinit alias
 
+help
+
+  $ hg help -c | grep myinit
+   myinit This is my documented alias for init.
+  $ hg help -c | grep mycommit
+   mycommit   This is my alias with only doc.
+  $ hg help -c | grep cleanstatus
+   cleanstatusshow changed files in the working directory
+  $ hg help -c | grep lognull
+   lognullLogs the null rev
+  $ hg help -c | grep dln
+   dlnLogs the null rev
+  $ hg help -c | grep recursivedoc
+   recursivedoc   Logs the null rev in debug mode
+  $ hg help myinit
+  hg myinit [OPTIONS] [BLA] [BLE]
+  
+  alias for: hg init
+  
+  This is my documented alias for init.
+  
+  defined by: * (glob)
+  */* (glob) (?)
+  */* (glob) (?)
+  */* (glob) (?)
+  
+  options:
+  
+   -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)
+  
+  (some details hidden, use --verbose to show complete help)
+
+  $ hg help mycommit
+  hg mycommit [OPTION]... [FILE]...
+  
+  alias for: hg commit
+  
+  This is my alias with only doc.
+  
+  defined by: * (glob)
+  */* (glob) (?)
+  */* (glob) (?)
+  */* (glob) (?)
+  
+  options ([+] can be repeated):
+  
+   -A --addremove   mark new/missing files as added/removed before
+committing
+  --close-branchmark a branch head as closed
+  --amend   amend the parent of the working directory
+   -s --secret  use the secret phase for committing
+   -e --editinvoke editor on commit messages
+   -i --interactive use interactive mode
+   -I --include PATTERN [+] include names matching the given patterns
+   -X --exclude PATTERN [+] exclude names matching the given patterns
+   -m --message TEXTuse text as commit message
+   -l --logfile FILEread commit message from file
+   -d --date DATE   record the specified date as commit date
+   -u --user USER   record the specified user as committer
+   -S --subreposrecurse into subrepositories
+  
+  (some details hidden, use --verbose to show complete help)
+
+  $ hg help cleanstatus
+  hg cleanstatus [ONLYHELPHERE]
+  
+  alias for: hg status -c
+  
+  show changed files in the working directory
+  
+  Show status of files in the repository. If names are given, only files
+  that match are shown. Files that are clean or ignored or the source of a
+  copy/move operation, are not listed unless -c/--clean, -i/--ignored,
+  -C/--copies or -A/--all are given. Unless options described with "show
+  only ..." are given, the options -mardu are used.
+  
+  Option -q/--quiet hides untracked (unknown and ignored) files unless
+  explicitly requested with -u/--unknown or -i/--ignored.
+  
+  Note:
+ 'hg status' may appear to disagree with diff if permissions have
+ changed or a merge has 

D2623: dispatch: adding config items for overriding flag defaults

2018-03-03 Thread rdamazio (Rodrigo Damazio Bovendorp)
rdamazio updated this revision to Diff 6523.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D2623?vs=6521=6523

REVISION DETAIL
  https://phab.mercurial-scm.org/D2623

AFFECTED FILES
  mercurial/configitems.py
  mercurial/dispatch.py
  mercurial/ui.py
  tests/test-dispatch.t

CHANGE DETAILS

diff --git a/tests/test-dispatch.t b/tests/test-dispatch.t
--- a/tests/test-dispatch.t
+++ b/tests/test-dispatch.t
@@ -8,8 +8,10 @@
   $ hg -v log -v x
 
   $ echo a > a
+  $ echo b > b
   $ hg ci -Ama
   adding a
+  adding b
 
 Missing arg:
 
@@ -52,10 +54,10 @@
 Parsing of early options should stop at "--":
 
   $ hg cat -- --config=hooks.pre-cat=false
-  --config=hooks.pre-cat=false: no such file in rev cb9a9f314b8b
+  --config=hooks.pre-cat=false: no such file in rev 0cd96de13884
   [1]
   $ hg cat -- --debugger
-  --debugger: no such file in rev cb9a9f314b8b
+  --debugger: no such file in rev 0cd96de13884
   [1]
 
 Unparsable form of early options:
@@ -155,31 +157,75 @@
   abort: pre-log hook exited with status 1
   [255]
   $ HGPLAIN=+strictflags hg --cwd .. -q -Ra log -b default
-  0:cb9a9f314b8b
+  0:0cd96de13884
   $ HGPLAIN=+strictflags hg --cwd .. -q --repository a log -b default
-  0:cb9a9f314b8b
+  0:0cd96de13884
   $ HGPLAIN=+strictflags hg --cwd .. -q --repo a log -b default
-  0:cb9a9f314b8b
+  0:0cd96de13884
 
 For compatibility reasons, HGPLAIN=+strictflags is not enabled by plain 
HGPLAIN:
 
   $ HGPLAIN= hg log --config='hooks.pre-log=false' -b default
   abort: pre-log hook exited with status 1
   [255]
   $ HGPLAINEXCEPT= hg log --cwd .. -q -Ra -b default
-  0:cb9a9f314b8b
+  0:0cd96de13884
 
 [defaults]
 
   $ hg cat a
   a
+  $ cp $HGRCPATH hgrc.bak
   $ cat >> $HGRCPATH < [defaults]
   > cat = -r null
   > EOF
   $ hg cat a
   a: no such file in rev 
   [1]
+  $ cp -f hgrc.bak $HGRCPATH
+
+new-style [commands] defaults and overrides
+
+  $ hg cat a
+  a
+  $ cat >> $HGRCPATH < [commands]
+  > cat.default.rev = null
+  > EOF
+  $ hg cat a
+  a: no such file in rev 
+  [1]
+
+  $ mv -f hgrc.bak $HGRCPATH
+  $ echo foo >> a
+  $ hg rm b
+  $ echo bar > c
+  $ hg add c
+  $ hg status
+  M a
+  A c
+  R b
+  ? bad.py
+  ? bad.pyc
+  $ cat >> $HGRCPATH < [commands]
+  > status.default.removed = 1
+  > EOF
+  $ hg status
+  R b
+  $ hg status --modified
+  M a
+  R b
+  $ hg status --modified --no-removed
+  M a
+  $ hg status --no-removed
+  M a
+  A c
+  R b
+  ? bad.py
+  ? bad.pyc
+  $ hg revert a b c
 
   $ cd "$TESTTMP"
 
diff --git a/mercurial/ui.py b/mercurial/ui.py
--- a/mercurial/ui.py
+++ b/mercurial/ui.py
@@ -379,10 +379,15 @@
 del cfg['defaults'][k]
 for k, v in cfg.items('commands'):
 del cfg['commands'][k]
-# Don't remove aliases from the configuration if in the exceptionlist
+# Don't remove specific sections from the configuration if in the
+# exception list.
 if self.plain('alias'):
 for k, v in cfg.items('alias'):
 del cfg['alias'][k]
+if self.plain('commanddefaults'):
+for k, v in cfg.items('commands'):
+if '.default.' in k:
+del cfg['commands'][k]
 if self.plain('revsetalias'):
 for k, v in cfg.items('revsetalias'):
 del cfg['revsetalias'][k]
diff --git a/mercurial/dispatch.py b/mercurial/dispatch.py
--- a/mercurial/dispatch.py
+++ b/mercurial/dispatch.py
@@ -611,6 +611,21 @@
 args = pycompat.maplist(
 util.expandpath, pycompat.shlexsplit(defaults)) + args
 c = list(entry[1])
+
+# Apply new-style defaults from config file by actually changing the
+# option defaults. We still let old-style defaults trump these (since
+# those are added to the command line).
+for idx, opt in enumerate(c):
+optname = opt[1]
+olddefault = opt[2]
+defaulttype = type(olddefault)
+cfgitem = "%s.default.%s" % (cmd, optname)
+# parse the new default as the same type as the original.
+newdefault = ui.configtyped("commands", cfgitem, defaulttype, 
olddefault)
+if olddefault != newdefault:
+# override the default in the flag declaration.
+c[idx] = (opt[0], opt[1], newdefault, opt[3])
+
 else:
 cmd = None
 c = []
diff --git a/mercurial/configitems.py b/mercurial/configitems.py
--- a/mercurial/configitems.py
+++ b/mercurial/configitems.py
@@ -184,6 +184,10 @@
 coreconfigitem('color', 'pagermode',
 default=dynamicdefault,
 )
+coreconfigitem('commands', '.*\.default\..*',
+generic=True,
+default=dynamicdefault,
+)
 coreconfigitem('commands', 'show.aliasprefix',
 default=list,
 )



To: rdamazio, #hg-reviewers
Cc: mercurial-devel
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org

D2623: dispatch: adding config items for overriding flag defaults

2018-03-03 Thread rdamazio (Rodrigo Damazio Bovendorp)
rdamazio created this revision.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.

REVISION SUMMARY
  This introduces the new defaults format "commandname.default.optionname" which
  directly overrides the default of the option, instead of prepending the
  command-line option. This is meant to replace the [defaults] section which is
  already deprecated in a manner that's easier and safer to use than creating
  aliases.

REPOSITORY
  rHG Mercurial

REVISION DETAIL
  https://phab.mercurial-scm.org/D2623

AFFECTED FILES
  mercurial/configitems.py
  mercurial/dispatch.py
  mercurial/ui.py
  tests/test-dispatch.t

CHANGE DETAILS

diff --git a/tests/test-dispatch.t b/tests/test-dispatch.t
--- a/tests/test-dispatch.t
+++ b/tests/test-dispatch.t
@@ -8,8 +8,10 @@
   $ hg -v log -v x
 
   $ echo a > a
+  $ echo b > b
   $ hg ci -Ama
   adding a
+  adding b
 
 Missing arg:
 
@@ -52,10 +54,10 @@
 Parsing of early options should stop at "--":
 
   $ hg cat -- --config=hooks.pre-cat=false
-  --config=hooks.pre-cat=false: no such file in rev cb9a9f314b8b
+  --config=hooks.pre-cat=false: no such file in rev 0cd96de13884
   [1]
   $ hg cat -- --debugger
-  --debugger: no such file in rev cb9a9f314b8b
+  --debugger: no such file in rev 0cd96de13884
   [1]
 
 Unparsable form of early options:
@@ -155,31 +157,75 @@
   abort: pre-log hook exited with status 1
   [255]
   $ HGPLAIN=+strictflags hg --cwd .. -q -Ra log -b default
-  0:cb9a9f314b8b
+  0:0cd96de13884
   $ HGPLAIN=+strictflags hg --cwd .. -q --repository a log -b default
-  0:cb9a9f314b8b
+  0:0cd96de13884
   $ HGPLAIN=+strictflags hg --cwd .. -q --repo a log -b default
-  0:cb9a9f314b8b
+  0:0cd96de13884
 
 For compatibility reasons, HGPLAIN=+strictflags is not enabled by plain 
HGPLAIN:
 
   $ HGPLAIN= hg log --config='hooks.pre-log=false' -b default
   abort: pre-log hook exited with status 1
   [255]
   $ HGPLAINEXCEPT= hg log --cwd .. -q -Ra -b default
-  0:cb9a9f314b8b
+  0:0cd96de13884
 
 [defaults]
 
   $ hg cat a
   a
+  $ cp $HGRCPATH hgrc.bak
   $ cat >> $HGRCPATH < [defaults]
   > cat = -r null
   > EOF
   $ hg cat a
   a: no such file in rev 
   [1]
+  $ cp -f hgrc.bak $HGRCPATH
+
+new-style [commands] defaults and overrides
+
+  $ hg cat a
+  a
+  $ cat >> $HGRCPATH < [commands]
+  > cat.default.rev = null
+  > EOF
+  $ hg cat a
+  a: no such file in rev 
+  [1]
+
+  $ mv -f hgrc.bak $HGRCPATH
+  $ echo foo >> a
+  $ hg rm b
+  $ echo bar > c
+  $ hg add c
+  $ hg status
+  M a
+  A c
+  R b
+  ? bad.py
+  ? bad.pyc
+  $ cat >> $HGRCPATH < [commands]
+  > status.default.removed = 1
+  > EOF
+  $ hg status
+  R b
+  $ hg status --modified
+  M a
+  R b
+  $ hg status --modified --no-removed
+  M a
+  $ hg status --no-removed
+  M a
+  A c
+  R b
+  ? bad.py
+  ? bad.pyc
+  $ hg revert a b c
 
   $ cd "$TESTTMP"
 
diff --git a/mercurial/ui.py b/mercurial/ui.py
--- a/mercurial/ui.py
+++ b/mercurial/ui.py
@@ -379,10 +379,15 @@
 del cfg['defaults'][k]
 for k, v in cfg.items('commands'):
 del cfg['commands'][k]
-# Don't remove aliases from the configuration if in the exceptionlist
+# Don't remove specific sections from the configuration if in the
+# exception list.
 if self.plain('alias'):
 for k, v in cfg.items('alias'):
 del cfg['alias'][k]
+if self.plain('commanddefaults'):
+for k, v in cfg.items('commands'):
+if '.default.' in k:
+   del cfg['commands'][k]
 if self.plain('revsetalias'):
 for k, v in cfg.items('revsetalias'):
 del cfg['revsetalias'][k]
diff --git a/mercurial/dispatch.py b/mercurial/dispatch.py
--- a/mercurial/dispatch.py
+++ b/mercurial/dispatch.py
@@ -611,6 +611,21 @@
 args = pycompat.maplist(
 util.expandpath, pycompat.shlexsplit(defaults)) + args
 c = list(entry[1])
+
+# Apply new-style defaults from config file by actually changing the
+# option defaults. We still let old-style defaults trump these (since
+# those are added to the command line).
+for idx, opt in enumerate(c):
+optname = opt[1]
+olddefault = opt[2]
+defaulttype = type(olddefault)
+cfgitem = "%s.default.%s" % (cmd, optname)
+# parse the new default as the same type as the original.
+newdefault = ui.configtyped("commands", cfgitem, defaulttype, 
olddefault)
+if olddefault != newdefault:
+# override the default in the flag declaration.
+c[idx] = (opt[0], opt[1], newdefault, opt[3])
+
 else:
 cmd = None
 c = []
diff --git a/mercurial/configitems.py b/mercurial/configitems.py
--- a/mercurial/configitems.py
+++ b/mercurial/configitems.py
@@ -184,6 +184,10 @@
 coreconfigitem('color', 'pagermode',
 default=dynamicdefault,
 )

D2622: ui: adding a generic method to read config items with an arbitrary type

2018-03-03 Thread rdamazio (Rodrigo Damazio Bovendorp)
rdamazio created this revision.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.

REVISION SUMMARY
  This can be used for reading many config options of various types where the
  type of each is known in some other structure (e.g. options matching command
  flags).

REPOSITORY
  rHG Mercurial

REVISION DETAIL
  https://phab.mercurial-scm.org/D2622

AFFECTED FILES
  mercurial/ui.py

CHANGE DETAILS

diff --git a/mercurial/ui.py b/mercurial/ui.py
--- a/mercurial/ui.py
+++ b/mercurial/ui.py
@@ -545,6 +545,16 @@
 
 return main, sub
 
+def configtyped(self, section, name, itemtype, default=_unset, 
untrusted=False):
+"""Get a config item as the given type."""
+if itemtype is type(False) or itemtype is type(None):
+return self.configbool(section, name, default, untrusted)
+if itemtype is type(1):
+return self.configint(section, name, default, untrusted)
+if itemtype is type([]):
+return self.configlist(section, name, default, untrusted)
+return self.config(section, name, default, untrusted)
+
 def configpath(self, section, name, default=_unset, untrusted=False):
 'get a path config item, expanded relative to repo root or config file'
 v = self.config(section, name, default, untrusted)



To: rdamazio, #hg-reviewers
Cc: mercurial-devel
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


D2623: dispatch: adding config items for overriding flag defaults

2018-03-03 Thread rdamazio (Rodrigo Damazio Bovendorp)
rdamazio added a comment.


  FYI this is a change I had previously sent to the list as 
60b3222e01f96f91ece7eda9681a89bf3bb930a6, and Yuya reviewed . I just had never 
followed up on it.

REPOSITORY
  rHG Mercurial

REVISION DETAIL
  https://phab.mercurial-scm.org/D2623

To: rdamazio, #hg-reviewers
Cc: mercurial-devel
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


D2623: dispatch: adding config items for overriding flag defaults

2018-03-04 Thread rdamazio (Rodrigo Damazio Bovendorp)
rdamazio added inline comments.

INLINE COMMENTS

> yuja wrote in dispatch.py:624
> Maybe this type conversion can be a `fancyopt.customopt` method since we've
> refactored the default handling by https://phab.mercurial-scm.org/D2090?
> 
>   # no idea if _defaultopt() should be made public or the whole 
> commands.default handling
>   # should be moved to fancyopts
>   x = fancyopts._defaultopt(olddefault)
>   newdefault = x.configdefault(ui, cmd, optname, ...)
> 
> @dploch, any suggestions?

The issue is that customopt (and all its children) assume the value type is 
already the correct one, and thus do not perform any conversion. Since we're 
parsing values from the config file, the conversion is desired to ensure they 
don't all end up as text - the config{bool,int,etc} methods called by 
configtyped perform the proper conversion. In most cases (all commands that 
declare default values) no conversio is needed since those already have the 
correct type.

> yuja wrote in ui.py:390
> Perhaps this is noop since `[commands]` is removed at all if `ui.plain()` 
> returns True.

You're right, I had the plain logic inverted in my head. Removed.

REPOSITORY
  rHG Mercurial

REVISION DETAIL
  https://phab.mercurial-scm.org/D2623

To: rdamazio, #hg-reviewers, yuja
Cc: dploch, mercurial-devel
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


D2623: dispatch: adding config items for overriding flag defaults

2018-03-04 Thread rdamazio (Rodrigo Damazio Bovendorp)
rdamazio updated this revision to Diff 6548.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D2623?vs=6523=6548

REVISION DETAIL
  https://phab.mercurial-scm.org/D2623

AFFECTED FILES
  mercurial/configitems.py
  mercurial/dispatch.py
  tests/test-dispatch.t

CHANGE DETAILS

diff --git a/tests/test-dispatch.t b/tests/test-dispatch.t
--- a/tests/test-dispatch.t
+++ b/tests/test-dispatch.t
@@ -8,8 +8,10 @@
   $ hg -v log -v x
 
   $ echo a > a
+  $ echo b > b
   $ hg ci -Ama
   adding a
+  adding b
 
 Missing arg:
 
@@ -52,10 +54,10 @@
 Parsing of early options should stop at "--":
 
   $ hg cat -- --config=hooks.pre-cat=false
-  --config=hooks.pre-cat=false: no such file in rev cb9a9f314b8b
+  --config=hooks.pre-cat=false: no such file in rev 0cd96de13884
   [1]
   $ hg cat -- --debugger
-  --debugger: no such file in rev cb9a9f314b8b
+  --debugger: no such file in rev 0cd96de13884
   [1]
 
 Unparsable form of early options:
@@ -155,31 +157,75 @@
   abort: pre-log hook exited with status 1
   [255]
   $ HGPLAIN=+strictflags hg --cwd .. -q -Ra log -b default
-  0:cb9a9f314b8b
+  0:0cd96de13884
   $ HGPLAIN=+strictflags hg --cwd .. -q --repository a log -b default
-  0:cb9a9f314b8b
+  0:0cd96de13884
   $ HGPLAIN=+strictflags hg --cwd .. -q --repo a log -b default
-  0:cb9a9f314b8b
+  0:0cd96de13884
 
 For compatibility reasons, HGPLAIN=+strictflags is not enabled by plain 
HGPLAIN:
 
   $ HGPLAIN= hg log --config='hooks.pre-log=false' -b default
   abort: pre-log hook exited with status 1
   [255]
   $ HGPLAINEXCEPT= hg log --cwd .. -q -Ra -b default
-  0:cb9a9f314b8b
+  0:0cd96de13884
 
 [defaults]
 
   $ hg cat a
   a
+  $ cp $HGRCPATH hgrc.bak
   $ cat >> $HGRCPATH < [defaults]
   > cat = -r null
   > EOF
   $ hg cat a
   a: no such file in rev 
   [1]
+  $ cp -f hgrc.bak $HGRCPATH
+
+new-style [commands] defaults and overrides
+
+  $ hg cat a
+  a
+  $ cat >> $HGRCPATH < [commands]
+  > cat.default.rev = null
+  > EOF
+  $ hg cat a
+  a: no such file in rev 
+  [1]
+
+  $ mv -f hgrc.bak $HGRCPATH
+  $ echo foo >> a
+  $ hg rm b
+  $ echo bar > c
+  $ hg add c
+  $ hg status
+  M a
+  A c
+  R b
+  ? bad.py
+  ? bad.pyc
+  $ cat >> $HGRCPATH < [commands]
+  > status.default.removed = 1
+  > EOF
+  $ hg status
+  R b
+  $ hg status --modified
+  M a
+  R b
+  $ hg status --modified --no-removed
+  M a
+  $ hg status --no-removed
+  M a
+  A c
+  R b
+  ? bad.py
+  ? bad.pyc
+  $ hg revert a b c
 
   $ cd "$TESTTMP"
 
diff --git a/mercurial/dispatch.py b/mercurial/dispatch.py
--- a/mercurial/dispatch.py
+++ b/mercurial/dispatch.py
@@ -611,6 +611,21 @@
 args = pycompat.maplist(
 util.expandpath, pycompat.shlexsplit(defaults)) + args
 c = list(entry[1])
+
+# Apply new-style defaults from config file by actually changing the
+# option defaults. We still let old-style defaults trump these (since
+# those are added to the command line).
+for idx, opt in enumerate(c):
+optname = opt[1]
+olddefault = opt[2]
+defaulttype = type(olddefault)
+cfgitem = "%s.default.%s" % (cmd, optname)
+# parse the new default as the same type as the original.
+newdefault = ui.configtyped("commands", cfgitem, defaulttype, 
olddefault)
+if olddefault != newdefault:
+# override the default in the flag declaration.
+c[idx] = (opt[0], opt[1], newdefault, opt[3])
+
 else:
 cmd = None
 c = []
diff --git a/mercurial/configitems.py b/mercurial/configitems.py
--- a/mercurial/configitems.py
+++ b/mercurial/configitems.py
@@ -184,6 +184,10 @@
 coreconfigitem('color', 'pagermode',
 default=dynamicdefault,
 )
+coreconfigitem('commands', '.*\.default\..*',
+generic=True,
+default=dynamicdefault,
+)
 coreconfigitem('commands', 'show.aliasprefix',
 default=list,
 )



To: rdamazio, #hg-reviewers, yuja
Cc: dploch, mercurial-devel
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


D2623: dispatch: adding config items for overriding flag defaults

2018-03-04 Thread rdamazio (Rodrigo Damazio Bovendorp)
rdamazio added inline comments.

INLINE COMMENTS

> yuja wrote in dispatch.py:624
> IIUC, an extension author may implement its own customopt subclasses, and
> put them into the command table, so we can't make ui.configtyped to
> support all of them.

Ah, makes sense. See if this addresses that case satisfactorily - it still has 
the caveat of not being able to "reset" container types, but that's true of the 
command line as well (if you have a list flag with a non-empty default, there's 
no way to remove that default item).

REPOSITORY
  rHG Mercurial

REVISION DETAIL
  https://phab.mercurial-scm.org/D2623

To: rdamazio, #hg-reviewers, yuja
Cc: dploch, mercurial-devel
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


D2623: dispatch: adding config items for overriding flag defaults

2018-03-04 Thread rdamazio (Rodrigo Damazio Bovendorp)
rdamazio updated this revision to Diff 6609.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D2623?vs=6548=6609

REVISION DETAIL
  https://phab.mercurial-scm.org/D2623

AFFECTED FILES
  mercurial/configitems.py
  mercurial/dispatch.py
  mercurial/ui.py
  tests/test-dispatch.t

CHANGE DETAILS

diff --git a/tests/test-dispatch.t b/tests/test-dispatch.t
--- a/tests/test-dispatch.t
+++ b/tests/test-dispatch.t
@@ -8,8 +8,10 @@
   $ hg -v log -v x
 
   $ echo a > a
+  $ echo b > b
   $ hg ci -Ama
   adding a
+  adding b
 
 Missing arg:
 
@@ -52,10 +54,10 @@
 Parsing of early options should stop at "--":
 
   $ hg cat -- --config=hooks.pre-cat=false
-  --config=hooks.pre-cat=false: no such file in rev cb9a9f314b8b
+  --config=hooks.pre-cat=false: no such file in rev 0cd96de13884
   [1]
   $ hg cat -- --debugger
-  --debugger: no such file in rev cb9a9f314b8b
+  --debugger: no such file in rev 0cd96de13884
   [1]
 
 Unparsable form of early options:
@@ -155,31 +157,75 @@
   abort: pre-log hook exited with status 1
   [255]
   $ HGPLAIN=+strictflags hg --cwd .. -q -Ra log -b default
-  0:cb9a9f314b8b
+  0:0cd96de13884
   $ HGPLAIN=+strictflags hg --cwd .. -q --repository a log -b default
-  0:cb9a9f314b8b
+  0:0cd96de13884
   $ HGPLAIN=+strictflags hg --cwd .. -q --repo a log -b default
-  0:cb9a9f314b8b
+  0:0cd96de13884
 
 For compatibility reasons, HGPLAIN=+strictflags is not enabled by plain 
HGPLAIN:
 
   $ HGPLAIN= hg log --config='hooks.pre-log=false' -b default
   abort: pre-log hook exited with status 1
   [255]
   $ HGPLAINEXCEPT= hg log --cwd .. -q -Ra -b default
-  0:cb9a9f314b8b
+  0:0cd96de13884
 
 [defaults]
 
   $ hg cat a
   a
+  $ cp $HGRCPATH hgrc.bak
   $ cat >> $HGRCPATH < [defaults]
   > cat = -r null
   > EOF
   $ hg cat a
   a: no such file in rev 
   [1]
+  $ cp -f hgrc.bak $HGRCPATH
+
+new-style [commands] defaults and overrides
+
+  $ hg cat a
+  a
+  $ cat >> $HGRCPATH < [commands]
+  > cat.default.rev = null
+  > EOF
+  $ hg cat a
+  a: no such file in rev 
+  [1]
+
+  $ mv -f hgrc.bak $HGRCPATH
+  $ echo foo >> a
+  $ hg rm b
+  $ echo bar > c
+  $ hg add c
+  $ hg status
+  M a
+  A c
+  R b
+  ? bad.py
+  ? bad.pyc
+  $ cat >> $HGRCPATH < [commands]
+  > status.default.removed = 1
+  > EOF
+  $ hg status
+  R b
+  $ hg status --modified
+  M a
+  R b
+  $ hg status --modified --no-removed
+  M a
+  $ hg status --no-removed
+  M a
+  A c
+  R b
+  ? bad.py
+  ? bad.pyc
+  $ hg revert a b c
 
   $ cd "$TESTTMP"
 
diff --git a/mercurial/ui.py b/mercurial/ui.py
--- a/mercurial/ui.py
+++ b/mercurial/ui.py
@@ -545,7 +545,8 @@
 
 return main, sub
 
-def configtyped(self, section, name, itemtype, default=_unset, 
untrusted=False):
+def configtyped(self, section, name, itemtype, default=_unset,
+untrusted=False):
 """Get a config item as the given type."""
 if itemtype is type(False) or itemtype is type(None):
 return self.configbool(section, name, default, untrusted)
diff --git a/mercurial/dispatch.py b/mercurial/dispatch.py
--- a/mercurial/dispatch.py
+++ b/mercurial/dispatch.py
@@ -611,6 +611,37 @@
 args = pycompat.maplist(
 util.expandpath, pycompat.shlexsplit(defaults)) + args
 c = list(entry[1])
+
+# Apply new-style defaults from config file by actually changing the
+# option defaults. We still let old-style defaults trump these (since
+# those are added to the command line).
+for idx, opt in enumerate(c):
+optname = opt[1]
+olddefault = opt[2]
+defaulttype = type(olddefault)
+cfgitem = "%s.default.%s" % (cmd, optname)
+
+# parse the new default as the same type as the original.
+newdefault = ui.configtyped("commands", cfgitem, defaulttype,
+olddefault)
+if isinstance(olddefault, fancyopts.customopt):
+def badvalue(s):
+raise error.Abort(
+_('invalid value %r for config option %s: %s') % (
+newdefault, cfgitem, s))
+
+# If it's a custom option, then configtyped must have parsed it
+# as string - ask the customopt to parse its new default.
+# Notice this does have limitations - since we have no way to
+# start with a "clean" old state, this is not overriding the
+# default, but rather adding to it - e.g. a non-empty list
+# default will be appended to.
+olddefault.defaultvalue = olddefault.newstate(
+olddefault.defaultvalue, newdefault, badvalue)
+elif olddefault != newdefault:
+# override the default in the flag declaration.
+c[idx] = (opt[0], opt[1], newdefault, opt[3])
+
 else:
 cmd = None
 

D2678: help: supporting both help and doc for aliases

2018-03-04 Thread rdamazio (Rodrigo Damazio Bovendorp)
rdamazio created this revision.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.

REVISION SUMMARY
  This allows an alias to be definted like:
  
  [alias]
  lj = log -Tjson
  lj:help = [-r REV]
  lj:doc = Shows the revision log in JSON format.

REPOSITORY
  rHG Mercurial

REVISION DETAIL
  https://phab.mercurial-scm.org/D2678

AFFECTED FILES
  mercurial/configitems.py
  mercurial/dispatch.py

CHANGE DETAILS

diff --git a/mercurial/dispatch.py b/mercurial/dispatch.py
--- a/mercurial/dispatch.py
+++ b/mercurial/dispatch.py
@@ -420,7 +420,7 @@
 return r.sub(lambda x: replacemap[x.group()], cmd)
 
 class cmdalias(object):
-def __init__(self, name, definition, cmdtable, source):
+def __init__(self, ui, name, definition, cmdtable, source):
 self.name = self.cmd = name
 self.cmdname = ''
 self.definition = definition
@@ -447,6 +447,7 @@
 return
 
 if self.definition.startswith('!'):
+shdef = self.definition[1:]
 self.shell = True
 def fn(ui, *args):
 env = {'HG_ARGS': ' '.join((self.name,) + args)}
@@ -460,11 +461,12 @@
  "of %i variable in alias '%s' definition.\n"
  % (int(m.groups()[0]), self.name))
 return ''
-cmd = re.sub(br'\$(\d+|\$)', _checkvar, self.definition[1:])
+cmd = re.sub(br'\$(\d+|\$)', _checkvar, shdef)
 cmd = aliasinterpolate(self.name, args, cmd)
 return ui.system(cmd, environ=env,
  blockedtag='alias_%s' % self.name)
 self.fn = fn
+self._populatehelp(ui, name, shdef, self.fn)
 return
 
 try:
@@ -486,14 +488,12 @@
 try:
 tableentry = cmdutil.findcmd(cmd, cmdtable, False)[1]
 if len(tableentry) > 2:
-self.fn, self.opts, self.help = tableentry
+self.fn, self.opts, cmdhelp = tableentry
 else:
 self.fn, self.opts = tableentry
+cmdhelp = None
 
-if self.help.startswith("hg " + cmd):
-# drop prefix in old-style help lines so hg shows the alias
-self.help = self.help[4 + len(cmd):]
-self.__doc__ = self.fn.__doc__
+self._populatehelp(ui, name, cmd, self.fn, cmdhelp)
 
 except error.UnknownCommand:
 self.badalias = (_("alias '%s' resolves to unknown command '%s'")
@@ -503,6 +503,14 @@
 self.badalias = (_("alias '%s' resolves to ambiguous command '%s'")
  % (self.name, cmd))
 
+def _populatehelp(self, ui, name, cmd, fn, defaulthelp=None):
+self.help = ui.config('alias', '%s:help' % name, defaulthelp or '')
+if self.help and self.help.startswith("hg " + cmd):
+# drop prefix in old-style help lines so hg shows the alias
+self.help = self.help[4 + len(cmd):]
+
+self.__doc__ = ui.config('alias', '%s:doc' % name, fn.__doc__)
+
 @property
 def args(self):
 args = pycompat.maplist(util.expandpath, self.givenargs)
@@ -547,15 +555,17 @@
 class lazyaliasentry(object):
 """like a typical command entry (func, opts, help), but is lazy"""
 
-def __init__(self, name, definition, cmdtable, source):
+def __init__(self, ui, name, definition, cmdtable, source):
+self.ui = ui
 self.name = name
 self.definition = definition
 self.cmdtable = cmdtable.copy()
 self.source = source
 
 @util.propertycache
 def _aliasdef(self):
-return cmdalias(self.name, self.definition, self.cmdtable, self.source)
+return cmdalias(self.ui, self.name, self.definition, self.cmdtable,
+self.source)
 
 def __getitem__(self, n):
 aliasdef = self._aliasdef
@@ -579,16 +589,16 @@
 # aliases are processed after extensions have been loaded, so they
 # may use extension commands. Aliases can also use other alias definitions,
 # but only if they have been defined prior to the current definition.
-for alias, definition in ui.configitems('alias'):
+for alias, definition in ui.configitems('alias', ignoresub=True):
 try:
 if cmdtable[alias].definition == definition:
 continue
 except (KeyError, AttributeError):
 # definition might not exist or it might not be a cmdalias
 pass
 
 source = ui.configsource('alias', alias)
-entry = lazyaliasentry(alias, definition, cmdtable, source)
+entry = lazyaliasentry(ui, alias, definition, cmdtable, source)
 cmdtable[alias] = entry
 
 def _parse(ui, args):
diff --git a/mercurial/configitems.py b/mercurial/configitems.py
--- a/mercurial/configitems.py
+++ b/mercurial/configitems.py
@@ -114,7 +114,7 @@
 coreconfigitem = 

D2678: help: supporting both help and doc for aliases

2018-03-04 Thread rdamazio (Rodrigo Damazio Bovendorp)
rdamazio added a comment.


  (I'll have more test updates in a min, sorry, please hold :) )

REPOSITORY
  rHG Mercurial

REVISION DETAIL
  https://phab.mercurial-scm.org/D2678

To: rdamazio, #hg-reviewers
Cc: pulkit, mercurial-devel
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


D2678: help: supporting both help and doc for aliases

2018-03-04 Thread rdamazio (Rodrigo Damazio Bovendorp)
rdamazio updated this revision to Diff 6634.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D2678?vs=6632=6634

REVISION DETAIL
  https://phab.mercurial-scm.org/D2678

AFFECTED FILES
  mercurial/configitems.py
  mercurial/dispatch.py
  mercurial/help.py
  tests/test-alias.t

CHANGE DETAILS

diff --git a/tests/test-alias.t b/tests/test-alias.t
--- a/tests/test-alias.t
+++ b/tests/test-alias.t
@@ -4,6 +4,8 @@
   > # should clobber ci but not commit (issue2993)
   > ci = version
   > myinit = init
+  > myinit:doc = This is my documented alias for init.
+  > myinit:help = [OPTIONS] [BLA] [BLE]
   > mycommit = commit
   > optionalrepo = showconfig alias.myinit
   > cleanstatus = status -c
@@ -53,11 +55,34 @@
   > log = -v
   > EOF
 
-
 basic
 
   $ hg myinit alias
 
+help
+
+  $ hg help -c | grep myinit
+   myinit This is my documented alias for init.
+  $ hg help myinit
+  hg myinit [OPTIONS] [BLA] [BLE]
+  
+  alias for: hg init
+  
+  This is my documented alias for init.
+  
+  defined by: * (glob)
+  */* (glob) (?)
+  */* (glob) (?)
+  */* (glob) (?)
+  
+  options:
+  
+   -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)
+  
+  (some details hidden, use --verbose to show complete help)
 
 unknown
 
@@ -440,6 +465,10 @@
   > rebate = !echo this is \$HG_ARGS
   > EOF
 #endif
+  $ cat >> .hg/hgrc < rebate:doc = This is my alias which just prints something.
+  > rebate:help = [MYARGS]
+  > EOF
   $ hg reba
   hg: command 'reba' is ambiguous:
   rebase rebate
@@ -449,6 +478,24 @@
   $ hg rebat --foo-bar
   this is rebate --foo-bar
 
+help for a shell alias
+
+  $ hg help -c | grep rebate
+   rebate This is my alias which just prints something.
+  $ hg help rebate
+  hg rebate [MYARGS]
+  
+  shell alias for:: echo this is $HG_ARGS
+  
+  This is my alias which just prints something.
+  
+  defined by:* (glob)
+  */* (glob) (?)
+  */* (glob) (?)
+  */* (glob) (?)
+  
+  (some details hidden, use --verbose to show complete help)
+
 invalid arguments
 
   $ hg rt foo
diff --git a/mercurial/help.py b/mercurial/help.py
--- a/mercurial/help.py
+++ b/mercurial/help.py
@@ -366,8 +366,8 @@
 if util.safehasattr(entry[0], 'definition'):  # aliased command
 source = entry[0].source
 if entry[0].definition.startswith('!'):  # shell alias
-doc = (_('shell alias for::\n\n%s\n\ndefined by: %s\n') %
-   (entry[0].definition[1:], source))
+doc = (_('shell alias for:: %s\n\n%s\n\ndefined by: %s\n') %
+   (entry[0].definition[1:], doc, source))
 else:
 doc = (_('alias for: hg %s\n\n%s\n\ndefined by: %s\n') %
(entry[0].definition, doc, source))
diff --git a/mercurial/dispatch.py b/mercurial/dispatch.py
--- a/mercurial/dispatch.py
+++ b/mercurial/dispatch.py
@@ -420,7 +420,7 @@
 return r.sub(lambda x: replacemap[x.group()], cmd)
 
 class cmdalias(object):
-def __init__(self, name, definition, cmdtable, source):
+def __init__(self, ui, name, definition, cmdtable, source):
 self.name = self.cmd = name
 self.cmdname = ''
 self.definition = definition
@@ -447,6 +447,7 @@
 return
 
 if self.definition.startswith('!'):
+shdef = self.definition[1:]
 self.shell = True
 def fn(ui, *args):
 env = {'HG_ARGS': ' '.join((self.name,) + args)}
@@ -460,11 +461,12 @@
  "of %i variable in alias '%s' definition.\n"
  % (int(m.groups()[0]), self.name))
 return ''
-cmd = re.sub(br'\$(\d+|\$)', _checkvar, self.definition[1:])
+cmd = re.sub(br'\$(\d+|\$)', _checkvar, shdef)
 cmd = aliasinterpolate(self.name, args, cmd)
 return ui.system(cmd, environ=env,
  blockedtag='alias_%s' % self.name)
 self.fn = fn
+self._populatehelp(ui, name, shdef, self.fn)
 return
 
 try:
@@ -486,14 +488,12 @@
 try:
 tableentry = cmdutil.findcmd(cmd, cmdtable, False)[1]
 if len(tableentry) > 2:
-self.fn, self.opts, self.help = tableentry
+self.fn, self.opts, cmdhelp = tableentry
 else:
 self.fn, self.opts = tableentry
+cmdhelp = None
 
-if self.help.startswith("hg " + cmd):
-# drop prefix in old-style help lines so hg shows the alias
-self.help = self.help[4 + len(cmd):]
-self.__doc__ = self.fn.__doc__
+self._populatehelp(ui, name, cmd, self.fn, cmdhelp)
 
 except 

D2678: help: supporting both help and doc for aliases

2018-03-04 Thread rdamazio (Rodrigo Damazio Bovendorp)
rdamazio added a comment.


  In https://phab.mercurial-scm.org/D2678#43196, @pulkit wrote:
  
  > I am very very much excited about this. But, this patch lacks test. :(
  
  
  Sorry, added now (and re-running tests in parallel)

REPOSITORY
  rHG Mercurial

REVISION DETAIL
  https://phab.mercurial-scm.org/D2678

To: rdamazio, #hg-reviewers
Cc: pulkit, mercurial-devel
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


D2678: help: supporting both help and doc for aliases

2018-03-04 Thread rdamazio (Rodrigo Damazio Bovendorp)
rdamazio updated this revision to Diff 6635.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D2678?vs=6634=6635

REVISION DETAIL
  https://phab.mercurial-scm.org/D2678

AFFECTED FILES
  mercurial/configitems.py
  mercurial/dispatch.py
  mercurial/help.py
  tests/test-alias.t
  tests/test-help.t

CHANGE DETAILS

diff --git a/tests/test-help.t b/tests/test-help.t
--- a/tests/test-help.t
+++ b/tests/test-help.t
@@ -769,9 +769,9 @@
   $ hg help shellalias
   hg shellalias
   
-  shell alias for:
-  
-echo hi
+  shell alias for: echo hi
+  
+  (no help text available)
   
   defined by: helpext
   
diff --git a/tests/test-alias.t b/tests/test-alias.t
--- a/tests/test-alias.t
+++ b/tests/test-alias.t
@@ -4,9 +4,13 @@
   > # should clobber ci but not commit (issue2993)
   > ci = version
   > myinit = init
+  > myinit:doc = This is my documented alias for init.
+  > myinit:help = [OPTIONS] [BLA] [BLE]
   > mycommit = commit
+  > mycommit:doc = This is my alias with only doc.
   > optionalrepo = showconfig alias.myinit
   > cleanstatus = status -c
+  > cleanstatus:help = [ONLYHELPHERE]
   > unknown = bargle
   > ambiguous = s
   > recursive = recursive
@@ -53,11 +57,135 @@
   > log = -v
   > EOF
 
-
 basic
 
   $ hg myinit alias
 
+help
+
+  $ hg help -c | grep myinit
+   myinit This is my documented alias for init.
+  $ hg help -c | grep mycommit
+   mycommit   This is my alias with only doc.
+  $ hg help -c | grep cleanstatus
+   cleanstatusshow changed files in the working directory
+  $ hg help myinit
+  hg myinit [OPTIONS] [BLA] [BLE]
+  
+  alias for: hg init
+  
+  This is my documented alias for init.
+  
+  defined by: * (glob)
+  */* (glob) (?)
+  */* (glob) (?)
+  */* (glob) (?)
+  
+  options:
+  
+   -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)
+  
+  (some details hidden, use --verbose to show complete help)
+
+  $ hg help mycommit
+  hg mycommit [OPTION]... [FILE]...
+  
+  alias for: hg commit
+  
+  This is my alias with only doc.
+  
+  defined by: * (glob)
+  */* (glob) (?)
+  */* (glob) (?)
+  */* (glob) (?)
+  
+  options ([+] can be repeated):
+  
+   -A --addremove   mark new/missing files as added/removed before
+committing
+  --close-branchmark a branch head as closed
+  --amend   amend the parent of the working directory
+   -s --secret  use the secret phase for committing
+   -e --editinvoke editor on commit messages
+   -i --interactive use interactive mode
+   -I --include PATTERN [+] include names matching the given patterns
+   -X --exclude PATTERN [+] exclude names matching the given patterns
+   -m --message TEXTuse text as commit message
+   -l --logfile FILEread commit message from file
+   -d --date DATE   record the specified date as commit date
+   -u --user USER   record the specified user as committer
+   -S --subreposrecurse into subrepositories
+  
+  (some details hidden, use --verbose to show complete help)
+
+  $ hg help cleanstatus
+  hg cleanstatus [ONLYHELPHERE]
+  
+  alias for: hg status -c
+  
+  show changed files in the working directory
+  
+  Show status of files in the repository. If names are given, only files
+  that match are shown. Files that are clean or ignored or the source of a
+  copy/move operation, are not listed unless -c/--clean, -i/--ignored,
+  -C/--copies or -A/--all are given. Unless options described with "show
+  only ..." are given, the options -mardu are used.
+  
+  Option -q/--quiet hides untracked (unknown and ignored) files unless
+  explicitly requested with -u/--unknown or -i/--ignored.
+  
+  Note:
+ 'hg status' may appear to disagree with diff if permissions have
+ changed or a merge has occurred. The standard diff format does not
+ report permission changes and diff only reports changes relative to 
one
+ merge parent.
+  
+  If one revision is given, it is used as the base revision. If two
+  revisions are given, the differences between them are shown. The --change
+  option can also be used as a shortcut to list the changed files of a
+  revision from its first parent.
+  
+  The codes used to show the status of files are:
+  
+M = modified
+A = added
+R = removed
+C = clean
+! = missing (deleted by non-hg command, but still tracked)
+? = not tracked
+I = ignored
+  = origin of the previous file (with --copies)
+  
+  Returns 0 on success.
+  
+  defined by: * (glob)
+  */* (glob) (?)
+  */* (glob) (?)
+  */* (glob) (?)
+  
+  options ([+] can be repeated):
+  
+   -A --all 

D2678: help: supporting both help and doc for aliases

2018-03-04 Thread rdamazio (Rodrigo Damazio Bovendorp)
rdamazio added a comment.


  Ok, should be good to go now :)

REPOSITORY
  rHG Mercurial

REVISION DETAIL
  https://phab.mercurial-scm.org/D2678

To: rdamazio, #hg-reviewers
Cc: pulkit, mercurial-devel
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


D5069: help: adding a proper declaration for shortlist/basic commands

2018-10-13 Thread rdamazio (Rodrigo Damazio Bovendorp)
rdamazio added a comment.


  Done now.

REPOSITORY
  rHG Mercurial

REVISION DETAIL
  https://phab.mercurial-scm.org/D5069

To: rdamazio, #hg-reviewers
Cc: mercurial-devel
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


D5068: help: assigning topic categories

2018-10-13 Thread rdamazio (Rodrigo Damazio Bovendorp)
rdamazio updated this revision to Diff 12063.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D5068?vs=12042=12063

REVISION DETAIL
  https://phab.mercurial-scm.org/D5068

AFFECTED FILES
  doc/gendoc.py
  mercurial/help.py
  tests/test-globalopts.t
  tests/test-help.t

CHANGE DETAILS

diff --git a/tests/test-help.t b/tests/test-help.t
--- a/tests/test-help.t
+++ b/tests/test-help.t
@@ -138,29 +138,43 @@
   
   additional help topics:
   
-   bundlespecBundle File Formats
+  Mercurial identifiers:
+  
+   filesets  Specifying File Sets
+   hgignore  Syntax for Mercurial Ignore Files
+   patterns  File Name Patterns
+   revisions Specifying Revisions
+   urls  URL Paths
+  
+  Mercurial output:
+  
color Colorizing Outputs
+   dates Date Formats
+   diffs Diff Formats
+   templatingTemplate Usage
+  
+  Mercurial configuration:
+  
configConfiguration Files
-   dates Date Formats
-   deprecatedDeprecated Features
-   diffs Diff Formats
environment   Environment Variables
extensionsUsing Additional Features
-   filesets  Specifying File Sets
flags Command-line flags
-   glossary  Glossary
-   hgignore  Syntax for Mercurial Ignore Files
hgweb Configuring hgweb
-   internals Technical implementation topics
merge-tools   Merge Tools
pager Pager Support
-   patterns  File Name Patterns
+  
+  Concepts:
+  
+   bundlespecBundle File Formats
+   glossary  Glossary
phasesWorking with Phases
-   revisions Specifying Revisions
+   subrepos  Subrepositories
+  
+  Miscellaneous:
+  
+   deprecatedDeprecated Features
+   internals Technical implementation topics
scripting Using Mercurial from scripts and automation
-   subrepos  Subrepositories
-   templatingTemplate Usage
-   urls  URL Paths
   
   (use 'hg help -v' to show built-in aliases and global options)
 
@@ -250,29 +264,43 @@
   
   additional help topics:
   
-   bundlespecBundle File Formats
+  Mercurial identifiers:
+  
+   filesets  Specifying File Sets
+   hgignore  Syntax for Mercurial Ignore Files
+   patterns  File Name Patterns
+   revisions Specifying Revisions
+   urls  URL Paths
+  
+  Mercurial output:
+  
color Colorizing Outputs
+   dates Date Formats
+   diffs Diff Formats
+   templatingTemplate Usage
+  
+  Mercurial configuration:
+  
configConfiguration Files
-   dates Date Formats
-   deprecatedDeprecated Features
-   diffs Diff Formats
environment   Environment Variables
extensionsUsing Additional Features
-   filesets  Specifying File Sets
flags Command-line flags
-   glossary  Glossary
-   hgignore  Syntax for Mercurial Ignore Files
hgweb Configuring hgweb
-   internals Technical implementation topics
merge-tools   Merge Tools
pager Pager Support
-   patterns  File Name Patterns
+  
+  Concepts:
+  
+   bundlespecBundle File Formats
+   glossary  Glossary
phasesWorking with Phases
-   revisions Specifying Revisions
+   subrepos  Subrepositories
+  
+  Miscellaneous:
+  
+   deprecatedDeprecated Features
+   internals Technical implementation topics
scripting Using Mercurial from scripts and automation
-   subrepos  Subrepositories
-   templatingTemplate Usage
-   urls  URL Paths
 
 Test extension help:
   $ hg help extensions --config extensions.rebase= --config 
extensions.children=
@@ -963,29 +991,43 @@
   
   additional help topics:
   
-   bundlespecBundle File Formats
+  Mercurial identifiers:
+  
+   filesets  Specifying File Sets
+   hgignore  Syntax for Mercurial Ignore Files
+   patterns  File Name Patterns
+   revisions Specifying Revisions
+   urls  URL Paths
+  
+  Mercurial output:
+  
color Colorizing Outputs
+   dates Date Formats
+   diffs Diff Formats
+   templatingTemplate Usage
+  
+  Mercurial configuration:
+  
configConfiguration Files
-   dates Date Formats
-   deprecatedDeprecated Features
-   diffs Diff Formats
environment   Environment Variables
extensionsUsing Additional Features
-   filesets  Specifying File Sets
flags Command-line flags
-   glossary  Glossary
-   hgignore  Syntax for Mercurial Ignore Files
hgweb Configuring hgweb
-   internals Technical implementation topics
merge-tools   Merge Tools
pager Pager Support
-   patterns  File Name Patterns
+  
+  Concepts:
+  
+   bundlespecBundle File Formats
+   glossary  Glossary
phasesWorking with Phases
-   revisions Specifying Revisions
+   subrepos  Subrepositories
+  
+  Miscellaneous:
+  

D5076: help: allow commands to be hidden

2018-10-13 Thread rdamazio (Rodrigo Damazio Bovendorp)
rdamazio created this revision.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.

REVISION SUMMARY
  This is useful in enterprise environments where some workflows are
  discouraged.

REPOSITORY
  rHG Mercurial

REVISION DETAIL
  https://phab.mercurial-scm.org/D5076

AFFECTED FILES
  mercurial/configitems.py
  mercurial/help.py
  tests/test-help-hide.t

CHANGE DETAILS

diff --git a/tests/test-help-hide.t b/tests/test-help-hide.t
new file mode 100644
--- /dev/null
+++ b/tests/test-help-hide.t
@@ -0,0 +1,126 @@
+Test hiding some commands (which also happens to hide an entire category).
+
+  $ hg --config help.hide.clone=true --config help.hide.init=true help
+  Mercurial Distributed SCM
+  
+  list of commands:
+  
+  Remote repository management:
+  
+   incoming  show new changesets found in source
+   outgoing  show changesets not found in the destination
+   paths show aliases for remote repositories
+   pull  pull changes from the specified source
+   push  push changes to the specified destination
+   serve start stand-alone webserver
+  
+  Change creation:
+  
+   commitcommit the specified files or all outstanding changes
+  
+  Change manipulation:
+  
+   backout   reverse effect of earlier changeset
+   graft copy changes from other branches onto the current branch
+   merge merge another revision into working directory
+  
+  Change organization:
+  
+   bookmarks create a new bookmark or list existing bookmarks
+   branchset or show the current branch name
+   branches  list repository named branches
+   phase set or show the current phase name
+   tag   add one or more tags for the current or given revision
+   tags  list repository tags
+  
+  File content management:
+  
+   annotate  show changeset information by line for each file
+   cat   output the current or given revision of files
+   copy  mark files as copied for the next commit
+   diff  diff repository (or selected files)
+   grep  search revision history for a pattern in specified files
+  
+  Change navigation:
+  
+   bisectsubdivision search of changesets
+   heads show branch heads
+   identify  identify the working directory or specified revision
+   log   show revision history of entire repository or files
+  
+  Working directory management:
+  
+   add   add the specified files on the next commit
+   addremove add all new files, delete all missing files
+   files list tracked files
+   forgetforget the specified files on the next commit
+   removeremove the specified files on the next commit
+   renamerename files; equivalent of copy + remove
+   resolve   redo merges or set/view the merge status of files
+   revertrestore files to their checkout state
+   root  print the root (top) of the current working directory
+   statusshow changed files in the working directory
+   summary   summarize working directory state
+   updateupdate working directory (or switch revisions)
+  
+  Change import/export:
+  
+   archive   create an unversioned archive of a repository revision
+   bundlecreate a bundle file
+   exportdump the header and diffs for one or more changesets
+   importimport an ordered set of patches
+   unbundle  apply one or more bundle files
+  
+  Repository maintenance:
+  
+   manifest  output the current or given revision of the project manifest
+   recover   roll back an interrupted transaction
+   verifyverify the integrity of the repository
+  
+  Help:
+  
+   configshow combined config settings from all hgrc files
+   help  show help for a given topic or a help overview
+   version   output version and copyright information
+  
+  additional help topics:
+  
+  Mercurial identifiers:
+  
+   filesets  Specifying File Sets
+   hgignore  Syntax for Mercurial Ignore Files
+   patterns  File Name Patterns
+   revisions Specifying Revisions
+   urls  URL Paths
+  
+  Mercurial output:
+  
+   color Colorizing Outputs
+   dates Date Formats
+   diffs Diff Formats
+   templatingTemplate Usage
+  
+  Mercurial configuration:
+  
+   configConfiguration Files
+   environment   Environment Variables
+   extensionsUsing Additional Features
+   flags Command-line flags
+   hgweb Configuring hgweb
+   merge-tools   Merge Tools
+   pager Pager Support
+  
+  Concepts:
+  
+   bundlespecBundle File Formats
+   glossary  Glossary
+   phasesWorking with Phases
+   subrepos  Subrepositories
+  
+  Miscellaneous:
+  
+   deprecatedDeprecated Features
+   internals Technical implementation topics
+   scripting Using Mercurial from scripts and automation
+ 

D5066: help: splitting the topics by category

2018-10-13 Thread rdamazio (Rodrigo Damazio Bovendorp)
rdamazio created this revision.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.

REPOSITORY
  rHG Mercurial

REVISION DETAIL
  https://phab.mercurial-scm.org/D5066

AFFECTED FILES
  mercurial/help.py
  mercurial/hgweb/webcommands.py

CHANGE DETAILS

diff --git a/mercurial/hgweb/webcommands.py b/mercurial/hgweb/webcommands.py
--- a/mercurial/hgweb/webcommands.py
+++ b/mercurial/hgweb/webcommands.py
@@ -1401,7 +1401,8 @@
 topicname = web.req.qsparams.get('node')
 if not topicname:
 def topics(context):
-for entries, summary, _doc in helpmod.helptable:
+for h in helpmod.helptable:
+entries, summary, _doc = h[0:3]
 yield {'topic': entries[0], 'summary': summary}
 
 early, other = [], []
diff --git a/mercurial/help.py b/mercurial/help.py
--- a/mercurial/help.py
+++ b/mercurial/help.py
@@ -58,6 +58,17 @@
 CATEGORY_NONE,
 ]
 
+# Topic categories.
+TOPIC_CATEGORY_NONE = _('Uncategorized topics')
+
+# The order in which topic categories will be displayed.
+# Extensions with custom categories should insert them into this list
+# after/before the appropriate item, rather than replacing the list or
+# assuming absolute positions.
+TOPIC_CATEGORY_ORDER = [
+TOPIC_CATEGORY_NONE,
+]
+
 def listexts(header, exts, indent=1, showdeprecated=False):
 '''return a text listing of the given extensions'''
 rst = []
@@ -150,7 +161,8 @@
'extensions': [],
'extensioncommands': [],
}
-for names, header, doc in helptable:
+for topic in helptable:
+names, header, doc = topic[0:3]
 # Old extensions may use a str as doc.
 if (sum(map(lowercontains, names))
 or lowercontains(header)
@@ -510,12 +522,24 @@
 rst.append('\n')
 rst.extend(exts)
 
-rst.append(_("\nadditional help topics:\n\n"))
-topics = []
-for names, header, doc in helptable:
-topics.append((names[0], header))
-for t, desc in topics:
-rst.append(" :%s: %s\n" % (t, desc))
+rst.append(_("\nadditional help topics:\n"))
+topiccats = {}
+for topic in helptable:
+names, header, doc = topic[0:3]
+if len(topic) > 3 and topic[3]:
+category = topic[3]
+else:
+category = TOPIC_CATEGORY_NONE
+
+topiccats.setdefault(category, []).append((names[0], header))
+for cat in TOPIC_CATEGORY_ORDER:
+topics = topiccats.get(cat, [])
+if topics:
+if len(topiccats) > 1:
+rst.append("\n%s:\n" % cat)
+rst.append("\n")
+for t, desc in topics:
+rst.append(" :%s: %s\n" % (t, desc))
 
 if ui.quiet:
 pass
@@ -550,7 +574,8 @@
 break
 
 if not header:
-for names, header, doc in helptable:
+for topic in helptable:
+names, header, doc = topic[0:3]
 if name in names:
 break
 else:



To: rdamazio, #hg-reviewers
Cc: mercurial-devel
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


D5065: help: adding support for command categories

2018-10-13 Thread rdamazio (Rodrigo Damazio Bovendorp)
rdamazio updated this revision to Diff 12039.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D5065?vs=12031=12039

REVISION DETAIL
  https://phab.mercurial-scm.org/D5065

AFFECTED FILES
  doc/gendoc.py
  mercurial/configitems.py
  mercurial/help.py
  mercurial/registrar.py

CHANGE DETAILS

diff --git a/mercurial/registrar.py b/mercurial/registrar.py
--- a/mercurial/registrar.py
+++ b/mercurial/registrar.py
@@ -146,6 +146,10 @@
 to prevent the command from running if the requested intent could not be
 fulfilled.
 
+If `helpcategory` is set (usually to one of the constants in the help
+module), the command will be displayed under that category in the help's
+list of commands.
+
 The following intents are defined:
 
 readonly
@@ -166,12 +170,12 @@
 
 def _doregister(self, func, name, options=(), synopsis=None,
 norepo=False, optionalrepo=False, inferrepo=False,
-intents=None):
-
+intents=None, helpcategory=None):
 func.norepo = norepo
 func.optionalrepo = optionalrepo
 func.inferrepo = inferrepo
 func.intents = intents or set()
+func.helpcategory = helpcategory
 if synopsis:
 self._table[name] = func, list(options), synopsis
 else:
diff --git a/mercurial/help.py b/mercurial/help.py
--- a/mercurial/help.py
+++ b/mercurial/help.py
@@ -47,6 +47,17 @@
 _("(EXPERIMENTAL)"),
 }
 
+# Command categories.
+CATEGORY_NONE = _('Uncategorized commands')
+
+# The order in which command categories will be displayed.
+# Extensions with custom categories should insert them into this list
+# after/before the appropriate item, rather than replacing the list or
+# assuming absolute positions.
+CATEGORY_ORDER = [
+CATEGORY_NONE,
+]
+
 def listexts(header, exts, indent=1, showdeprecated=False):
 '''return a text listing of the given extensions'''
 rst = []
@@ -121,6 +132,8 @@
 return True
 if not ui.verbose and doc and any(w in doc for w in _exclkeywords):
 return True
+if ui.configbool('help', 'hide.%s' % cmd):
+return True
 return False
 
 def topicmatch(ui, commands, kw):
@@ -421,53 +434,80 @@
 
 
 def helplist(select=None, **opts):
-# list of commands
-if name == "shortlist":
-header = _('basic commands:\n\n')
-elif name == "debug":
-header = _('debug commands (internal and unsupported):\n\n')
-else:
-header = _('list of commands:\n\n')
-
+# Category -> list of commands
+cats = {}
+# Command -> short description
 h = {}
-cmds = {}
+# Command -> string showing synonyms
+syns = {}
 for c, e in commands.table.iteritems():
 fs = cmdutil.parsealiases(c)
 f = fs[0]
+syns[f] = ', '.join(fs)
+func = e[0]
 p = ''
 if c.startswith("^"):
 p = '^'
 if select and not select(p + f):
 continue
 if (not select and name != 'shortlist' and
-e[0].__module__ != commands.__name__):
+func.__module__ != commands.__name__):
 continue
 if name == "shortlist" and not p:
 continue
-doc = pycompat.getdoc(e[0])
+doc = pycompat.getdoc(func)
 if filtercmd(ui, f, name, doc):
 continue
 doc = gettext(doc)
 if not doc:
 doc = _("(no help text available)")
 h[f] = doc.splitlines()[0].rstrip()
-cmds[f] = '|'.join(fs)
+
+cat = getattr(func, 'helpcategory', None) or CATEGORY_NONE
+cats.setdefault(cat, []).append(f)
 
 rst = []
 if not h:
 if not ui.quiet:
 rst.append(_('no commands defined\n'))
 return rst
 
+# Output top header.
 if not ui.quiet:
-rst.append(header)
-fns = sorted(h)
-for f in fns:
-if ui.verbose:
-commacmds = cmds[f].replace("|",", ")
-rst.append(" :%s: %s\n" % (commacmds, h[f]))
+if name == "shortlist":
+rst.append(_('basic commands:\n\n'))
+elif name == "debug":
+rst.append(_('debug commands (internal and unsupported):\n\n'))
 else:
-rst.append(' :%s: %s\n' % (f, h[f]))
+rst.append(_('list of commands:\n'))
+
+def appendcmds(cmds):
+cmds = sorted(cmds)
+for c in cmds:
+if ui.verbose:
+rst.append(" :%s: %s\n" % (syns[c], h[c]))
+else:
+rst.append(' :%s: %s\n' % (c, h[c]))
+
+if name in ('shortlist', 'debug'):
+# List without categories.
+appendcmds(h)
+ 

D5066: help: splitting the topics by category

2018-10-13 Thread rdamazio (Rodrigo Damazio Bovendorp)
rdamazio updated this revision to Diff 12040.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D5066?vs=12032=12040

REVISION DETAIL
  https://phab.mercurial-scm.org/D5066

AFFECTED FILES
  mercurial/help.py
  mercurial/hgweb/webcommands.py

CHANGE DETAILS

diff --git a/mercurial/hgweb/webcommands.py b/mercurial/hgweb/webcommands.py
--- a/mercurial/hgweb/webcommands.py
+++ b/mercurial/hgweb/webcommands.py
@@ -1401,7 +1401,8 @@
 topicname = web.req.qsparams.get('node')
 if not topicname:
 def topics(context):
-for entries, summary, _doc in helpmod.helptable:
+for h in helpmod.helptable:
+entries, summary, _doc = h[0:3]
 yield {'topic': entries[0], 'summary': summary}
 
 early, other = [], []
diff --git a/mercurial/help.py b/mercurial/help.py
--- a/mercurial/help.py
+++ b/mercurial/help.py
@@ -58,6 +58,17 @@
 CATEGORY_NONE,
 ]
 
+# Topic categories.
+TOPIC_CATEGORY_NONE = _('Uncategorized topics')
+
+# The order in which topic categories will be displayed.
+# Extensions with custom categories should insert them into this list
+# after/before the appropriate item, rather than replacing the list or
+# assuming absolute positions.
+TOPIC_CATEGORY_ORDER = [
+TOPIC_CATEGORY_NONE,
+]
+
 def listexts(header, exts, indent=1, showdeprecated=False):
 '''return a text listing of the given extensions'''
 rst = []
@@ -150,7 +161,8 @@
'extensions': [],
'extensioncommands': [],
}
-for names, header, doc in helptable:
+for topic in helptable:
+names, header, doc = topic[0:3]
 # Old extensions may use a str as doc.
 if (sum(map(lowercontains, names))
 or lowercontains(header)
@@ -517,12 +529,34 @@
 rst.append('\n')
 rst.extend(exts)
 
-rst.append(_("\nadditional help topics:\n\n"))
-topics = []
-for names, header, doc in helptable:
-topics.append((names[0], header))
-for t, desc in topics:
-rst.append(" :%s: %s\n" % (t, desc))
+rst.append(_("\nadditional help topics:\n"))
+# Group commands by category.
+topiccats = {}
+for topic in helptable:
+names, header, doc = topic[0:3]
+if len(topic) > 3 and topic[3]:
+category = topic[3]
+else:
+category = TOPIC_CATEGORY_NONE
+
+topiccats.setdefault(category, []).append((names[0], header))
+
+# Check that all categories have an order.
+missing_order = set(topiccats.keys()) - set(TOPIC_CATEGORY_ORDER)
+if missing_order:
+ui.develwarn(
+'Help categories missing from TOPIC_CATEGORY_ORDER: %s' %
+missing_order)
+
+# Output topics per category.
+for cat in TOPIC_CATEGORY_ORDER:
+topics = topiccats.get(cat, [])
+if topics:
+if len(topiccats) > 1:
+rst.append("\n%s:\n" % cat)
+rst.append("\n")
+for t, desc in topics:
+rst.append(" :%s: %s\n" % (t, desc))
 
 if ui.quiet:
 pass
@@ -557,7 +591,8 @@
 break
 
 if not header:
-for names, header, doc in helptable:
+for topic in helptable:
+names, header, doc = topic[0:3]
 if name in names:
 break
 else:



To: rdamazio, #hg-reviewers
Cc: mercurial-devel
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


D5069: help: adding a proper declaration for shortlist/basic commands

2018-10-13 Thread rdamazio (Rodrigo Damazio Bovendorp)
rdamazio updated this revision to Diff 12064.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D5069?vs=12043=12064

REVISION DETAIL
  https://phab.mercurial-scm.org/D5069

AFFECTED FILES
  contrib/perf.py
  hgext/absorb.py
  hgext/blackbox.py
  hgext/fastannotate/commands.py
  hgext/githelp.py
  hgext/mq.py
  hgext/record.py
  hgext/sparse.py
  hgext/split.py
  hgext/uncommit.py
  mercurial/cmdutil.py
  mercurial/commands.py
  mercurial/help.py
  mercurial/hgweb/webcommands.py
  mercurial/registrar.py
  tests/test-completion.t

CHANGE DETAILS

diff --git a/tests/test-completion.t b/tests/test-completion.t
--- a/tests/test-completion.t
+++ b/tests/test-completion.t
@@ -231,31 +231,18 @@
 Show all commands + options
   $ hg debugcommands
   add: include, exclude, subrepos, dry-run
+  addremove: similarity, subrepos, include, exclude, dry-run
   annotate: rev, follow, no-follow, text, user, file, date, number, changeset, 
line-number, skip, ignore-all-space, ignore-space-change, ignore-blank-lines, 
ignore-space-at-eol, include, exclude, template
-  clone: noupdate, updaterev, rev, branch, pull, uncompressed, stream, ssh, 
remotecmd, insecure
-  commit: addremove, close-branch, amend, secret, edit, interactive, include, 
exclude, message, logfile, date, user, subrepos
-  diff: rev, change, text, git, binary, nodates, noprefix, show-function, 
reverse, ignore-all-space, ignore-space-change, ignore-blank-lines, 
ignore-space-at-eol, unified, stat, root, include, exclude, subrepos
-  export: bookmark, output, switch-parent, rev, text, git, binary, nodates, 
template
-  forget: interactive, include, exclude, dry-run
-  init: ssh, remotecmd, insecure
-  log: follow, follow-first, date, copies, keyword, rev, line-range, removed, 
only-merges, user, only-branch, branch, prune, patch, git, limit, no-merges, 
stat, graph, style, template, include, exclude
-  merge: force, rev, preview, abort, tool
-  pull: update, force, rev, bookmark, branch, ssh, remotecmd, insecure
-  push: force, rev, bookmark, branch, new-branch, pushvars, ssh, remotecmd, 
insecure
-  remove: after, force, subrepos, include, exclude, dry-run
-  serve: accesslog, daemon, daemon-postexec, errorlog, port, address, prefix, 
name, web-conf, webdir-conf, pid-file, stdio, cmdserver, templates, style, 
ipv6, certificate, print-url, subrepos
-  status: all, modified, added, removed, deleted, clean, unknown, ignored, 
no-status, terse, copies, print0, rev, change, include, exclude, subrepos, 
template
-  summary: remote
-  update: clean, check, merge, date, rev, tool
-  addremove: similarity, subrepos, include, exclude, dry-run
   archive: no-decode, prefix, rev, type, subrepos, include, exclude
   backout: merge, commit, no-commit, parent, rev, edit, tool, include, 
exclude, message, logfile, date, user
   bisect: reset, good, bad, skip, extend, command, noupdate
   bookmarks: force, rev, delete, rename, inactive, list, template
   branch: force, clean, rev
   branches: active, closed, template
   bundle: force, rev, branch, base, all, type, ssh, remotecmd, insecure
   cat: output, rev, decode, include, exclude, template
+  clone: noupdate, updaterev, rev, branch, pull, uncompressed, stream, ssh, 
remotecmd, insecure
+  commit: addremove, close-branch, amend, secret, edit, interactive, include, 
exclude, message, logfile, date, user, subrepos
   config: untrusted, edit, local, global, template
   copy: after, force, include, exclude, dry-run
   debugancestor: 
@@ -317,30 +304,43 @@
   debugwhyunstable: 
   debugwireargs: three, four, five, ssh, remotecmd, insecure
   debugwireproto: localssh, peer, noreadstderr, nologhandshake, ssh, 
remotecmd, insecure
+  diff: rev, change, text, git, binary, nodates, noprefix, show-function, 
reverse, ignore-all-space, ignore-space-change, ignore-blank-lines, 
ignore-space-at-eol, unified, stat, root, include, exclude, subrepos
+  export: bookmark, output, switch-parent, rev, text, git, binary, nodates, 
template
   files: rev, print0, include, exclude, template, subrepos
+  forget: interactive, include, exclude, dry-run
   graft: rev, continue, stop, abort, edit, log, no-commit, force, currentdate, 
currentuser, date, user, tool, dry-run
   grep: print0, all, diff, text, follow, ignore-case, files-with-matches, 
line-number, rev, all-files, user, date, template, include, exclude
   heads: rev, topo, active, closed, style, template
   help: extension, command, keyword, system
   identify: rev, num, id, branch, tags, bookmarks, ssh, remotecmd, insecure, 
template
   import: strip, base, edit, force, no-commit, bypass, partial, exact, prefix, 
import-branch, message, logfile, date, user, similarity
   incoming: force, newest-first, bundle, rev, bookmarks, branch, patch, git, 
limit, no-merges, stat, graph, style, template, ssh, remotecmd, insecure, 
subrepos
+  init: ssh, remotecmd, insecure
   locate: rev, print0, fullpath, include, exclude
+  log: follow, follow-first, date, 

D5087: help: displaying documented aliases by default

2018-10-13 Thread rdamazio (Rodrigo Damazio Bovendorp)
rdamazio created this revision.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.

REVISION SUMMARY
  This makes aliases be displayed in "hg help" when they have a :doc config
  entry, and also allows them to be assigned to a category with :category.

REPOSITORY
  rHG Mercurial

REVISION DETAIL
  https://phab.mercurial-scm.org/D5087

AFFECTED FILES
  mercurial/dispatch.py
  mercurial/help.py
  tests/test-alias.t
  tests/test-help.t

CHANGE DETAILS

diff --git a/tests/test-help.t b/tests/test-help.t
--- a/tests/test-help.t
+++ b/tests/test-help.t
@@ -823,18 +823,38 @@
   > def uisetup(ui):
   > ui.setconfig(b'alias', b'shellalias', b'!echo hi', b'helpext')
   > ui.setconfig(b'alias', b'hgalias', b'summary', b'helpext')
+  > ui.setconfig(b'alias', b'hgalias:doc', b'My doc', b'helpext')
+  > ui.setconfig(b'alias', b'hgalias:category', b'Change navigation', 
b'helpext')
+  > ui.setconfig(b'alias', b'hgaliasnodoc', b'summary', b'helpext')
   > 
   > EOF
   $ echo '[extensions]' >> $HGRCPATH
   $ echo "helpext = `pwd`/helpext.py" >> $HGRCPATH
 
 Test for aliases
 
+  $ hg help | grep hgalias
+   hgalias   My doc
+
   $ hg help hgalias
   hg hgalias [--remote]
   
   alias for: hg summary
   
+  My doc
+  
+  defined by: helpext
+  
+  options:
+  
+--remote check for push and pull
+  
+  (some details hidden, use --verbose to show complete help)
+  $ hg help hgaliasnodoc
+  hg hgaliasnodoc [--remote]
+  
+  alias for: hg summary
+  
   summarize working directory state
   
   This generates a brief summary of the working directory state, including
@@ -947,6 +967,7 @@
   
bisectsubdivision search of changesets
heads show branch heads
+   hgalias   My doc
identify  identify the working directory or specified revision
log   show revision history of entire repository or files
   
@@ -2660,6 +2681,13 @@
   hgalias
   
   
+  My doc
+  
+  
+  
+  hgaliasnodoc
+  
+  
   summarize working directory state
   
   
diff --git a/tests/test-alias.t b/tests/test-alias.t
--- a/tests/test-alias.t
+++ b/tests/test-alias.t
@@ -68,17 +68,17 @@
 help
 
   $ hg help -c | grep myinit
-   myinit This is my documented alias for init.
+   myinit   This is my documented alias for init.
   $ hg help -c | grep mycommit
-   mycommit   This is my alias with only doc.
+   mycommit This is my alias with only doc.
   $ hg help -c | grep cleanstatus
-   cleanstatusshow changed files in the working directory
+  [1]
   $ hg help -c | grep lognull
-   lognullLogs the null rev
+   lognull  Logs the null rev
   $ hg help -c | grep dln
-   dlnLogs the null rev
+  [1]
   $ hg help -c | grep recursivedoc
-   recursivedoc   Logs the null rev in debug mode
+   recursivedoc Logs the null rev in debug mode
   $ hg help myinit
   hg myinit [OPTIONS] [BLA] [BLE]
   
@@ -602,7 +602,7 @@
 help for a shell alias
 
   $ hg help -c | grep rebate
-   rebate This is my alias which just prints something.
+   rebate   This is my alias which just prints something.
   $ hg help rebate
   hg rebate [MYARGS]
   
diff --git a/mercurial/help.py b/mercurial/help.py
--- a/mercurial/help.py
+++ b/mercurial/help.py
@@ -172,12 +172,25 @@
 if notomitted:
 rst.append('\n\n.. container:: notomitted\n\n%s\n\n' % notomitted)
 
-def filtercmd(ui, cmd, kw, doc):
+def filtercmd(ui, cmd, func, kw, doc):
 if not ui.debugflag and cmd.startswith("debug") and kw != "debug":
+# Debug command, and user is not looking for those.
 return True
-if not ui.verbose and doc and any(w in doc for w in _exclkeywords):
+if not ui.verbose:
+if not kw and not doc:
+# Command had no documentation, no point in showing it by default.
+return True
+if getattr(func, 'alias', False) and not getattr(func, 'owndoc', 
False):
+# Alias didn't have its own documentation.
+return True
+if doc and any(w in doc for w in _exclkeywords):
+# Documentation has excluded keywords.
+return True
+if kw == "shortlist" and not getattr(func, 'helpbasic', False):
+# We're presenting the short list but the command is not basic.
 return True
 if ui.configbool('help', 'hide.%s' % cmd):
+# Configuration explicitly hides the command.
 return True
 return False
 
@@ -213,13 +226,14 @@
 else:
 summary = ''
 # translate docs *before* searching there
-docs = _(pycompat.getdoc(entry[0])) or ''
+func = entry[0]
+docs = _(pycompat.getdoc(func)) or ''
 if kw in cmd or lowercontains(summary) or lowercontains(docs):
 doclines = docs.splitlines()
 if doclines:
 summary = doclines[0]
 cmdname = cmdutil.parsealiases(cmd)[0]
-if filtercmd(ui, 

D5065: help: adding support for command categories

2018-10-13 Thread rdamazio (Rodrigo Damazio Bovendorp)
rdamazio created this revision.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.

REPOSITORY
  rHG Mercurial

REVISION DETAIL
  https://phab.mercurial-scm.org/D5065

AFFECTED FILES
  doc/gendoc.py
  mercurial/configitems.py
  mercurial/help.py
  mercurial/registrar.py

CHANGE DETAILS

diff --git a/mercurial/registrar.py b/mercurial/registrar.py
--- a/mercurial/registrar.py
+++ b/mercurial/registrar.py
@@ -146,6 +146,10 @@
 to prevent the command from running if the requested intent could not be
 fulfilled.
 
+If `helpcategory` is set (usually to one of the constants in the help
+module), the command will be displayed under that category in the help's
+list of commands.
+
 The following intents are defined:
 
 readonly
@@ -166,12 +170,12 @@
 
 def _doregister(self, func, name, options=(), synopsis=None,
 norepo=False, optionalrepo=False, inferrepo=False,
-intents=None):
-
+intents=None, helpcategory=None):
 func.norepo = norepo
 func.optionalrepo = optionalrepo
 func.inferrepo = inferrepo
 func.intents = intents or set()
+func.helpcategory = helpcategory
 if synopsis:
 self._table[name] = func, list(options), synopsis
 else:
diff --git a/mercurial/help.py b/mercurial/help.py
--- a/mercurial/help.py
+++ b/mercurial/help.py
@@ -47,6 +47,17 @@
 _("(EXPERIMENTAL)"),
 }
 
+# Command categories.
+CATEGORY_NONE = _('Uncategorized commands')
+
+# The order in which command categories will be displayed.
+# Extensions with custom categories should insert them into this list
+# after/before the appropriate item, rather than replacing the list or
+# assuming absolute positions.
+CATEGORY_ORDER = [
+CATEGORY_NONE,
+]
+
 def listexts(header, exts, indent=1, showdeprecated=False):
 '''return a text listing of the given extensions'''
 rst = []
@@ -121,6 +132,8 @@
 return True
 if not ui.verbose and doc and any(w in doc for w in _exclkeywords):
 return True
+if ui.configbool('help', 'hide.%s' % cmd):
+return True
 return False
 
 def topicmatch(ui, commands, kw):
@@ -421,53 +434,73 @@
 
 
 def helplist(select=None, **opts):
-# list of commands
-if name == "shortlist":
-header = _('basic commands:\n\n')
-elif name == "debug":
-header = _('debug commands (internal and unsupported):\n\n')
-else:
-header = _('list of commands:\n\n')
-
+# Category -> list of commands
+cats = {}
+# Command -> short description
 h = {}
-cmds = {}
+# Command -> string showing synonyms
+syns = {}
 for c, e in commands.table.iteritems():
 fs = cmdutil.parsealiases(c)
 f = fs[0]
+syns[f] = ', '.join(fs)
+func = e[0]
 p = ''
 if c.startswith("^"):
 p = '^'
 if select and not select(p + f):
 continue
 if (not select and name != 'shortlist' and
-e[0].__module__ != commands.__name__):
+func.__module__ != commands.__name__):
 continue
 if name == "shortlist" and not p:
 continue
-doc = pycompat.getdoc(e[0])
+doc = pycompat.getdoc(func)
 if filtercmd(ui, f, name, doc):
 continue
 doc = gettext(doc)
 if not doc:
 doc = _("(no help text available)")
 h[f] = doc.splitlines()[0].rstrip()
-cmds[f] = '|'.join(fs)
+
+cat = getattr(func, 'helpcategory', None) or CATEGORY_NONE
+cats.setdefault(cat, []).append(f)
 
 rst = []
 if not h:
 if not ui.quiet:
 rst.append(_('no commands defined\n'))
 return rst
 
+# Output top header.
 if not ui.quiet:
-rst.append(header)
-fns = sorted(h)
-for f in fns:
-if ui.verbose:
-commacmds = cmds[f].replace("|",", ")
-rst.append(" :%s: %s\n" % (commacmds, h[f]))
+if name == "shortlist":
+rst.append(_('basic commands:\n\n'))
+elif name == "debug":
+rst.append(_('debug commands (internal and unsupported):\n\n'))
 else:
-rst.append(' :%s: %s\n' % (f, h[f]))
+rst.append(_('list of commands:\n'))
+
+def appendcmds(cmds):
+cmds = sorted(cmds)
+for c in cmds:
+if ui.verbose:
+rst.append(" :%s: %s\n" % (syns[c], h[c]))
+else:
+rst.append(' :%s: %s\n' % (c, h[c]))
+
+if name in ('shortlist', 'debug'):
+# List without categories.
+appendcmds(h)
+

D5068: help: assigning topic categories

2018-10-13 Thread rdamazio (Rodrigo Damazio Bovendorp)
rdamazio created this revision.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.

REPOSITORY
  rHG Mercurial

REVISION DETAIL
  https://phab.mercurial-scm.org/D5068

AFFECTED FILES
  doc/gendoc.py
  mercurial/help.py
  tests/test-globalopts.t
  tests/test-help.t

CHANGE DETAILS

diff --git a/tests/test-help.t b/tests/test-help.t
--- a/tests/test-help.t
+++ b/tests/test-help.t
@@ -138,29 +138,43 @@
   
   additional help topics:
   
-   bundlespecBundle File Formats
+  Mercurial identifiers:
+  
+   filesets  Specifying File Sets
+   hgignore  Syntax for Mercurial Ignore Files
+   patterns  File Name Patterns
+   revisions Specifying Revisions
+   urls  URL Paths
+  
+  Mercurial output:
+  
color Colorizing Outputs
+   dates Date Formats
+   diffs Diff Formats
+   templatingTemplate Usage
+  
+  Mercurial configuration:
+  
configConfiguration Files
-   dates Date Formats
-   deprecatedDeprecated Features
-   diffs Diff Formats
environment   Environment Variables
extensionsUsing Additional Features
-   filesets  Specifying File Sets
flags Command-line flags
-   glossary  Glossary
-   hgignore  Syntax for Mercurial Ignore Files
hgweb Configuring hgweb
-   internals Technical implementation topics
merge-tools   Merge Tools
pager Pager Support
-   patterns  File Name Patterns
+  
+  Concepts:
+  
+   bundlespecBundle File Formats
+   glossary  Glossary
phasesWorking with Phases
-   revisions Specifying Revisions
+   subrepos  Subrepositories
+  
+  Miscellaneous:
+  
+   deprecatedDeprecated Features
+   internals Technical implementation topics
scripting Using Mercurial from scripts and automation
-   subrepos  Subrepositories
-   templatingTemplate Usage
-   urls  URL Paths
   
   (use 'hg help -v' to show built-in aliases and global options)
 
@@ -250,29 +264,43 @@
   
   additional help topics:
   
-   bundlespecBundle File Formats
+  Mercurial identifiers:
+  
+   filesets  Specifying File Sets
+   hgignore  Syntax for Mercurial Ignore Files
+   patterns  File Name Patterns
+   revisions Specifying Revisions
+   urls  URL Paths
+  
+  Mercurial output:
+  
color Colorizing Outputs
+   dates Date Formats
+   diffs Diff Formats
+   templatingTemplate Usage
+  
+  Mercurial configuration:
+  
configConfiguration Files
-   dates Date Formats
-   deprecatedDeprecated Features
-   diffs Diff Formats
environment   Environment Variables
extensionsUsing Additional Features
-   filesets  Specifying File Sets
flags Command-line flags
-   glossary  Glossary
-   hgignore  Syntax for Mercurial Ignore Files
hgweb Configuring hgweb
-   internals Technical implementation topics
merge-tools   Merge Tools
pager Pager Support
-   patterns  File Name Patterns
+  
+  Concepts:
+  
+   bundlespecBundle File Formats
+   glossary  Glossary
phasesWorking with Phases
-   revisions Specifying Revisions
+   subrepos  Subrepositories
+  
+  Miscellaneous:
+  
+   deprecatedDeprecated Features
+   internals Technical implementation topics
scripting Using Mercurial from scripts and automation
-   subrepos  Subrepositories
-   templatingTemplate Usage
-   urls  URL Paths
 
 Test extension help:
   $ hg help extensions --config extensions.rebase= --config 
extensions.children=
@@ -963,29 +991,43 @@
   
   additional help topics:
   
-   bundlespecBundle File Formats
+  Mercurial identifiers:
+  
+   filesets  Specifying File Sets
+   hgignore  Syntax for Mercurial Ignore Files
+   patterns  File Name Patterns
+   revisions Specifying Revisions
+   urls  URL Paths
+  
+  Mercurial output:
+  
color Colorizing Outputs
+   dates Date Formats
+   diffs Diff Formats
+   templatingTemplate Usage
+  
+  Mercurial configuration:
+  
configConfiguration Files
-   dates Date Formats
-   deprecatedDeprecated Features
-   diffs Diff Formats
environment   Environment Variables
extensionsUsing Additional Features
-   filesets  Specifying File Sets
flags Command-line flags
-   glossary  Glossary
-   hgignore  Syntax for Mercurial Ignore Files
hgweb Configuring hgweb
-   internals Technical implementation topics
merge-tools   Merge Tools
pager Pager Support
-   patterns  File Name Patterns
+  
+  Concepts:
+  
+   bundlespecBundle File Formats
+   glossary  Glossary
phasesWorking with Phases
-   revisions Specifying Revisions
+   subrepos  Subrepositories
+  
+  Miscellaneous:
+  
+   

D5066: help: splitting the topics by category

2018-10-13 Thread rdamazio (Rodrigo Damazio Bovendorp)
rdamazio updated this revision to Diff 12061.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D5066?vs=12040=12061

REVISION DETAIL
  https://phab.mercurial-scm.org/D5066

AFFECTED FILES
  mercurial/help.py
  mercurial/hgweb/webcommands.py

CHANGE DETAILS

diff --git a/mercurial/hgweb/webcommands.py b/mercurial/hgweb/webcommands.py
--- a/mercurial/hgweb/webcommands.py
+++ b/mercurial/hgweb/webcommands.py
@@ -1401,7 +1401,8 @@
 topicname = web.req.qsparams.get('node')
 if not topicname:
 def topics(context):
-for entries, summary, _doc in helpmod.helptable:
+for h in helpmod.helptable:
+entries, summary, _doc = h[0:3]
 yield {'topic': entries[0], 'summary': summary}
 
 early, other = [], []
diff --git a/mercurial/help.py b/mercurial/help.py
--- a/mercurial/help.py
+++ b/mercurial/help.py
@@ -58,6 +58,17 @@
 CATEGORY_NONE,
 ]
 
+# Topic categories.
+TOPIC_CATEGORY_NONE = _('Uncategorized topics')
+
+# The order in which topic categories will be displayed.
+# Extensions with custom categories should insert them into this list
+# after/before the appropriate item, rather than replacing the list or
+# assuming absolute positions.
+TOPIC_CATEGORY_ORDER = [
+TOPIC_CATEGORY_NONE,
+]
+
 def listexts(header, exts, indent=1, showdeprecated=False):
 '''return a text listing of the given extensions'''
 rst = []
@@ -148,7 +159,8 @@
'extensions': [],
'extensioncommands': [],
}
-for names, header, doc in helptable:
+for topic in helptable:
+names, header, doc = topic[0:3]
 # Old extensions may use a str as doc.
 if (sum(map(lowercontains, names))
 or lowercontains(header)
@@ -514,12 +526,34 @@
 rst.append('\n')
 rst.extend(exts)
 
-rst.append(_("\nadditional help topics:\n\n"))
-topics = []
-for names, header, doc in helptable:
-topics.append((names[0], header))
-for t, desc in topics:
-rst.append(" :%s: %s\n" % (t, desc))
+rst.append(_("\nadditional help topics:\n"))
+# Group commands by category.
+topiccats = {}
+for topic in helptable:
+names, header, doc = topic[0:3]
+if len(topic) > 3 and topic[3]:
+category = topic[3]
+else:
+category = TOPIC_CATEGORY_NONE
+
+topiccats.setdefault(category, []).append((names[0], header))
+
+# Check that all categories have an order.
+missing_order = set(topiccats.keys()) - set(TOPIC_CATEGORY_ORDER)
+if missing_order:
+ui.develwarn(
+'Help categories missing from TOPIC_CATEGORY_ORDER: %s' %
+missing_order)
+
+# Output topics per category.
+for cat in TOPIC_CATEGORY_ORDER:
+topics = topiccats.get(cat, [])
+if topics:
+if len(topiccats) > 1:
+rst.append("\n%s:\n" % cat)
+rst.append("\n")
+for t, desc in topics:
+rst.append(" :%s: %s\n" % (t, desc))
 
 if ui.quiet:
 pass
@@ -554,7 +588,8 @@
 break
 
 if not header:
-for names, header, doc in helptable:
+for topic in helptable:
+names, header, doc = topic[0:3]
 if name in names:
 break
 else:



To: rdamazio, #hg-reviewers
Cc: mercurial-devel
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


D5065: help: adding support for command categories

2018-10-13 Thread rdamazio (Rodrigo Damazio Bovendorp)
rdamazio updated this revision to Diff 12060.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D5065?vs=12039=12060

REVISION DETAIL
  https://phab.mercurial-scm.org/D5065

AFFECTED FILES
  doc/gendoc.py
  mercurial/help.py
  mercurial/registrar.py

CHANGE DETAILS

diff --git a/mercurial/registrar.py b/mercurial/registrar.py
--- a/mercurial/registrar.py
+++ b/mercurial/registrar.py
@@ -146,6 +146,10 @@
 to prevent the command from running if the requested intent could not be
 fulfilled.
 
+If `helpcategory` is set (usually to one of the constants in the help
+module), the command will be displayed under that category in the help's
+list of commands.
+
 The following intents are defined:
 
 readonly
@@ -166,12 +170,12 @@
 
 def _doregister(self, func, name, options=(), synopsis=None,
 norepo=False, optionalrepo=False, inferrepo=False,
-intents=None):
-
+intents=None, helpcategory=None):
 func.norepo = norepo
 func.optionalrepo = optionalrepo
 func.inferrepo = inferrepo
 func.intents = intents or set()
+func.helpcategory = helpcategory
 if synopsis:
 self._table[name] = func, list(options), synopsis
 else:
diff --git a/mercurial/help.py b/mercurial/help.py
--- a/mercurial/help.py
+++ b/mercurial/help.py
@@ -47,6 +47,17 @@
 _("(EXPERIMENTAL)"),
 }
 
+# Command categories.
+CATEGORY_NONE = _('Uncategorized commands')
+
+# The order in which command categories will be displayed.
+# Extensions with custom categories should insert them into this list
+# after/before the appropriate item, rather than replacing the list or
+# assuming absolute positions.
+CATEGORY_ORDER = [
+CATEGORY_NONE,
+]
+
 def listexts(header, exts, indent=1, showdeprecated=False):
 '''return a text listing of the given extensions'''
 rst = []
@@ -421,53 +432,79 @@
 
 
 def helplist(select=None, **opts):
-# list of commands
-if name == "shortlist":
-header = _('basic commands:\n\n')
-elif name == "debug":
-header = _('debug commands (internal and unsupported):\n\n')
-else:
-header = _('list of commands:\n\n')
-
+# Category -> list of commands
+cats = {}
+# Command -> short description
 h = {}
-cmds = {}
+# Command -> string showing synonyms
+syns = {}
 for c, e in commands.table.iteritems():
 fs = cmdutil.parsealiases(c)
 f = fs[0]
+syns[f] = ', '.join(fs)
+func = e[0]
 p = ''
 if c.startswith("^"):
 p = '^'
 if select and not select(p + f):
 continue
 if (not select and name != 'shortlist' and
-e[0].__module__ != commands.__name__):
+func.__module__ != commands.__name__):
 continue
 if name == "shortlist" and not p:
 continue
-doc = pycompat.getdoc(e[0])
+doc = pycompat.getdoc(func)
 if filtercmd(ui, f, name, doc):
 continue
 doc = gettext(doc)
 if not doc:
 doc = _("(no help text available)")
 h[f] = doc.splitlines()[0].rstrip()
-cmds[f] = '|'.join(fs)
+
+cat = getattr(func, 'helpcategory', None) or CATEGORY_NONE
+cats.setdefault(cat, []).append(f)
 
 rst = []
 if not h:
 if not ui.quiet:
 rst.append(_('no commands defined\n'))
 return rst
 
+# Output top header.
 if not ui.quiet:
-rst.append(header)
-fns = sorted(h)
-for f in fns:
-if ui.verbose:
-commacmds = cmds[f].replace("|",", ")
-rst.append(" :%s: %s\n" % (commacmds, h[f]))
+if name == "shortlist":
+rst.append(_('basic commands:\n\n'))
+elif name == "debug":
+rst.append(_('debug commands (internal and unsupported):\n\n'))
 else:
-rst.append(' :%s: %s\n' % (f, h[f]))
+rst.append(_('list of commands:\n'))
+
+def appendcmds(cmds):
+cmds = sorted(cmds)
+for c in cmds:
+if ui.verbose:
+rst.append(" :%s: %s\n" % (syns[c], h[c]))
+else:
+rst.append(' :%s: %s\n' % (c, h[c]))
+
+if name in ('shortlist', 'debug'):
+# List without categories.
+appendcmds(h)
+else:
+# Check that all categories have an order.
+missing_order = set(cats.keys()) - set(CATEGORY_ORDER)
+if missing_order:
+ui.develwarn('Help categories missing from CATEGORY_ORDER: %s' 
%
+ 

D5067: help: assigning categories to existing commands

2018-10-13 Thread rdamazio (Rodrigo Damazio Bovendorp)
rdamazio updated this revision to Diff 12062.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D5067?vs=12041=12062

REVISION DETAIL
  https://phab.mercurial-scm.org/D5067

AFFECTED FILES
  hgext/absorb.py
  hgext/amend.py
  hgext/blackbox.py
  hgext/censor.py
  hgext/children.py
  hgext/churn.py
  hgext/closehead.py
  hgext/extdiff.py
  hgext/fetch.py
  hgext/fix.py
  hgext/githelp.py
  hgext/gpg.py
  hgext/graphlog.py
  hgext/hgk.py
  hgext/histedit.py
  hgext/journal.py
  hgext/mq.py
  hgext/patchbomb.py
  hgext/purge.py
  hgext/rebase.py
  hgext/record.py
  hgext/releasenotes.py
  hgext/relink.py
  hgext/share.py
  hgext/shelve.py
  hgext/show.py
  hgext/split.py
  hgext/strip.py
  hgext/transplant.py
  hgext/uncommit.py
  mercurial/commands.py
  mercurial/help.py
  tests/test-globalopts.t
  tests/test-help.t
  tests/test-mq.t

CHANGE DETAILS

diff --git a/tests/test-mq.t b/tests/test-mq.t
--- a/tests/test-mq.t
+++ b/tests/test-mq.t
@@ -73,29 +73,46 @@
   
   list of commands:
   
+  Repository creation:
+  
+   qcloneclone main and patch repository at same time
+  
+  Change creation:
+  
+   qnew  create a new patch
+   qrefresh  update the current patch
+  
+  Change manipulation:
+  
+   qfold fold the named patches into the current patch
+  
+  Change organization:
+  
qapplied  print the patches already applied
-   qcloneclone main and patch repository at same time
qdelete   remove patches from queue
-   qdiff diff of the current patch and subsequent modifications
qfinish   move applied patches into repository history
-   qfold fold the named patches into the current patch
qgoto push or pop patches until named patch is at top of stack
qguardset or print guards for a patch
qheader   print the header of the topmost or specified patch
-   qimport   import a patch or existing changeset
-   qnew  create a new patch
qnext print the name of the next pushable patch
qpop  pop the current patch off the stack
qprev print the name of the preceding applied patch
qpush push the next patch onto the stack
qqueuemanage multiple patch queues
-   qrefresh  update the current patch
qrename   rename a patch
qselect   set or print guarded patches to push
qseries   print the entire series file
qtop  print the name of the current patch
qunappliedprint the patches not yet applied
   
+  File content management:
+  
+   qdiff diff of the current patch and subsequent modifications
+  
+  Change import/export:
+  
+   qimport   import a patch or existing changeset
+  
   (use 'hg help -v mq' to show built-in aliases and global options)
 
   $ hg init a
diff --git a/tests/test-help.t b/tests/test-help.t
--- a/tests/test-help.t
+++ b/tests/test-help.t
@@ -53,55 +53,87 @@
   
   list of commands:
   
-   add   add the specified files on the next commit
-   addremove add all new files, delete all missing files
-   annotate  show changeset information by line for each file
-   archive   create an unversioned archive of a repository revision
+  Repository creation:
+  
+   clone make a copy of an existing repository
+   init  create a new repository in the given directory
+  
+  Remote repository management:
+  
+   incoming  show new changesets found in source
+   outgoing  show changesets not found in the destination
+   paths show aliases for remote repositories
+   pull  pull changes from the specified source
+   push  push changes to the specified destination
+   serve start stand-alone webserver
+  
+  Change creation:
+  
+   commitcommit the specified files or all outstanding changes
+  
+  Change manipulation:
+  
backout   reverse effect of earlier changeset
-   bisectsubdivision search of changesets
+   graft copy changes from other branches onto the current branch
+   merge merge another revision into working directory
+  
+  Change organization:
+  
bookmarks create a new bookmark or list existing bookmarks
branchset or show the current branch name
branches  list repository named branches
-   bundlecreate a bundle file
+   phase set or show the current phase name
+   tag   add one or more tags for the current or given revision
+   tags  list repository tags
+  
+  File content management:
+  
+   annotate  show changeset information by line for each file
cat   output the current or given revision of files
-   clone make a copy of an existing repository
-   commitcommit the specified files or all outstanding changes
-   configshow combined config settings from all hgrc files
copy  mark files as copied for the next 

D5067: help: assigning categories to existing commands

2018-10-13 Thread rdamazio (Rodrigo Damazio Bovendorp)
rdamazio created this revision.
Herald added a reviewer: durin42.
Herald added a reviewer: martinvonz.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.

REVISION SUMMARY
  I'm separating this into its own commit so people can bikeshed over the actual
  categorization (vs the support for categories). These categories are based on
  the help implementation we've been using internally at Google, and have had
  zero complaints.

REPOSITORY
  rHG Mercurial

REVISION DETAIL
  https://phab.mercurial-scm.org/D5067

AFFECTED FILES
  hgext/absorb.py
  hgext/amend.py
  hgext/blackbox.py
  hgext/censor.py
  hgext/children.py
  hgext/churn.py
  hgext/closehead.py
  hgext/extdiff.py
  hgext/fetch.py
  hgext/fix.py
  hgext/githelp.py
  hgext/gpg.py
  hgext/graphlog.py
  hgext/hgk.py
  hgext/histedit.py
  hgext/journal.py
  hgext/mq.py
  hgext/patchbomb.py
  hgext/purge.py
  hgext/rebase.py
  hgext/record.py
  hgext/releasenotes.py
  hgext/relink.py
  hgext/share.py
  hgext/shelve.py
  hgext/show.py
  hgext/split.py
  hgext/strip.py
  hgext/transplant.py
  hgext/uncommit.py
  mercurial/commands.py
  mercurial/help.py
  tests/test-globalopts.t
  tests/test-help.t
  tests/test-mq.t

CHANGE DETAILS

diff --git a/tests/test-mq.t b/tests/test-mq.t
--- a/tests/test-mq.t
+++ b/tests/test-mq.t
@@ -73,29 +73,46 @@
   
   list of commands:
   
+  Repository creation:
+  
+   qcloneclone main and patch repository at same time
+  
+  Change creation:
+  
+   qnew  create a new patch
+   qrefresh  update the current patch
+  
+  Change manipulation:
+  
+   qfold fold the named patches into the current patch
+  
+  Change organization:
+  
qapplied  print the patches already applied
-   qcloneclone main and patch repository at same time
qdelete   remove patches from queue
-   qdiff diff of the current patch and subsequent modifications
qfinish   move applied patches into repository history
-   qfold fold the named patches into the current patch
qgoto push or pop patches until named patch is at top of stack
qguardset or print guards for a patch
qheader   print the header of the topmost or specified patch
-   qimport   import a patch or existing changeset
-   qnew  create a new patch
qnext print the name of the next pushable patch
qpop  pop the current patch off the stack
qprev print the name of the preceding applied patch
qpush push the next patch onto the stack
qqueuemanage multiple patch queues
-   qrefresh  update the current patch
qrename   rename a patch
qselect   set or print guarded patches to push
qseries   print the entire series file
qtop  print the name of the current patch
qunappliedprint the patches not yet applied
   
+  File content management:
+  
+   qdiff diff of the current patch and subsequent modifications
+  
+  Change import/export:
+  
+   qimport   import a patch or existing changeset
+  
   (use 'hg help -v mq' to show built-in aliases and global options)
 
   $ hg init a
diff --git a/tests/test-help.t b/tests/test-help.t
--- a/tests/test-help.t
+++ b/tests/test-help.t
@@ -53,55 +53,87 @@
   
   list of commands:
   
-   add   add the specified files on the next commit
-   addremove add all new files, delete all missing files
-   annotate  show changeset information by line for each file
-   archive   create an unversioned archive of a repository revision
+  Repository creation:
+  
+   clone make a copy of an existing repository
+   init  create a new repository in the given directory
+  
+  Remote repository management:
+  
+   incoming  show new changesets found in source
+   outgoing  show changesets not found in the destination
+   paths show aliases for remote repositories
+   pull  pull changes from the specified source
+   push  push changes to the specified destination
+   serve start stand-alone webserver
+  
+  Change creation:
+  
+   commitcommit the specified files or all outstanding changes
+  
+  Change manipulation:
+  
backout   reverse effect of earlier changeset
-   bisectsubdivision search of changesets
+   graft copy changes from other branches onto the current branch
+   merge merge another revision into working directory
+  
+  Change organization:
+  
bookmarks create a new bookmark or list existing bookmarks
branchset or show the current branch name
branches  list repository named branches
-   bundlecreate a bundle file
+   phase set or show the current phase name
+   tag   add one or more tags for the current or given revision
+   tags  list repository tags
+  
+  File content management:
+  
+   annotate  show changeset information by 

D5069: help: adding a proper declaration for shortlist/basic commands

2018-10-13 Thread rdamazio (Rodrigo Damazio Bovendorp)
rdamazio updated this revision to Diff 12043.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D5069?vs=12035=12043

REVISION DETAIL
  https://phab.mercurial-scm.org/D5069

AFFECTED FILES
  contrib/perf.py
  hgext/absorb.py
  hgext/blackbox.py
  hgext/fastannotate/commands.py
  hgext/githelp.py
  hgext/mq.py
  hgext/record.py
  hgext/sparse.py
  hgext/split.py
  hgext/uncommit.py
  mercurial/cmdutil.py
  mercurial/commands.py
  mercurial/help.py
  mercurial/hgweb/webcommands.py
  mercurial/registrar.py
  tests/test-completion.t

CHANGE DETAILS

diff --git a/tests/test-completion.t b/tests/test-completion.t
--- a/tests/test-completion.t
+++ b/tests/test-completion.t
@@ -231,31 +231,18 @@
 Show all commands + options
   $ hg debugcommands
   add: include, exclude, subrepos, dry-run
+  addremove: similarity, subrepos, include, exclude, dry-run
   annotate: rev, follow, no-follow, text, user, file, date, number, changeset, 
line-number, skip, ignore-all-space, ignore-space-change, ignore-blank-lines, 
ignore-space-at-eol, include, exclude, template
-  clone: noupdate, updaterev, rev, branch, pull, uncompressed, stream, ssh, 
remotecmd, insecure
-  commit: addremove, close-branch, amend, secret, edit, interactive, include, 
exclude, message, logfile, date, user, subrepos
-  diff: rev, change, text, git, binary, nodates, noprefix, show-function, 
reverse, ignore-all-space, ignore-space-change, ignore-blank-lines, 
ignore-space-at-eol, unified, stat, root, include, exclude, subrepos
-  export: bookmark, output, switch-parent, rev, text, git, binary, nodates, 
template
-  forget: interactive, include, exclude, dry-run
-  init: ssh, remotecmd, insecure
-  log: follow, follow-first, date, copies, keyword, rev, line-range, removed, 
only-merges, user, only-branch, branch, prune, patch, git, limit, no-merges, 
stat, graph, style, template, include, exclude
-  merge: force, rev, preview, abort, tool
-  pull: update, force, rev, bookmark, branch, ssh, remotecmd, insecure
-  push: force, rev, bookmark, branch, new-branch, pushvars, ssh, remotecmd, 
insecure
-  remove: after, force, subrepos, include, exclude, dry-run
-  serve: accesslog, daemon, daemon-postexec, errorlog, port, address, prefix, 
name, web-conf, webdir-conf, pid-file, stdio, cmdserver, templates, style, 
ipv6, certificate, print-url, subrepos
-  status: all, modified, added, removed, deleted, clean, unknown, ignored, 
no-status, terse, copies, print0, rev, change, include, exclude, subrepos, 
template
-  summary: remote
-  update: clean, check, merge, date, rev, tool
-  addremove: similarity, subrepos, include, exclude, dry-run
   archive: no-decode, prefix, rev, type, subrepos, include, exclude
   backout: merge, commit, no-commit, parent, rev, edit, tool, include, 
exclude, message, logfile, date, user
   bisect: reset, good, bad, skip, extend, command, noupdate
   bookmarks: force, rev, delete, rename, inactive, list, template
   branch: force, clean, rev
   branches: active, closed, template
   bundle: force, rev, branch, base, all, type, ssh, remotecmd, insecure
   cat: output, rev, decode, include, exclude, template
+  clone: noupdate, updaterev, rev, branch, pull, uncompressed, stream, ssh, 
remotecmd, insecure
+  commit: addremove, close-branch, amend, secret, edit, interactive, include, 
exclude, message, logfile, date, user, subrepos
   config: untrusted, edit, local, global, template
   copy: after, force, include, exclude, dry-run
   debugancestor: 
@@ -317,30 +304,43 @@
   debugwhyunstable: 
   debugwireargs: three, four, five, ssh, remotecmd, insecure
   debugwireproto: localssh, peer, noreadstderr, nologhandshake, ssh, 
remotecmd, insecure
+  diff: rev, change, text, git, binary, nodates, noprefix, show-function, 
reverse, ignore-all-space, ignore-space-change, ignore-blank-lines, 
ignore-space-at-eol, unified, stat, root, include, exclude, subrepos
+  export: bookmark, output, switch-parent, rev, text, git, binary, nodates, 
template
   files: rev, print0, include, exclude, template, subrepos
+  forget: interactive, include, exclude, dry-run
   graft: rev, continue, stop, abort, edit, log, no-commit, force, currentdate, 
currentuser, date, user, tool, dry-run
   grep: print0, all, diff, text, follow, ignore-case, files-with-matches, 
line-number, rev, all-files, user, date, template, include, exclude
   heads: rev, topo, active, closed, style, template
   help: extension, command, keyword, system
   identify: rev, num, id, branch, tags, bookmarks, ssh, remotecmd, insecure, 
template
   import: strip, base, edit, force, no-commit, bypass, partial, exact, prefix, 
import-branch, message, logfile, date, user, similarity
   incoming: force, newest-first, bundle, rev, bookmarks, branch, patch, git, 
limit, no-merges, stat, graph, style, template, ssh, remotecmd, insecure, 
subrepos
+  init: ssh, remotecmd, insecure
   locate: rev, print0, fullpath, include, exclude
+  log: follow, follow-first, date, 

D5069: help: adding a proper declaration for shortlist/basic commands

2018-10-13 Thread rdamazio (Rodrigo Damazio Bovendorp)
rdamazio created this revision.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.

REVISION SUMMARY
  We previously used the '^' prefix to indicate that a command
  should be shown on the short list (shown for just "hg"), but
  that's a horrible hack, so I'm removing it.

REPOSITORY
  rHG Mercurial

REVISION DETAIL
  https://phab.mercurial-scm.org/D5069

AFFECTED FILES
  hgext/absorb.py
  hgext/blackbox.py
  hgext/githelp.py
  hgext/mq.py
  hgext/sparse.py
  hgext/split.py
  mercurial/cmdutil.py
  mercurial/commands.py
  mercurial/help.py
  mercurial/hgweb/webcommands.py
  mercurial/registrar.py

CHANGE DETAILS

diff --git a/mercurial/registrar.py b/mercurial/registrar.py
--- a/mercurial/registrar.py
+++ b/mercurial/registrar.py
@@ -170,12 +170,13 @@
 
 def _doregister(self, func, name, options=(), synopsis=None,
 norepo=False, optionalrepo=False, inferrepo=False,
-intents=None, helpcategory=None):
+intents=None, helpcategory=None, helpbasic=False):
 func.norepo = norepo
 func.optionalrepo = optionalrepo
 func.inferrepo = inferrepo
 func.intents = intents or set()
 func.helpcategory = helpcategory
+func.helpbasic = helpbasic
 if synopsis:
 self._table[name] = func, list(options), synopsis
 else:
diff --git a/mercurial/hgweb/webcommands.py b/mercurial/hgweb/webcommands.py
--- a/mercurial/hgweb/webcommands.py
+++ b/mercurial/hgweb/webcommands.py
@@ -1412,10 +1412,7 @@
 if 'DEPRECATED' in doc or c.startswith('debug'):
 continue
 cmd = primary(c)
-if cmd.startswith('^'):
-early.append((cmd[1:], doc))
-else:
-other.append((cmd, doc))
+other.append((cmd, doc))
 
 early.sort()
 other.sort()
diff --git a/mercurial/help.py b/mercurial/help.py
--- a/mercurial/help.py
+++ b/mercurial/help.py
@@ -502,16 +502,14 @@
 f = fs[0]
 syns[f] = ', '.join(fs)
 func = e[0]
-p = ''
-if c.startswith("^"):
-p = '^'
-if select and not select(p + f):
+if select and not select(f):
 continue
 if (not select and name != 'shortlist' and
 func.__module__ != commands.__name__):
 continue
-if name == "shortlist" and not p:
-continue
+if name == "shortlist":
+if not getattr(func, 'helpbasic', False):
+continue
 doc = pycompat.getdoc(func)
 if filtercmd(ui, f, name, doc):
 continue
diff --git a/mercurial/commands.py b/mercurial/commands.py
--- a/mercurial/commands.py
+++ b/mercurial/commands.py
@@ -131,11 +131,11 @@
 
 # Commands start here, listed alphabetically
 
-@command('^add',
+@command('add',
 walkopts + subrepoopts + dryrunopts,
 _('[OPTION]... [FILE]...'),
 helpcategory=help.CATEGORY_WORKING_DIRECTORY,
-inferrepo=True)
+helpbasic=True, inferrepo=True)
 def add(ui, repo, *pats, **opts):
 """add the specified files on the next commit
 
@@ -256,7 +256,7 @@
 matcher = scmutil.match(repo[None], pats, opts)
 return scmutil.addremove(repo, matcher, "", opts)
 
-@command('^annotate|blame',
+@command('annotate|blame',
 [('r', 'rev', '', _('annotate the specified revision'), _('REV')),
 ('', 'follow', None,
  _('follow copies/renames and list the filename (DEPRECATED)')),
@@ -272,7 +272,7 @@
 ] + diffwsopts + walkopts + formatteropts,
 _('[-r REV] [-f] [-a] [-u] [-d] [-n] [-c] [-l] FILE...'),
 helpcategory=help.CATEGORY_FILE_CONTENTS,
-inferrepo=True)
+helpbasic=True, inferrepo=True)
 def annotate(ui, repo, *pats, **opts):
 """show changeset information by line for each file
 
@@ -1399,7 +1399,7 @@
 return cmdutil.cat(ui, repo, ctx, m, fm, fntemplate, '',
**pycompat.strkwargs(opts))
 
-@command('^clone',
+@command('clone',
 [('U', 'noupdate', None, _('the clone will include an empty working '
'directory (only a repository)')),
 ('u', 'updaterev', '', _('revision, tag, or branch to check out'),
@@ -1416,7 +1416,7 @@
 ] + remoteopts,
 _('[OPTION]... SOURCE [DEST]'),
 helpcategory=help.CATEGORY_REPO_CREATION,
-norepo=True)
+helpbasic=True, norepo=True)
 def clone(ui, source, dest=None, **opts):
 """make a copy of an existing repository
 
@@ -1555,7 +1555,7 @@
 
 return r is None
 
-@command('^commit|ci',
+@command('commit|ci',
 [('A', 'addremove', None,
  _('mark new/missing files as added/removed before committing')),
 ('', 'close-branch', None,
@@ -1567,7 +1567,7 @@
 ] + walkopts + commitopts + commitopts2 + subrepoopts,
 _('[OPTION]... [FILE]...'),
 helpcategory=help.CATEGORY_COMMITTING,

D5077: help: allow hiding of help topics

2018-10-13 Thread rdamazio (Rodrigo Damazio Bovendorp)
rdamazio created this revision.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.

REPOSITORY
  rHG Mercurial

REVISION DETAIL
  https://phab.mercurial-scm.org/D5077

AFFECTED FILES
  mercurial/help.py
  tests/test-help-hide.t

CHANGE DETAILS

diff --git a/tests/test-help-hide.t b/tests/test-help-hide.t
--- a/tests/test-help-hide.t
+++ b/tests/test-help-hide.t
@@ -124,3 +124,130 @@
scripting Using Mercurial from scripts and automation
   
   (use 'hg help -v' to show built-in aliases and global options)
+
+Test hiding some topics.
+
+  $ hg --config help.hide.deprecated=true --config help.hide.internals=true \
+  > --config help.hide.scripting=true help
+  Mercurial Distributed SCM
+  
+  list of commands:
+  
+  Repository creation:
+  
+   clone make a copy of an existing repository
+   init  create a new repository in the given directory
+  
+  Remote repository management:
+  
+   incoming  show new changesets found in source
+   outgoing  show changesets not found in the destination
+   paths show aliases for remote repositories
+   pull  pull changes from the specified source
+   push  push changes to the specified destination
+   serve start stand-alone webserver
+  
+  Change creation:
+  
+   commitcommit the specified files or all outstanding changes
+  
+  Change manipulation:
+  
+   backout   reverse effect of earlier changeset
+   graft copy changes from other branches onto the current branch
+   merge merge another revision into working directory
+  
+  Change organization:
+  
+   bookmarks create a new bookmark or list existing bookmarks
+   branchset or show the current branch name
+   branches  list repository named branches
+   phase set or show the current phase name
+   tag   add one or more tags for the current or given revision
+   tags  list repository tags
+  
+  File content management:
+  
+   annotate  show changeset information by line for each file
+   cat   output the current or given revision of files
+   copy  mark files as copied for the next commit
+   diff  diff repository (or selected files)
+   grep  search revision history for a pattern in specified files
+  
+  Change navigation:
+  
+   bisectsubdivision search of changesets
+   heads show branch heads
+   identify  identify the working directory or specified revision
+   log   show revision history of entire repository or files
+  
+  Working directory management:
+  
+   add   add the specified files on the next commit
+   addremove add all new files, delete all missing files
+   files list tracked files
+   forgetforget the specified files on the next commit
+   removeremove the specified files on the next commit
+   renamerename files; equivalent of copy + remove
+   resolve   redo merges or set/view the merge status of files
+   revertrestore files to their checkout state
+   root  print the root (top) of the current working directory
+   statusshow changed files in the working directory
+   summary   summarize working directory state
+   updateupdate working directory (or switch revisions)
+  
+  Change import/export:
+  
+   archive   create an unversioned archive of a repository revision
+   bundlecreate a bundle file
+   exportdump the header and diffs for one or more changesets
+   importimport an ordered set of patches
+   unbundle  apply one or more bundle files
+  
+  Repository maintenance:
+  
+   manifest  output the current or given revision of the project manifest
+   recover   roll back an interrupted transaction
+   verifyverify the integrity of the repository
+  
+  Help:
+  
+   configshow combined config settings from all hgrc files
+   help  show help for a given topic or a help overview
+   version   output version and copyright information
+  
+  additional help topics:
+  
+  Mercurial identifiers:
+  
+   filesets  Specifying File Sets
+   hgignore  Syntax for Mercurial Ignore Files
+   patterns  File Name Patterns
+   revisions Specifying Revisions
+   urls  URL Paths
+  
+  Mercurial output:
+  
+   color Colorizing Outputs
+   dates Date Formats
+   diffs Diff Formats
+   templatingTemplate Usage
+  
+  Mercurial configuration:
+  
+   configConfiguration Files
+   environment   Environment Variables
+   extensionsUsing Additional Features
+   flags Command-line flags
+   hgweb Configuring hgweb
+   merge-tools   Merge Tools
+   pager Pager Support
+  
+  Concepts:
+  
+   bundlespecBundle File Formats
+   glossary  Glossary
+   phasesWorking with Phases
+   subrepos  Subrepositories
+  
+  (use 'hg help 

D5065: help: adding support for command categories

2018-10-14 Thread rdamazio (Rodrigo Damazio Bovendorp)
This revision was automatically updated to reflect the committed changes.
Closed by commit rHG170926caf44c: help: adding support for command categories 
(authored by rdamazio, committed by ).

CHANGED PRIOR TO COMMIT
  https://phab.mercurial-scm.org/D5065?vs=12120=12142#toc

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D5065?vs=12120=12142

REVISION DETAIL
  https://phab.mercurial-scm.org/D5065

AFFECTED FILES
  doc/gendoc.py
  mercurial/help.py
  mercurial/registrar.py

CHANGE DETAILS

diff --git a/mercurial/registrar.py b/mercurial/registrar.py
--- a/mercurial/registrar.py
+++ b/mercurial/registrar.py
@@ -146,6 +146,10 @@
 to prevent the command from running if the requested intent could not be
 fulfilled.
 
+If `helpcategory` is set (usually to one of the constants in the help
+module), the command will be displayed under that category in the help's
+list of commands.
+
 The following intents are defined:
 
 readonly
@@ -164,14 +168,17 @@
 descriptions and examples.
 """
 
+# Command categories for grouping them in help output.
+CATEGORY_NONE = 'none'
+
 def _doregister(self, func, name, options=(), synopsis=None,
 norepo=False, optionalrepo=False, inferrepo=False,
-intents=None):
-
+intents=None, helpcategory=None):
 func.norepo = norepo
 func.optionalrepo = optionalrepo
 func.inferrepo = inferrepo
 func.intents = intents or set()
+func.helpcategory = helpcategory
 if synopsis:
 self._table[name] = func, list(options), synopsis
 else:
diff --git a/mercurial/help.py b/mercurial/help.py
--- a/mercurial/help.py
+++ b/mercurial/help.py
@@ -25,6 +25,7 @@
 fileset,
 minirst,
 pycompat,
+registrar,
 revset,
 templatefilters,
 templatefuncs,
@@ -47,6 +48,20 @@
 _("(EXPERIMENTAL)"),
 }
 
+# The order in which command categories will be displayed.
+# Extensions with custom categories should insert them into this list
+# after/before the appropriate item, rather than replacing the list or
+# assuming absolute positions.
+CATEGORY_ORDER = [
+registrar.command.CATEGORY_NONE,
+]
+
+# Human-readable category names. These are translated.
+# Extensions with custom categories should add their names here.
+CATEGORY_NAMES = {
+registrar.command.CATEGORY_NONE: 'Uncategorized commands',
+}
+
 def listexts(header, exts, indent=1, showdeprecated=False):
 '''return a text listing of the given extensions'''
 rst = []
@@ -419,55 +434,82 @@
 
 return rst
 
-
 def helplist(select=None, **opts):
-# list of commands
-if name == "shortlist":
-header = _('basic commands:\n\n')
-elif name == "debug":
-header = _('debug commands (internal and unsupported):\n\n')
-else:
-header = _('list of commands:\n\n')
-
+# Category -> list of commands
+cats = {}
+# Command -> short description
 h = {}
-cmds = {}
+# Command -> string showing synonyms
+syns = {}
 for c, e in commands.table.iteritems():
 fs = cmdutil.parsealiases(c)
 f = fs[0]
+syns[f] = ', '.join(fs)
+func = e[0]
 p = ''
 if c.startswith("^"):
 p = '^'
 if select and not select(p + f):
 continue
 if (not select and name != 'shortlist' and
-e[0].__module__ != commands.__name__):
+func.__module__ != commands.__name__):
 continue
 if name == "shortlist" and not p:
 continue
-doc = pycompat.getdoc(e[0])
+doc = pycompat.getdoc(func)
 if filtercmd(ui, f, name, doc):
 continue
 doc = gettext(doc)
 if not doc:
 doc = _("(no help text available)")
 h[f] = doc.splitlines()[0].rstrip()
-cmds[f] = '|'.join(fs)
+
+cat = getattr(func, 'helpcategory', None) or (
+registrar.command.CATEGORY_NONE)
+cats.setdefault(cat, []).append(f)
 
 rst = []
 if not h:
 if not ui.quiet:
 rst.append(_('no commands defined\n'))
 return rst
 
+# Output top header.
 if not ui.quiet:
-rst.append(header)
-fns = sorted(h)
-for f in fns:
-if ui.verbose:
-commacmds = cmds[f].replace("|",", ")
-rst.append(" :%s: %s\n" % (commacmds, h[f]))
+if name == "shortlist":
+rst.append(_('basic commands:\n\n'))
+elif name == "debug":
+rst.append(_('debug commands (internal and unsupported):\n\n'))
 else:
-rst.append(' :%s: %s\n' % (f, h[f]))
+  

D5066: help: splitting the topics by category

2018-10-14 Thread rdamazio (Rodrigo Damazio Bovendorp)
This revision was automatically updated to reflect the committed changes.
Closed by commit rHG9c6473d2038b: help: splitting the topics by category 
(authored by rdamazio, committed by ).

CHANGED PRIOR TO COMMIT
  https://phab.mercurial-scm.org/D5066?vs=12121=12143#toc

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D5066?vs=12121=12143

REVISION DETAIL
  https://phab.mercurial-scm.org/D5066

AFFECTED FILES
  doc/check-seclevel.py
  mercurial/help.py
  mercurial/hgweb/webcommands.py

CHANGE DETAILS

diff --git a/mercurial/hgweb/webcommands.py b/mercurial/hgweb/webcommands.py
--- a/mercurial/hgweb/webcommands.py
+++ b/mercurial/hgweb/webcommands.py
@@ -1407,7 +1407,8 @@
 topicname = web.req.qsparams.get('node')
 if not topicname:
 def topics(context):
-for entries, summary, _doc in helpmod.helptable:
+for h in helpmod.helptable:
+entries, summary, _doc = h[0:3]
 yield {'topic': entries[0], 'summary': summary}
 
 early, other = [], []
diff --git a/mercurial/help.py b/mercurial/help.py
--- a/mercurial/help.py
+++ b/mercurial/help.py
@@ -62,6 +62,22 @@
 registrar.command.CATEGORY_NONE: 'Uncategorized commands',
 }
 
+# Topic categories.
+TOPIC_CATEGORY_NONE = 'none'
+
+# The order in which topic categories will be displayed.
+# Extensions with custom categories should insert them into this list
+# after/before the appropriate item, rather than replacing the list or
+# assuming absolute positions.
+TOPIC_CATEGORY_ORDER = [
+TOPIC_CATEGORY_NONE,
+]
+
+# Human-readable topic category names. These are translated.
+TOPIC_CATEGORY_NAMES = {
+TOPIC_CATEGORY_NONE: 'Uncategorized topics',
+}
+
 def listexts(header, exts, indent=1, showdeprecated=False):
 '''return a text listing of the given extensions'''
 rst = []
@@ -152,7 +168,8 @@
'extensions': [],
'extensioncommands': [],
}
-for names, header, doc in helptable:
+for topic in helptable:
+names, header, doc = topic[0:3]
 # Old extensions may use a str as doc.
 if (sum(map(lowercontains, names))
 or lowercontains(header)
@@ -519,12 +536,35 @@
 rst.append('\n')
 rst.extend(exts)
 
-rst.append(_("\nadditional help topics:\n\n"))
-topics = []
-for names, header, doc in helptable:
-topics.append((names[0], header))
-for t, desc in topics:
-rst.append(" :%s: %s\n" % (t, desc))
+rst.append(_("\nadditional help topics:\n"))
+# Group commands by category.
+topiccats = {}
+for topic in helptable:
+names, header, doc = topic[0:3]
+if len(topic) > 3 and topic[3]:
+category = topic[3]
+else:
+category = TOPIC_CATEGORY_NONE
+
+topiccats.setdefault(category, []).append((names[0], header))
+
+# Check that all categories have an order.
+missing_order = set(topiccats.keys()) - set(TOPIC_CATEGORY_ORDER)
+if missing_order:
+ui.develwarn(
+'help categories missing from TOPIC_CATEGORY_ORDER: %s' %
+missing_order)
+
+# Output topics per category.
+for cat in TOPIC_CATEGORY_ORDER:
+topics = topiccats.get(cat, [])
+if topics:
+if len(topiccats) > 1:
+catname = gettext(TOPIC_CATEGORY_NAMES[cat])
+rst.append("\n%s:\n" % catname)
+rst.append("\n")
+for t, desc in topics:
+rst.append(" :%s: %s\n" % (t, desc))
 
 if ui.quiet:
 pass
@@ -559,7 +599,8 @@
 break
 
 if not header:
-for names, header, doc in helptable:
+for topic in helptable:
+names, header, doc = topic[0:3]
 if name in names:
 break
 else:
diff --git a/doc/check-seclevel.py b/doc/check-seclevel.py
--- a/doc/check-seclevel.py
+++ b/doc/check-seclevel.py
@@ -87,7 +87,8 @@
 
 def checkhghelps(ui):
 errorcnt = 0
-for names, sec, doc in helptable:
+for h in helptable:
+names, sec, doc = h[0:3]
 if callable(doc):
 doc = doc(ui)
 errorcnt += checkseclevel(ui, doc,



To: rdamazio, #hg-reviewers
Cc: mercurial-devel
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


D5065: help: adding support for command categories

2018-10-14 Thread rdamazio (Rodrigo Damazio Bovendorp)
rdamazio updated this revision to Diff 12120.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D5065?vs=12060=12120

REVISION DETAIL
  https://phab.mercurial-scm.org/D5065

AFFECTED FILES
  doc/gendoc.py
  mercurial/help.py
  mercurial/registrar.py

CHANGE DETAILS

diff --git a/mercurial/registrar.py b/mercurial/registrar.py
--- a/mercurial/registrar.py
+++ b/mercurial/registrar.py
@@ -146,6 +146,10 @@
 to prevent the command from running if the requested intent could not be
 fulfilled.
 
+If `helpcategory` is set (usually to one of the constants in the help
+module), the command will be displayed under that category in the help's
+list of commands.
+
 The following intents are defined:
 
 readonly
@@ -164,14 +168,17 @@
 descriptions and examples.
 """
 
+# Command categories for grouping them in help output.
+CATEGORY_NONE = 'none'
+
 def _doregister(self, func, name, options=(), synopsis=None,
 norepo=False, optionalrepo=False, inferrepo=False,
-intents=None):
-
+intents=None, helpcategory=None):
 func.norepo = norepo
 func.optionalrepo = optionalrepo
 func.inferrepo = inferrepo
 func.intents = intents or set()
+func.helpcategory = helpcategory
 if synopsis:
 self._table[name] = func, list(options), synopsis
 else:
diff --git a/mercurial/help.py b/mercurial/help.py
--- a/mercurial/help.py
+++ b/mercurial/help.py
@@ -25,6 +25,7 @@
 fileset,
 minirst,
 pycompat,
+registrar,
 revset,
 templatefilters,
 templatefuncs,
@@ -47,6 +48,20 @@
 _("(EXPERIMENTAL)"),
 }
 
+# The order in which command categories will be displayed.
+# Extensions with custom categories should insert them into this list
+# after/before the appropriate item, rather than replacing the list or
+# assuming absolute positions.
+CATEGORY_ORDER = [
+registrar.command.CATEGORY_NONE,
+]
+
+# Human-readable category names. These are translated.
+# Extensions with custom categories should add their names here.
+CATEGORY_NAMES = {
+registrar.command.CATEGORY_NONE: 'Uncategorized commands',
+}
+
 def listexts(header, exts, indent=1, showdeprecated=False):
 '''return a text listing of the given extensions'''
 rst = []
@@ -421,53 +436,81 @@
 
 
 def helplist(select=None, **opts):
-# list of commands
-if name == "shortlist":
-header = _('basic commands:\n\n')
-elif name == "debug":
-header = _('debug commands (internal and unsupported):\n\n')
-else:
-header = _('list of commands:\n\n')
-
+# Category -> list of commands
+cats = {}
+# Command -> short description
 h = {}
-cmds = {}
+# Command -> string showing synonyms
+syns = {}
 for c, e in commands.table.iteritems():
 fs = cmdutil.parsealiases(c)
 f = fs[0]
+syns[f] = ', '.join(fs)
+func = e[0]
 p = ''
 if c.startswith("^"):
 p = '^'
 if select and not select(p + f):
 continue
 if (not select and name != 'shortlist' and
-e[0].__module__ != commands.__name__):
+func.__module__ != commands.__name__):
 continue
 if name == "shortlist" and not p:
 continue
-doc = pycompat.getdoc(e[0])
+doc = pycompat.getdoc(func)
 if filtercmd(ui, f, name, doc):
 continue
 doc = gettext(doc)
 if not doc:
 doc = _("(no help text available)")
 h[f] = doc.splitlines()[0].rstrip()
-cmds[f] = '|'.join(fs)
+
+cat = getattr(func, 'helpcategory', None) or (
+registrar.command.CATEGORY_NONE)
+cats.setdefault(cat, []).append(f)
 
 rst = []
 if not h:
 if not ui.quiet:
 rst.append(_('no commands defined\n'))
 return rst
 
+# Output top header.
 if not ui.quiet:
-rst.append(header)
-fns = sorted(h)
-for f in fns:
-if ui.verbose:
-commacmds = cmds[f].replace("|",", ")
-rst.append(" :%s: %s\n" % (commacmds, h[f]))
+if name == "shortlist":
+rst.append(_('basic commands:\n\n'))
+elif name == "debug":
+rst.append(_('debug commands (internal and unsupported):\n\n'))
 else:
-rst.append(' :%s: %s\n' % (f, h[f]))
+rst.append(_('list of commands:\n'))
+
+def appendcmds(cmds):
+cmds = sorted(cmds)
+for c in cmds:
+if ui.verbose:
+rst.append(" :%s: %s\n" % (syns[c], h[c]))
+

D5087: help: displaying documented aliases by default

2018-10-14 Thread rdamazio (Rodrigo Damazio Bovendorp)
rdamazio updated this revision to Diff 12127.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D5087?vs=12092=12127

REVISION DETAIL
  https://phab.mercurial-scm.org/D5087

AFFECTED FILES
  mercurial/dispatch.py
  mercurial/help.py
  mercurial/registrar.py
  tests/test-alias.t
  tests/test-help.t

CHANGE DETAILS

diff --git a/tests/test-help.t b/tests/test-help.t
--- a/tests/test-help.t
+++ b/tests/test-help.t
@@ -823,18 +823,38 @@
   > def uisetup(ui):
   > ui.setconfig(b'alias', b'shellalias', b'!echo hi', b'helpext')
   > ui.setconfig(b'alias', b'hgalias', b'summary', b'helpext')
+  > ui.setconfig(b'alias', b'hgalias:doc', b'My doc', b'helpext')
+  > ui.setconfig(b'alias', b'hgalias:category', b'navigation', b'helpext')
+  > ui.setconfig(b'alias', b'hgaliasnodoc', b'summary', b'helpext')
   > 
   > EOF
   $ echo '[extensions]' >> $HGRCPATH
   $ echo "helpext = `pwd`/helpext.py" >> $HGRCPATH
 
 Test for aliases
 
+  $ hg help | grep hgalias
+   hgalias   My doc
+
   $ hg help hgalias
   hg hgalias [--remote]
   
   alias for: hg summary
   
+  My doc
+  
+  defined by: helpext
+  
+  options:
+  
+--remote check for push and pull
+  
+  (some details hidden, use --verbose to show complete help)
+  $ hg help hgaliasnodoc
+  hg hgaliasnodoc [--remote]
+  
+  alias for: hg summary
+  
   summarize working directory state
   
   This generates a brief summary of the working directory state, including
@@ -947,6 +967,7 @@
   
bisectsubdivision search of changesets
heads show branch heads
+   hgalias   My doc
identify  identify the working directory or specified revision
log   show revision history of entire repository or files
   
@@ -2660,6 +2681,13 @@
   hgalias
   
   
+  My doc
+  
+  
+  
+  hgaliasnodoc
+  
+  
   summarize working directory state
   
   
diff --git a/tests/test-alias.t b/tests/test-alias.t
--- a/tests/test-alias.t
+++ b/tests/test-alias.t
@@ -68,17 +68,17 @@
 help
 
   $ hg help -c | grep myinit
-   myinit This is my documented alias for init.
+   myinit   This is my documented alias for init.
   $ hg help -c | grep mycommit
-   mycommit   This is my alias with only doc.
+   mycommit This is my alias with only doc.
   $ hg help -c | grep cleanstatus
-   cleanstatusshow changed files in the working directory
+  [1]
   $ hg help -c | grep lognull
-   lognullLogs the null rev
+   lognull  Logs the null rev
   $ hg help -c | grep dln
-   dlnLogs the null rev
+  [1]
   $ hg help -c | grep recursivedoc
-   recursivedoc   Logs the null rev in debug mode
+   recursivedoc Logs the null rev in debug mode
   $ hg help myinit
   hg myinit [OPTIONS] [BLA] [BLE]
   
@@ -602,7 +602,7 @@
 help for a shell alias
 
   $ hg help -c | grep rebate
-   rebate This is my alias which just prints something.
+   rebate   This is my alias which just prints something.
   $ hg help rebate
   hg rebate [MYARGS]
   
diff --git a/mercurial/registrar.py b/mercurial/registrar.py
--- a/mercurial/registrar.py
+++ b/mercurial/registrar.py
@@ -169,6 +169,10 @@
 """
 
 # Command categories for grouping them in help output.
+# These can also be specified for aliases, like:
+# [alias]
+# myalias = something
+# myalias:category = repo
 CATEGORY_REPO_CREATION = 'repo'
 CATEGORY_REMOTE_REPO_MANAGEMENT = 'remote'
 CATEGORY_COMMITTING = 'commit'
diff --git a/mercurial/help.py b/mercurial/help.py
--- a/mercurial/help.py
+++ b/mercurial/help.py
@@ -189,12 +189,25 @@
 if notomitted:
 rst.append('\n\n.. container:: notomitted\n\n%s\n\n' % notomitted)
 
-def filtercmd(ui, cmd, kw, doc):
+def filtercmd(ui, cmd, func, kw, doc):
 if not ui.debugflag and cmd.startswith("debug") and kw != "debug":
+# Debug command, and user is not looking for those.
 return True
-if not ui.verbose and doc and any(w in doc for w in _exclkeywords):
+if not ui.verbose:
+if not kw and not doc:
+# Command had no documentation, no point in showing it by default.
+return True
+if getattr(func, 'alias', False) and not getattr(func, 'owndoc', 
False):
+# Alias didn't have its own documentation.
+return True
+if doc and any(w in doc for w in _exclkeywords):
+# Documentation has excluded keywords.
+return True
+if kw == "shortlist" and not getattr(func, 'helpbasic', False):
+# We're presenting the short list but the command is not basic.
 return True
 if ui.configbool('help', 'hide.%s' % cmd):
+# Configuration explicitly hides the command.
 return True
 return False
 
@@ -230,13 +243,14 @@
 else:
 summary = ''
 # translate docs *before* searching there
-docs = _(pycompat.getdoc(entry[0])) or ''
+func = 

D5067: help: assigning categories to existing commands

2018-10-14 Thread rdamazio (Rodrigo Damazio Bovendorp)
rdamazio added a comment.


  In https://phab.mercurial-scm.org/D5067#76195, @yuja wrote:
  
  > Can you make these constants untranslated (e.g. 'help' instead of _('Help'))
  >  and map them to corresponding translation later?
  >
  > And, perhaps they can be moved to `registrar.command` so we can avoid
  >  importing help.py everywhere.
  
  
  See if this is what you had in mind. Also updated all parent changesets 
accordingly.

REPOSITORY
  rHG Mercurial

REVISION DETAIL
  https://phab.mercurial-scm.org/D5067

To: rdamazio, durin42, martinvonz, #hg-reviewers
Cc: yuja, mercurial-devel
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


D5069: help: adding a proper declaration for shortlist/basic commands

2018-10-14 Thread rdamazio (Rodrigo Damazio Bovendorp)
This revision was automatically updated to reflect the committed changes.
Closed by commit rHGfa88170c10bb: help: adding a proper declaration for 
shortlist/basic commands (API) (authored by rdamazio, committed by ).

CHANGED PRIOR TO COMMIT
  https://phab.mercurial-scm.org/D5069?vs=12124=12146#toc

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D5069?vs=12124=12146

REVISION DETAIL
  https://phab.mercurial-scm.org/D5069

AFFECTED FILES
  contrib/perf.py
  hgext/absorb.py
  hgext/blackbox.py
  hgext/fastannotate/commands.py
  hgext/githelp.py
  hgext/mq.py
  hgext/record.py
  hgext/sparse.py
  hgext/split.py
  hgext/uncommit.py
  mercurial/cmdutil.py
  mercurial/commands.py
  mercurial/help.py
  mercurial/hgweb/webcommands.py
  mercurial/registrar.py
  tests/test-completion.t

CHANGE DETAILS

diff --git a/tests/test-completion.t b/tests/test-completion.t
--- a/tests/test-completion.t
+++ b/tests/test-completion.t
@@ -231,31 +231,18 @@
 Show all commands + options
   $ hg debugcommands
   add: include, exclude, subrepos, dry-run
+  addremove: similarity, subrepos, include, exclude, dry-run
   annotate: rev, follow, no-follow, text, user, file, date, number, changeset, 
line-number, skip, ignore-all-space, ignore-space-change, ignore-blank-lines, 
ignore-space-at-eol, include, exclude, template
-  clone: noupdate, updaterev, rev, branch, pull, uncompressed, stream, ssh, 
remotecmd, insecure
-  commit: addremove, close-branch, amend, secret, edit, interactive, include, 
exclude, message, logfile, date, user, subrepos
-  diff: rev, change, text, git, binary, nodates, noprefix, show-function, 
reverse, ignore-all-space, ignore-space-change, ignore-blank-lines, 
ignore-space-at-eol, unified, stat, root, include, exclude, subrepos
-  export: bookmark, output, switch-parent, rev, text, git, binary, nodates, 
template
-  forget: interactive, include, exclude, dry-run
-  init: ssh, remotecmd, insecure
-  log: follow, follow-first, date, copies, keyword, rev, line-range, removed, 
only-merges, user, only-branch, branch, prune, patch, git, limit, no-merges, 
stat, graph, style, template, include, exclude
-  merge: force, rev, preview, abort, tool
-  pull: update, force, rev, bookmark, branch, ssh, remotecmd, insecure
-  push: force, rev, bookmark, branch, new-branch, pushvars, ssh, remotecmd, 
insecure
-  remove: after, force, subrepos, include, exclude, dry-run
-  serve: accesslog, daemon, daemon-postexec, errorlog, port, address, prefix, 
name, web-conf, webdir-conf, pid-file, stdio, cmdserver, templates, style, 
ipv6, certificate, print-url, subrepos
-  status: all, modified, added, removed, deleted, clean, unknown, ignored, 
no-status, terse, copies, print0, rev, change, include, exclude, subrepos, 
template
-  summary: remote
-  update: clean, check, merge, date, rev, tool
-  addremove: similarity, subrepos, include, exclude, dry-run
   archive: no-decode, prefix, rev, type, subrepos, include, exclude
   backout: merge, commit, no-commit, parent, rev, edit, tool, include, 
exclude, message, logfile, date, user
   bisect: reset, good, bad, skip, extend, command, noupdate
   bookmarks: force, rev, delete, rename, inactive, list, template
   branch: force, clean, rev
   branches: active, closed, template
   bundle: force, rev, branch, base, all, type, ssh, remotecmd, insecure
   cat: output, rev, decode, include, exclude, template
+  clone: noupdate, updaterev, rev, branch, pull, uncompressed, stream, ssh, 
remotecmd, insecure
+  commit: addremove, close-branch, amend, secret, edit, interactive, include, 
exclude, message, logfile, date, user, subrepos
   config: untrusted, edit, local, global, template
   copy: after, force, include, exclude, dry-run
   debugancestor: 
@@ -317,30 +304,43 @@
   debugwhyunstable: 
   debugwireargs: three, four, five, ssh, remotecmd, insecure
   debugwireproto: localssh, peer, noreadstderr, nologhandshake, ssh, 
remotecmd, insecure
+  diff: rev, change, text, git, binary, nodates, noprefix, show-function, 
reverse, ignore-all-space, ignore-space-change, ignore-blank-lines, 
ignore-space-at-eol, unified, stat, root, include, exclude, subrepos
+  export: bookmark, output, switch-parent, rev, text, git, binary, nodates, 
template
   files: rev, print0, include, exclude, template, subrepos
+  forget: interactive, include, exclude, dry-run
   graft: rev, continue, stop, abort, edit, log, no-commit, force, currentdate, 
currentuser, date, user, tool, dry-run
   grep: print0, all, diff, text, follow, ignore-case, files-with-matches, 
line-number, rev, all-files, user, date, template, include, exclude
   heads: rev, topo, active, closed, style, template
   help: extension, command, keyword, system
   identify: rev, num, id, branch, tags, bookmarks, ssh, remotecmd, insecure, 
template
   import: strip, base, edit, force, no-commit, bypass, partial, exact, prefix, 
import-branch, message, logfile, date, user, similarity
   incoming: force, newest-first, 

D5069: help: adding a proper declaration for shortlist/basic commands

2018-10-14 Thread rdamazio (Rodrigo Damazio Bovendorp)
rdamazio updated this revision to Diff 12124.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D5069?vs=12064=12124

REVISION DETAIL
  https://phab.mercurial-scm.org/D5069

AFFECTED FILES
  contrib/perf.py
  hgext/absorb.py
  hgext/blackbox.py
  hgext/fastannotate/commands.py
  hgext/githelp.py
  hgext/mq.py
  hgext/record.py
  hgext/sparse.py
  hgext/split.py
  hgext/uncommit.py
  mercurial/cmdutil.py
  mercurial/commands.py
  mercurial/help.py
  mercurial/hgweb/webcommands.py
  mercurial/registrar.py
  tests/test-completion.t

CHANGE DETAILS

diff --git a/tests/test-completion.t b/tests/test-completion.t
--- a/tests/test-completion.t
+++ b/tests/test-completion.t
@@ -231,31 +231,18 @@
 Show all commands + options
   $ hg debugcommands
   add: include, exclude, subrepos, dry-run
+  addremove: similarity, subrepos, include, exclude, dry-run
   annotate: rev, follow, no-follow, text, user, file, date, number, changeset, 
line-number, skip, ignore-all-space, ignore-space-change, ignore-blank-lines, 
ignore-space-at-eol, include, exclude, template
-  clone: noupdate, updaterev, rev, branch, pull, uncompressed, stream, ssh, 
remotecmd, insecure
-  commit: addremove, close-branch, amend, secret, edit, interactive, include, 
exclude, message, logfile, date, user, subrepos
-  diff: rev, change, text, git, binary, nodates, noprefix, show-function, 
reverse, ignore-all-space, ignore-space-change, ignore-blank-lines, 
ignore-space-at-eol, unified, stat, root, include, exclude, subrepos
-  export: bookmark, output, switch-parent, rev, text, git, binary, nodates, 
template
-  forget: interactive, include, exclude, dry-run
-  init: ssh, remotecmd, insecure
-  log: follow, follow-first, date, copies, keyword, rev, line-range, removed, 
only-merges, user, only-branch, branch, prune, patch, git, limit, no-merges, 
stat, graph, style, template, include, exclude
-  merge: force, rev, preview, abort, tool
-  pull: update, force, rev, bookmark, branch, ssh, remotecmd, insecure
-  push: force, rev, bookmark, branch, new-branch, pushvars, ssh, remotecmd, 
insecure
-  remove: after, force, subrepos, include, exclude, dry-run
-  serve: accesslog, daemon, daemon-postexec, errorlog, port, address, prefix, 
name, web-conf, webdir-conf, pid-file, stdio, cmdserver, templates, style, 
ipv6, certificate, print-url, subrepos
-  status: all, modified, added, removed, deleted, clean, unknown, ignored, 
no-status, terse, copies, print0, rev, change, include, exclude, subrepos, 
template
-  summary: remote
-  update: clean, check, merge, date, rev, tool
-  addremove: similarity, subrepos, include, exclude, dry-run
   archive: no-decode, prefix, rev, type, subrepos, include, exclude
   backout: merge, commit, no-commit, parent, rev, edit, tool, include, 
exclude, message, logfile, date, user
   bisect: reset, good, bad, skip, extend, command, noupdate
   bookmarks: force, rev, delete, rename, inactive, list, template
   branch: force, clean, rev
   branches: active, closed, template
   bundle: force, rev, branch, base, all, type, ssh, remotecmd, insecure
   cat: output, rev, decode, include, exclude, template
+  clone: noupdate, updaterev, rev, branch, pull, uncompressed, stream, ssh, 
remotecmd, insecure
+  commit: addremove, close-branch, amend, secret, edit, interactive, include, 
exclude, message, logfile, date, user, subrepos
   config: untrusted, edit, local, global, template
   copy: after, force, include, exclude, dry-run
   debugancestor: 
@@ -317,30 +304,43 @@
   debugwhyunstable: 
   debugwireargs: three, four, five, ssh, remotecmd, insecure
   debugwireproto: localssh, peer, noreadstderr, nologhandshake, ssh, 
remotecmd, insecure
+  diff: rev, change, text, git, binary, nodates, noprefix, show-function, 
reverse, ignore-all-space, ignore-space-change, ignore-blank-lines, 
ignore-space-at-eol, unified, stat, root, include, exclude, subrepos
+  export: bookmark, output, switch-parent, rev, text, git, binary, nodates, 
template
   files: rev, print0, include, exclude, template, subrepos
+  forget: interactive, include, exclude, dry-run
   graft: rev, continue, stop, abort, edit, log, no-commit, force, currentdate, 
currentuser, date, user, tool, dry-run
   grep: print0, all, diff, text, follow, ignore-case, files-with-matches, 
line-number, rev, all-files, user, date, template, include, exclude
   heads: rev, topo, active, closed, style, template
   help: extension, command, keyword, system
   identify: rev, num, id, branch, tags, bookmarks, ssh, remotecmd, insecure, 
template
   import: strip, base, edit, force, no-commit, bypass, partial, exact, prefix, 
import-branch, message, logfile, date, user, similarity
   incoming: force, newest-first, bundle, rev, bookmarks, branch, patch, git, 
limit, no-merges, stat, graph, style, template, ssh, remotecmd, insecure, 
subrepos
+  init: ssh, remotecmd, insecure
   locate: rev, print0, fullpath, include, exclude
+  log: follow, follow-first, date, 

D5067: help: assigning categories to existing commands

2018-10-14 Thread rdamazio (Rodrigo Damazio Bovendorp)
This revision was automatically updated to reflect the committed changes.
Closed by commit rHGc303d65d2e34: help: assigning categories to existing 
commands (authored by rdamazio, committed by ).

CHANGED PRIOR TO COMMIT
  https://phab.mercurial-scm.org/D5067?vs=12122=12145#toc

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D5067?vs=12122=12145

REVISION DETAIL
  https://phab.mercurial-scm.org/D5067

AFFECTED FILES
  hgext/absorb.py
  hgext/amend.py
  hgext/blackbox.py
  hgext/censor.py
  hgext/children.py
  hgext/churn.py
  hgext/closehead.py
  hgext/extdiff.py
  hgext/fetch.py
  hgext/fix.py
  hgext/githelp.py
  hgext/gpg.py
  hgext/graphlog.py
  hgext/hgk.py
  hgext/histedit.py
  hgext/journal.py
  hgext/mq.py
  hgext/patchbomb.py
  hgext/purge.py
  hgext/rebase.py
  hgext/record.py
  hgext/releasenotes.py
  hgext/relink.py
  hgext/share.py
  hgext/shelve.py
  hgext/show.py
  hgext/split.py
  hgext/strip.py
  hgext/transplant.py
  hgext/uncommit.py
  mercurial/commands.py
  mercurial/help.py
  mercurial/registrar.py
  tests/test-globalopts.t
  tests/test-help.t
  tests/test-mq.t

CHANGE DETAILS

diff --git a/tests/test-mq.t b/tests/test-mq.t
--- a/tests/test-mq.t
+++ b/tests/test-mq.t
@@ -73,29 +73,46 @@
   
   list of commands:
   
+  Repository creation:
+  
+   qcloneclone main and patch repository at same time
+  
+  Change creation:
+  
+   qnew  create a new patch
+   qrefresh  update the current patch
+  
+  Change manipulation:
+  
+   qfold fold the named patches into the current patch
+  
+  Change organization:
+  
qapplied  print the patches already applied
-   qcloneclone main and patch repository at same time
qdelete   remove patches from queue
-   qdiff diff of the current patch and subsequent modifications
qfinish   move applied patches into repository history
-   qfold fold the named patches into the current patch
qgoto push or pop patches until named patch is at top of stack
qguardset or print guards for a patch
qheader   print the header of the topmost or specified patch
-   qimport   import a patch or existing changeset
-   qnew  create a new patch
qnext print the name of the next pushable patch
qpop  pop the current patch off the stack
qprev print the name of the preceding applied patch
qpush push the next patch onto the stack
qqueuemanage multiple patch queues
-   qrefresh  update the current patch
qrename   rename a patch
qselect   set or print guarded patches to push
qseries   print the entire series file
qtop  print the name of the current patch
qunappliedprint the patches not yet applied
   
+  File content management:
+  
+   qdiff diff of the current patch and subsequent modifications
+  
+  Change import/export:
+  
+   qimport   import a patch or existing changeset
+  
   (use 'hg help -v mq' to show built-in aliases and global options)
 
   $ hg init a
diff --git a/tests/test-help.t b/tests/test-help.t
--- a/tests/test-help.t
+++ b/tests/test-help.t
@@ -53,55 +53,87 @@
   
   list of commands:
   
-   add   add the specified files on the next commit
-   addremove add all new files, delete all missing files
-   annotate  show changeset information by line for each file
-   archive   create an unversioned archive of a repository revision
+  Repository creation:
+  
+   clone make a copy of an existing repository
+   init  create a new repository in the given directory
+  
+  Remote repository management:
+  
+   incoming  show new changesets found in source
+   outgoing  show changesets not found in the destination
+   paths show aliases for remote repositories
+   pull  pull changes from the specified source
+   push  push changes to the specified destination
+   serve start stand-alone webserver
+  
+  Change creation:
+  
+   commitcommit the specified files or all outstanding changes
+  
+  Change manipulation:
+  
backout   reverse effect of earlier changeset
-   bisectsubdivision search of changesets
+   graft copy changes from other branches onto the current branch
+   merge merge another revision into working directory
+  
+  Change organization:
+  
bookmarks create a new bookmark or list existing bookmarks
branchset or show the current branch name
branches  list repository named branches
-   bundlecreate a bundle file
+   phase set or show the current phase name
+   tag   add one or more tags for the current or given revision
+   tags  list repository tags
+  
+  File content management:
+  
+   annotate  show changeset information by line for each file
cat   output the current or given revision of 

D5068: help: assigning topic categories

2018-10-14 Thread rdamazio (Rodrigo Damazio Bovendorp)
rdamazio updated this revision to Diff 12123.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D5068?vs=12063=12123

REVISION DETAIL
  https://phab.mercurial-scm.org/D5068

AFFECTED FILES
  doc/gendoc.py
  mercurial/help.py
  tests/test-globalopts.t
  tests/test-help.t

CHANGE DETAILS

diff --git a/tests/test-help.t b/tests/test-help.t
--- a/tests/test-help.t
+++ b/tests/test-help.t
@@ -138,29 +138,43 @@
   
   additional help topics:
   
-   bundlespecBundle File Formats
+  Mercurial identifiers:
+  
+   filesets  Specifying File Sets
+   hgignore  Syntax for Mercurial Ignore Files
+   patterns  File Name Patterns
+   revisions Specifying Revisions
+   urls  URL Paths
+  
+  Mercurial output:
+  
color Colorizing Outputs
+   dates Date Formats
+   diffs Diff Formats
+   templatingTemplate Usage
+  
+  Mercurial configuration:
+  
configConfiguration Files
-   dates Date Formats
-   deprecatedDeprecated Features
-   diffs Diff Formats
environment   Environment Variables
extensionsUsing Additional Features
-   filesets  Specifying File Sets
flags Command-line flags
-   glossary  Glossary
-   hgignore  Syntax for Mercurial Ignore Files
hgweb Configuring hgweb
-   internals Technical implementation topics
merge-tools   Merge Tools
pager Pager Support
-   patterns  File Name Patterns
+  
+  Concepts:
+  
+   bundlespecBundle File Formats
+   glossary  Glossary
phasesWorking with Phases
-   revisions Specifying Revisions
+   subrepos  Subrepositories
+  
+  Miscellaneous:
+  
+   deprecatedDeprecated Features
+   internals Technical implementation topics
scripting Using Mercurial from scripts and automation
-   subrepos  Subrepositories
-   templatingTemplate Usage
-   urls  URL Paths
   
   (use 'hg help -v' to show built-in aliases and global options)
 
@@ -250,29 +264,43 @@
   
   additional help topics:
   
-   bundlespecBundle File Formats
+  Mercurial identifiers:
+  
+   filesets  Specifying File Sets
+   hgignore  Syntax for Mercurial Ignore Files
+   patterns  File Name Patterns
+   revisions Specifying Revisions
+   urls  URL Paths
+  
+  Mercurial output:
+  
color Colorizing Outputs
+   dates Date Formats
+   diffs Diff Formats
+   templatingTemplate Usage
+  
+  Mercurial configuration:
+  
configConfiguration Files
-   dates Date Formats
-   deprecatedDeprecated Features
-   diffs Diff Formats
environment   Environment Variables
extensionsUsing Additional Features
-   filesets  Specifying File Sets
flags Command-line flags
-   glossary  Glossary
-   hgignore  Syntax for Mercurial Ignore Files
hgweb Configuring hgweb
-   internals Technical implementation topics
merge-tools   Merge Tools
pager Pager Support
-   patterns  File Name Patterns
+  
+  Concepts:
+  
+   bundlespecBundle File Formats
+   glossary  Glossary
phasesWorking with Phases
-   revisions Specifying Revisions
+   subrepos  Subrepositories
+  
+  Miscellaneous:
+  
+   deprecatedDeprecated Features
+   internals Technical implementation topics
scripting Using Mercurial from scripts and automation
-   subrepos  Subrepositories
-   templatingTemplate Usage
-   urls  URL Paths
 
 Test extension help:
   $ hg help extensions --config extensions.rebase= --config 
extensions.children=
@@ -963,29 +991,43 @@
   
   additional help topics:
   
-   bundlespecBundle File Formats
+  Mercurial identifiers:
+  
+   filesets  Specifying File Sets
+   hgignore  Syntax for Mercurial Ignore Files
+   patterns  File Name Patterns
+   revisions Specifying Revisions
+   urls  URL Paths
+  
+  Mercurial output:
+  
color Colorizing Outputs
+   dates Date Formats
+   diffs Diff Formats
+   templatingTemplate Usage
+  
+  Mercurial configuration:
+  
configConfiguration Files
-   dates Date Formats
-   deprecatedDeprecated Features
-   diffs Diff Formats
environment   Environment Variables
extensionsUsing Additional Features
-   filesets  Specifying File Sets
flags Command-line flags
-   glossary  Glossary
-   hgignore  Syntax for Mercurial Ignore Files
hgweb Configuring hgweb
-   internals Technical implementation topics
merge-tools   Merge Tools
pager Pager Support
-   patterns  File Name Patterns
+  
+  Concepts:
+  
+   bundlespecBundle File Formats
+   glossary  Glossary
phasesWorking with Phases
-   revisions Specifying Revisions
+   subrepos  Subrepositories
+  
+  Miscellaneous:
+  

D5066: help: splitting the topics by category

2018-10-14 Thread rdamazio (Rodrigo Damazio Bovendorp)
rdamazio updated this revision to Diff 12121.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D5066?vs=12061=12121

REVISION DETAIL
  https://phab.mercurial-scm.org/D5066

AFFECTED FILES
  mercurial/help.py
  mercurial/hgweb/webcommands.py

CHANGE DETAILS

diff --git a/mercurial/hgweb/webcommands.py b/mercurial/hgweb/webcommands.py
--- a/mercurial/hgweb/webcommands.py
+++ b/mercurial/hgweb/webcommands.py
@@ -1401,7 +1401,8 @@
 topicname = web.req.qsparams.get('node')
 if not topicname:
 def topics(context):
-for entries, summary, _doc in helpmod.helptable:
+for h in helpmod.helptable:
+entries, summary, _doc = h[0:3]
 yield {'topic': entries[0], 'summary': summary}
 
 early, other = [], []
diff --git a/mercurial/help.py b/mercurial/help.py
--- a/mercurial/help.py
+++ b/mercurial/help.py
@@ -62,6 +62,22 @@
 registrar.command.CATEGORY_NONE: 'Uncategorized commands',
 }
 
+# Topic categories.
+TOPIC_CATEGORY_NONE = 'none'
+
+# The order in which topic categories will be displayed.
+# Extensions with custom categories should insert them into this list
+# after/before the appropriate item, rather than replacing the list or
+# assuming absolute positions.
+TOPIC_CATEGORY_ORDER = [
+TOPIC_CATEGORY_NONE,
+]
+
+# Human-readable topic category names. These are translated.
+TOPIC_CATEGORY_NAMES = {
+TOPIC_CATEGORY_NONE: 'Uncategorized topics',
+}
+
 def listexts(header, exts, indent=1, showdeprecated=False):
 '''return a text listing of the given extensions'''
 rst = []
@@ -152,7 +168,8 @@
'extensions': [],
'extensioncommands': [],
}
-for names, header, doc in helptable:
+for topic in helptable:
+names, header, doc = topic[0:3]
 # Old extensions may use a str as doc.
 if (sum(map(lowercontains, names))
 or lowercontains(header)
@@ -520,12 +537,35 @@
 rst.append('\n')
 rst.extend(exts)
 
-rst.append(_("\nadditional help topics:\n\n"))
-topics = []
-for names, header, doc in helptable:
-topics.append((names[0], header))
-for t, desc in topics:
-rst.append(" :%s: %s\n" % (t, desc))
+rst.append(_("\nadditional help topics:\n"))
+# Group commands by category.
+topiccats = {}
+for topic in helptable:
+names, header, doc = topic[0:3]
+if len(topic) > 3 and topic[3]:
+category = topic[3]
+else:
+category = TOPIC_CATEGORY_NONE
+
+topiccats.setdefault(category, []).append((names[0], header))
+
+# Check that all categories have an order.
+missing_order = set(topiccats.keys()) - set(TOPIC_CATEGORY_ORDER)
+if missing_order:
+ui.develwarn(
+'Help categories missing from TOPIC_CATEGORY_ORDER: %s' %
+missing_order)
+
+# Output topics per category.
+for cat in TOPIC_CATEGORY_ORDER:
+topics = topiccats.get(cat, [])
+if topics:
+if len(topiccats) > 1:
+catname = gettext(TOPIC_CATEGORY_NAMES[cat])
+rst.append("\n%s:\n" % catname)
+rst.append("\n")
+for t, desc in topics:
+rst.append(" :%s: %s\n" % (t, desc))
 
 if ui.quiet:
 pass
@@ -560,7 +600,8 @@
 break
 
 if not header:
-for names, header, doc in helptable:
+for topic in helptable:
+names, header, doc = topic[0:3]
 if name in names:
 break
 else:



To: rdamazio, #hg-reviewers
Cc: mercurial-devel
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


D5076: help: allow commands to be hidden

2018-10-14 Thread rdamazio (Rodrigo Damazio Bovendorp)
rdamazio updated this revision to Diff 12125.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D5076?vs=12065=12125

REVISION DETAIL
  https://phab.mercurial-scm.org/D5076

AFFECTED FILES
  mercurial/configitems.py
  mercurial/help.py
  tests/test-help-hide.t

CHANGE DETAILS

diff --git a/tests/test-help-hide.t b/tests/test-help-hide.t
new file mode 100644
--- /dev/null
+++ b/tests/test-help-hide.t
@@ -0,0 +1,126 @@
+Test hiding some commands (which also happens to hide an entire category).
+
+  $ hg --config help.hide.clone=true --config help.hide.init=true help
+  Mercurial Distributed SCM
+  
+  list of commands:
+  
+  Remote repository management:
+  
+   incoming  show new changesets found in source
+   outgoing  show changesets not found in the destination
+   paths show aliases for remote repositories
+   pull  pull changes from the specified source
+   push  push changes to the specified destination
+   serve start stand-alone webserver
+  
+  Change creation:
+  
+   commitcommit the specified files or all outstanding changes
+  
+  Change manipulation:
+  
+   backout   reverse effect of earlier changeset
+   graft copy changes from other branches onto the current branch
+   merge merge another revision into working directory
+  
+  Change organization:
+  
+   bookmarks create a new bookmark or list existing bookmarks
+   branchset or show the current branch name
+   branches  list repository named branches
+   phase set or show the current phase name
+   tag   add one or more tags for the current or given revision
+   tags  list repository tags
+  
+  File content management:
+  
+   annotate  show changeset information by line for each file
+   cat   output the current or given revision of files
+   copy  mark files as copied for the next commit
+   diff  diff repository (or selected files)
+   grep  search revision history for a pattern in specified files
+  
+  Change navigation:
+  
+   bisectsubdivision search of changesets
+   heads show branch heads
+   identify  identify the working directory or specified revision
+   log   show revision history of entire repository or files
+  
+  Working directory management:
+  
+   add   add the specified files on the next commit
+   addremove add all new files, delete all missing files
+   files list tracked files
+   forgetforget the specified files on the next commit
+   removeremove the specified files on the next commit
+   renamerename files; equivalent of copy + remove
+   resolve   redo merges or set/view the merge status of files
+   revertrestore files to their checkout state
+   root  print the root (top) of the current working directory
+   statusshow changed files in the working directory
+   summary   summarize working directory state
+   updateupdate working directory (or switch revisions)
+  
+  Change import/export:
+  
+   archive   create an unversioned archive of a repository revision
+   bundlecreate a bundle file
+   exportdump the header and diffs for one or more changesets
+   importimport an ordered set of patches
+   unbundle  apply one or more bundle files
+  
+  Repository maintenance:
+  
+   manifest  output the current or given revision of the project manifest
+   recover   roll back an interrupted transaction
+   verifyverify the integrity of the repository
+  
+  Help:
+  
+   configshow combined config settings from all hgrc files
+   help  show help for a given topic or a help overview
+   version   output version and copyright information
+  
+  additional help topics:
+  
+  Mercurial identifiers:
+  
+   filesets  Specifying File Sets
+   hgignore  Syntax for Mercurial Ignore Files
+   patterns  File Name Patterns
+   revisions Specifying Revisions
+   urls  URL Paths
+  
+  Mercurial output:
+  
+   color Colorizing Outputs
+   dates Date Formats
+   diffs Diff Formats
+   templatingTemplate Usage
+  
+  Mercurial configuration:
+  
+   configConfiguration Files
+   environment   Environment Variables
+   extensionsUsing Additional Features
+   flags Command-line flags
+   hgweb Configuring hgweb
+   merge-tools   Merge Tools
+   pager Pager Support
+  
+  Concepts:
+  
+   bundlespecBundle File Formats
+   glossary  Glossary
+   phasesWorking with Phases
+   subrepos  Subrepositories
+  
+  Miscellaneous:
+  
+   deprecatedDeprecated Features
+   internals Technical implementation topics
+   scripting Using Mercurial from scripts and automation
+  
+  (use 'hg help -v' to show built-in aliases and global options)
diff --git 

D5068: help: assigning topic categories

2018-10-14 Thread rdamazio (Rodrigo Damazio Bovendorp)
This revision was automatically updated to reflect the committed changes.
Closed by commit rHGfabbf9310025: help: assigning topic categories (authored by 
rdamazio, committed by ).

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D5068?vs=12123=12144

REVISION DETAIL
  https://phab.mercurial-scm.org/D5068

AFFECTED FILES
  doc/gendoc.py
  mercurial/help.py
  tests/test-globalopts.t
  tests/test-help.t

CHANGE DETAILS

diff --git a/tests/test-help.t b/tests/test-help.t
--- a/tests/test-help.t
+++ b/tests/test-help.t
@@ -138,29 +138,43 @@
   
   additional help topics:
   
-   bundlespecBundle File Formats
+  Mercurial identifiers:
+  
+   filesets  Specifying File Sets
+   hgignore  Syntax for Mercurial Ignore Files
+   patterns  File Name Patterns
+   revisions Specifying Revisions
+   urls  URL Paths
+  
+  Mercurial output:
+  
color Colorizing Outputs
+   dates Date Formats
+   diffs Diff Formats
+   templatingTemplate Usage
+  
+  Mercurial configuration:
+  
configConfiguration Files
-   dates Date Formats
-   deprecatedDeprecated Features
-   diffs Diff Formats
environment   Environment Variables
extensionsUsing Additional Features
-   filesets  Specifying File Sets
flags Command-line flags
-   glossary  Glossary
-   hgignore  Syntax for Mercurial Ignore Files
hgweb Configuring hgweb
-   internals Technical implementation topics
merge-tools   Merge Tools
pager Pager Support
-   patterns  File Name Patterns
+  
+  Concepts:
+  
+   bundlespecBundle File Formats
+   glossary  Glossary
phasesWorking with Phases
-   revisions Specifying Revisions
+   subrepos  Subrepositories
+  
+  Miscellaneous:
+  
+   deprecatedDeprecated Features
+   internals Technical implementation topics
scripting Using Mercurial from scripts and automation
-   subrepos  Subrepositories
-   templatingTemplate Usage
-   urls  URL Paths
   
   (use 'hg help -v' to show built-in aliases and global options)
 
@@ -250,29 +264,43 @@
   
   additional help topics:
   
-   bundlespecBundle File Formats
+  Mercurial identifiers:
+  
+   filesets  Specifying File Sets
+   hgignore  Syntax for Mercurial Ignore Files
+   patterns  File Name Patterns
+   revisions Specifying Revisions
+   urls  URL Paths
+  
+  Mercurial output:
+  
color Colorizing Outputs
+   dates Date Formats
+   diffs Diff Formats
+   templatingTemplate Usage
+  
+  Mercurial configuration:
+  
configConfiguration Files
-   dates Date Formats
-   deprecatedDeprecated Features
-   diffs Diff Formats
environment   Environment Variables
extensionsUsing Additional Features
-   filesets  Specifying File Sets
flags Command-line flags
-   glossary  Glossary
-   hgignore  Syntax for Mercurial Ignore Files
hgweb Configuring hgweb
-   internals Technical implementation topics
merge-tools   Merge Tools
pager Pager Support
-   patterns  File Name Patterns
+  
+  Concepts:
+  
+   bundlespecBundle File Formats
+   glossary  Glossary
phasesWorking with Phases
-   revisions Specifying Revisions
+   subrepos  Subrepositories
+  
+  Miscellaneous:
+  
+   deprecatedDeprecated Features
+   internals Technical implementation topics
scripting Using Mercurial from scripts and automation
-   subrepos  Subrepositories
-   templatingTemplate Usage
-   urls  URL Paths
 
 Test extension help:
   $ hg help extensions --config extensions.rebase= --config 
extensions.children=
@@ -963,29 +991,43 @@
   
   additional help topics:
   
-   bundlespecBundle File Formats
+  Mercurial identifiers:
+  
+   filesets  Specifying File Sets
+   hgignore  Syntax for Mercurial Ignore Files
+   patterns  File Name Patterns
+   revisions Specifying Revisions
+   urls  URL Paths
+  
+  Mercurial output:
+  
color Colorizing Outputs
+   dates Date Formats
+   diffs Diff Formats
+   templatingTemplate Usage
+  
+  Mercurial configuration:
+  
configConfiguration Files
-   dates Date Formats
-   deprecatedDeprecated Features
-   diffs Diff Formats
environment   Environment Variables
extensionsUsing Additional Features
-   filesets  Specifying File Sets
flags Command-line flags
-   glossary  Glossary
-   hgignore  Syntax for Mercurial Ignore Files
hgweb Configuring hgweb
-   internals Technical implementation topics
merge-tools   Merge Tools
pager Pager Support
-   patterns  File Name Patterns
+  
+  Concepts:
+  
+   bundlespecBundle File Formats
+   glossary  Glossary
 

D5067: help: assigning categories to existing commands

2018-10-14 Thread rdamazio (Rodrigo Damazio Bovendorp)
rdamazio updated this revision to Diff 12122.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D5067?vs=12062=12122

REVISION DETAIL
  https://phab.mercurial-scm.org/D5067

AFFECTED FILES
  hgext/absorb.py
  hgext/amend.py
  hgext/blackbox.py
  hgext/censor.py
  hgext/children.py
  hgext/churn.py
  hgext/closehead.py
  hgext/extdiff.py
  hgext/fetch.py
  hgext/fix.py
  hgext/githelp.py
  hgext/gpg.py
  hgext/graphlog.py
  hgext/hgk.py
  hgext/histedit.py
  hgext/journal.py
  hgext/mq.py
  hgext/patchbomb.py
  hgext/purge.py
  hgext/rebase.py
  hgext/record.py
  hgext/releasenotes.py
  hgext/relink.py
  hgext/share.py
  hgext/shelve.py
  hgext/show.py
  hgext/split.py
  hgext/strip.py
  hgext/transplant.py
  hgext/uncommit.py
  mercurial/commands.py
  mercurial/help.py
  mercurial/registrar.py
  tests/test-globalopts.t
  tests/test-help.t
  tests/test-mq.t

CHANGE DETAILS

diff --git a/tests/test-mq.t b/tests/test-mq.t
--- a/tests/test-mq.t
+++ b/tests/test-mq.t
@@ -73,29 +73,46 @@
   
   list of commands:
   
+  Repository creation:
+  
+   qcloneclone main and patch repository at same time
+  
+  Change creation:
+  
+   qnew  create a new patch
+   qrefresh  update the current patch
+  
+  Change manipulation:
+  
+   qfold fold the named patches into the current patch
+  
+  Change organization:
+  
qapplied  print the patches already applied
-   qcloneclone main and patch repository at same time
qdelete   remove patches from queue
-   qdiff diff of the current patch and subsequent modifications
qfinish   move applied patches into repository history
-   qfold fold the named patches into the current patch
qgoto push or pop patches until named patch is at top of stack
qguardset or print guards for a patch
qheader   print the header of the topmost or specified patch
-   qimport   import a patch or existing changeset
-   qnew  create a new patch
qnext print the name of the next pushable patch
qpop  pop the current patch off the stack
qprev print the name of the preceding applied patch
qpush push the next patch onto the stack
qqueuemanage multiple patch queues
-   qrefresh  update the current patch
qrename   rename a patch
qselect   set or print guarded patches to push
qseries   print the entire series file
qtop  print the name of the current patch
qunappliedprint the patches not yet applied
   
+  File content management:
+  
+   qdiff diff of the current patch and subsequent modifications
+  
+  Change import/export:
+  
+   qimport   import a patch or existing changeset
+  
   (use 'hg help -v mq' to show built-in aliases and global options)
 
   $ hg init a
diff --git a/tests/test-help.t b/tests/test-help.t
--- a/tests/test-help.t
+++ b/tests/test-help.t
@@ -53,55 +53,87 @@
   
   list of commands:
   
-   add   add the specified files on the next commit
-   addremove add all new files, delete all missing files
-   annotate  show changeset information by line for each file
-   archive   create an unversioned archive of a repository revision
+  Repository creation:
+  
+   clone make a copy of an existing repository
+   init  create a new repository in the given directory
+  
+  Remote repository management:
+  
+   incoming  show new changesets found in source
+   outgoing  show changesets not found in the destination
+   paths show aliases for remote repositories
+   pull  pull changes from the specified source
+   push  push changes to the specified destination
+   serve start stand-alone webserver
+  
+  Change creation:
+  
+   commitcommit the specified files or all outstanding changes
+  
+  Change manipulation:
+  
backout   reverse effect of earlier changeset
-   bisectsubdivision search of changesets
+   graft copy changes from other branches onto the current branch
+   merge merge another revision into working directory
+  
+  Change organization:
+  
bookmarks create a new bookmark or list existing bookmarks
branchset or show the current branch name
branches  list repository named branches
-   bundlecreate a bundle file
+   phase set or show the current phase name
+   tag   add one or more tags for the current or given revision
+   tags  list repository tags
+  
+  File content management:
+  
+   annotate  show changeset information by line for each file
cat   output the current or given revision of files
-   clone make a copy of an existing repository
-   commitcommit the specified files or all outstanding changes
-   configshow combined config settings from all hgrc files
copy  mark files as 

D5077: help: allow hiding of help topics

2018-10-14 Thread rdamazio (Rodrigo Damazio Bovendorp)
rdamazio updated this revision to Diff 12126.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D5077?vs=12066=12126

REVISION DETAIL
  https://phab.mercurial-scm.org/D5077

AFFECTED FILES
  mercurial/help.py
  tests/test-help-hide.t

CHANGE DETAILS

diff --git a/tests/test-help-hide.t b/tests/test-help-hide.t
--- a/tests/test-help-hide.t
+++ b/tests/test-help-hide.t
@@ -124,3 +124,130 @@
scripting Using Mercurial from scripts and automation
   
   (use 'hg help -v' to show built-in aliases and global options)
+
+Test hiding some topics.
+
+  $ hg --config help.hide.deprecated=true --config help.hide.internals=true \
+  > --config help.hide.scripting=true help
+  Mercurial Distributed SCM
+  
+  list of commands:
+  
+  Repository creation:
+  
+   clone make a copy of an existing repository
+   init  create a new repository in the given directory
+  
+  Remote repository management:
+  
+   incoming  show new changesets found in source
+   outgoing  show changesets not found in the destination
+   paths show aliases for remote repositories
+   pull  pull changes from the specified source
+   push  push changes to the specified destination
+   serve start stand-alone webserver
+  
+  Change creation:
+  
+   commitcommit the specified files or all outstanding changes
+  
+  Change manipulation:
+  
+   backout   reverse effect of earlier changeset
+   graft copy changes from other branches onto the current branch
+   merge merge another revision into working directory
+  
+  Change organization:
+  
+   bookmarks create a new bookmark or list existing bookmarks
+   branchset or show the current branch name
+   branches  list repository named branches
+   phase set or show the current phase name
+   tag   add one or more tags for the current or given revision
+   tags  list repository tags
+  
+  File content management:
+  
+   annotate  show changeset information by line for each file
+   cat   output the current or given revision of files
+   copy  mark files as copied for the next commit
+   diff  diff repository (or selected files)
+   grep  search revision history for a pattern in specified files
+  
+  Change navigation:
+  
+   bisectsubdivision search of changesets
+   heads show branch heads
+   identify  identify the working directory or specified revision
+   log   show revision history of entire repository or files
+  
+  Working directory management:
+  
+   add   add the specified files on the next commit
+   addremove add all new files, delete all missing files
+   files list tracked files
+   forgetforget the specified files on the next commit
+   removeremove the specified files on the next commit
+   renamerename files; equivalent of copy + remove
+   resolve   redo merges or set/view the merge status of files
+   revertrestore files to their checkout state
+   root  print the root (top) of the current working directory
+   statusshow changed files in the working directory
+   summary   summarize working directory state
+   updateupdate working directory (or switch revisions)
+  
+  Change import/export:
+  
+   archive   create an unversioned archive of a repository revision
+   bundlecreate a bundle file
+   exportdump the header and diffs for one or more changesets
+   importimport an ordered set of patches
+   unbundle  apply one or more bundle files
+  
+  Repository maintenance:
+  
+   manifest  output the current or given revision of the project manifest
+   recover   roll back an interrupted transaction
+   verifyverify the integrity of the repository
+  
+  Help:
+  
+   configshow combined config settings from all hgrc files
+   help  show help for a given topic or a help overview
+   version   output version and copyright information
+  
+  additional help topics:
+  
+  Mercurial identifiers:
+  
+   filesets  Specifying File Sets
+   hgignore  Syntax for Mercurial Ignore Files
+   patterns  File Name Patterns
+   revisions Specifying Revisions
+   urls  URL Paths
+  
+  Mercurial output:
+  
+   color Colorizing Outputs
+   dates Date Formats
+   diffs Diff Formats
+   templatingTemplate Usage
+  
+  Mercurial configuration:
+  
+   configConfiguration Files
+   environment   Environment Variables
+   extensionsUsing Additional Features
+   flags Command-line flags
+   hgweb Configuring hgweb
+   merge-tools   Merge Tools
+   pager Pager Support
+  
+  Concepts:
+  
+   bundlespecBundle File Formats
+   glossary  Glossary
+   phasesWorking with Phases
+   subrepos  Subrepositories
+  
+  

D5087: help: displaying documented aliases by default

2018-10-18 Thread rdamazio (Rodrigo Damazio Bovendorp)
rdamazio added a comment.


  In https://phab.mercurial-scm.org/D5087#76401, @yuja wrote:
  
  > > @@ -507,16 +522,11 @@
  > > 
  > >   f = fs[0]
  > >   syns[f] = ', '.join(fs)
  > >   func = e[0]
  > > 
  > > +alias = getattr(func, 'alias', False)
  > > 
  > >   if select and not select(f):
  > >   continue
  > > 
  > > - if (not select and name != 'shortlist' and
  > > - func.__module__ != commands.__name__):
  > > - continue
  > > - if name == "shortlist":
  > > - if not getattr(func, 'helpbasic', False):
  > > - continue doc = pycompat.getdoc(func)
  > > - if filtercmd(ui, f, name, doc): +if filtercmd(ui, f, func, 
name, doc):
  >
  > This makes extension commands get listed in "hg help". I think that's fine,
  >  but can you split patches so we can backout if that causes problem?
  
  
  Done. Sending another review for the extensions part.

REPOSITORY
  rHG Mercurial

REVISION DETAIL
  https://phab.mercurial-scm.org/D5087

To: rdamazio, #hg-reviewers, durin42
Cc: yuja, mercurial-devel
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


D5077: help: allow hiding of help topics

2018-10-18 Thread rdamazio (Rodrigo Damazio Bovendorp)
rdamazio updated this revision to Diff 12255.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D5077?vs=12126=12255

REVISION DETAIL
  https://phab.mercurial-scm.org/D5077

AFFECTED FILES
  mercurial/configitems.py
  mercurial/help.py
  tests/test-help-hide.t

CHANGE DETAILS

diff --git a/tests/test-help-hide.t b/tests/test-help-hide.t
--- a/tests/test-help-hide.t
+++ b/tests/test-help-hide.t
@@ -125,3 +125,131 @@
scripting Using Mercurial from scripts and automation
   
   (use 'hg help -v' to show built-in aliases and global options)
+
+Test hiding some topics.
+
+  $ hg --config help.hidden-topic.deprecated=true \
+  > --config help.hidden-topic.internals=true \
+  > --config help.hidden-topic.scripting=true help
+  Mercurial Distributed SCM
+  
+  list of commands:
+  
+  Repository creation:
+  
+   clone make a copy of an existing repository
+   init  create a new repository in the given directory
+  
+  Remote repository management:
+  
+   incoming  show new changesets found in source
+   outgoing  show changesets not found in the destination
+   paths show aliases for remote repositories
+   pull  pull changes from the specified source
+   push  push changes to the specified destination
+   serve start stand-alone webserver
+  
+  Change creation:
+  
+   commitcommit the specified files or all outstanding changes
+  
+  Change manipulation:
+  
+   backout   reverse effect of earlier changeset
+   graft copy changes from other branches onto the current branch
+   merge merge another revision into working directory
+  
+  Change organization:
+  
+   bookmarks create a new bookmark or list existing bookmarks
+   branchset or show the current branch name
+   branches  list repository named branches
+   phase set or show the current phase name
+   tag   add one or more tags for the current or given revision
+   tags  list repository tags
+  
+  File content management:
+  
+   annotate  show changeset information by line for each file
+   cat   output the current or given revision of files
+   copy  mark files as copied for the next commit
+   diff  diff repository (or selected files)
+   grep  search revision history for a pattern in specified files
+  
+  Change navigation:
+  
+   bisectsubdivision search of changesets
+   heads show branch heads
+   identify  identify the working directory or specified revision
+   log   show revision history of entire repository or files
+  
+  Working directory management:
+  
+   add   add the specified files on the next commit
+   addremove add all new files, delete all missing files
+   files list tracked files
+   forgetforget the specified files on the next commit
+   removeremove the specified files on the next commit
+   renamerename files; equivalent of copy + remove
+   resolve   redo merges or set/view the merge status of files
+   revertrestore files to their checkout state
+   root  print the root (top) of the current working directory
+   statusshow changed files in the working directory
+   summary   summarize working directory state
+   updateupdate working directory (or switch revisions)
+  
+  Change import/export:
+  
+   archive   create an unversioned archive of a repository revision
+   bundlecreate a bundle file
+   exportdump the header and diffs for one or more changesets
+   importimport an ordered set of patches
+   unbundle  apply one or more bundle files
+  
+  Repository maintenance:
+  
+   manifest  output the current or given revision of the project manifest
+   recover   roll back an interrupted transaction
+   verifyverify the integrity of the repository
+  
+  Help:
+  
+   configshow combined config settings from all hgrc files
+   help  show help for a given topic or a help overview
+   version   output version and copyright information
+  
+  additional help topics:
+  
+  Mercurial identifiers:
+  
+   filesets  Specifying File Sets
+   hgignore  Syntax for Mercurial Ignore Files
+   patterns  File Name Patterns
+   revisions Specifying Revisions
+   urls  URL Paths
+  
+  Mercurial output:
+  
+   color Colorizing Outputs
+   dates Date Formats
+   diffs Diff Formats
+   templatingTemplate Usage
+  
+  Mercurial configuration:
+  
+   configConfiguration Files
+   environment   Environment Variables
+   extensionsUsing Additional Features
+   flags Command-line flags
+   hgweb Configuring hgweb
+   merge-tools   Merge Tools
+   pager Pager Support
+  
+  Concepts:
+  
+   bundlespecBundle File Formats
+   glossary  Glossary
+   phases

D5077: help: allow hiding of help topics

2018-10-18 Thread rdamazio (Rodrigo Damazio Bovendorp)
rdamazio added a comment.


  In https://phab.mercurial-scm.org/D5077#76403, @yuja wrote:
  
  > > +def filtertopic(ui, topic):
  > >  +return ui.configbool('help', 'hide.%s' % topic, False)
  >
  > Maybe we need a separate namespace (e.g. help.hidden-topic.%s)?
  
  
  Done.

REPOSITORY
  rHG Mercurial

REVISION DETAIL
  https://phab.mercurial-scm.org/D5077

To: rdamazio, #hg-reviewers
Cc: yuja, mercurial-devel
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


D5087: help: displaying documented aliases by default

2018-10-18 Thread rdamazio (Rodrigo Damazio Bovendorp)
rdamazio updated this revision to Diff 12256.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D5087?vs=12127=12256

REVISION DETAIL
  https://phab.mercurial-scm.org/D5087

AFFECTED FILES
  mercurial/dispatch.py
  mercurial/help.py
  mercurial/registrar.py
  tests/test-alias.t
  tests/test-help.t

CHANGE DETAILS

diff --git a/tests/test-help.t b/tests/test-help.t
--- a/tests/test-help.t
+++ b/tests/test-help.t
@@ -823,18 +823,38 @@
   > def uisetup(ui):
   > ui.setconfig(b'alias', b'shellalias', b'!echo hi', b'helpext')
   > ui.setconfig(b'alias', b'hgalias', b'summary', b'helpext')
+  > ui.setconfig(b'alias', b'hgalias:doc', b'My doc', b'helpext')
+  > ui.setconfig(b'alias', b'hgalias:category', b'navigation', b'helpext')
+  > ui.setconfig(b'alias', b'hgaliasnodoc', b'summary', b'helpext')
   > 
   > EOF
   $ echo '[extensions]' >> $HGRCPATH
   $ echo "helpext = `pwd`/helpext.py" >> $HGRCPATH
 
 Test for aliases
 
+  $ hg help | grep hgalias
+   hgalias   My doc
+
   $ hg help hgalias
   hg hgalias [--remote]
   
   alias for: hg summary
   
+  My doc
+  
+  defined by: helpext
+  
+  options:
+  
+--remote check for push and pull
+  
+  (some details hidden, use --verbose to show complete help)
+  $ hg help hgaliasnodoc
+  hg hgaliasnodoc [--remote]
+  
+  alias for: hg summary
+  
   summarize working directory state
   
   This generates a brief summary of the working directory state, including
@@ -947,6 +967,7 @@
   
bisectsubdivision search of changesets
heads show branch heads
+   hgalias   My doc
identify  identify the working directory or specified revision
log   show revision history of entire repository or files
   
@@ -2662,6 +2683,13 @@
   hgalias
   
   
+  My doc
+  
+  
+  
+  hgaliasnodoc
+  
+  
   summarize working directory state
   
   
diff --git a/tests/test-alias.t b/tests/test-alias.t
--- a/tests/test-alias.t
+++ b/tests/test-alias.t
@@ -68,17 +68,17 @@
 help
 
   $ hg help -c | grep myinit
-   myinit This is my documented alias for init.
+   myinit   This is my documented alias for init.
   $ hg help -c | grep mycommit
-   mycommit   This is my alias with only doc.
+   mycommit This is my alias with only doc.
   $ hg help -c | grep cleanstatus
-   cleanstatusshow changed files in the working directory
+  [1]
   $ hg help -c | grep lognull
-   lognullLogs the null rev
+   lognull  Logs the null rev
   $ hg help -c | grep dln
-   dlnLogs the null rev
+  [1]
   $ hg help -c | grep recursivedoc
-   recursivedoc   Logs the null rev in debug mode
+   recursivedoc Logs the null rev in debug mode
   $ hg help myinit
   hg myinit [OPTIONS] [BLA] [BLE]
   
@@ -602,7 +602,7 @@
 help for a shell alias
 
   $ hg help -c | grep rebate
-   rebate This is my alias which just prints something.
+   rebate   This is my alias which just prints something.
   $ hg help rebate
   hg rebate [MYARGS]
   
diff --git a/mercurial/registrar.py b/mercurial/registrar.py
--- a/mercurial/registrar.py
+++ b/mercurial/registrar.py
@@ -169,6 +169,10 @@
 """
 
 # Command categories for grouping them in help output.
+# These can also be specified for aliases, like:
+# [alias]
+# myalias = something
+# myalias:category = repo
 CATEGORY_REPO_CREATION = 'repo'
 CATEGORY_REMOTE_REPO_MANAGEMENT = 'remote'
 CATEGORY_COMMITTING = 'commit'
diff --git a/mercurial/help.py b/mercurial/help.py
--- a/mercurial/help.py
+++ b/mercurial/help.py
@@ -189,12 +189,25 @@
 if notomitted:
 rst.append('\n\n.. container:: notomitted\n\n%s\n\n' % notomitted)
 
-def filtercmd(ui, cmd, kw, doc):
+def filtercmd(ui, cmd, func, kw, doc):
 if not ui.debugflag and cmd.startswith("debug") and kw != "debug":
+# Debug command, and user is not looking for those.
 return True
-if not ui.verbose and doc and any(w in doc for w in _exclkeywords):
+if not ui.verbose:
+if not kw and not doc:
+# Command had no documentation, no point in showing it by default.
+return True
+if getattr(func, 'alias', False) and not getattr(func, 'owndoc', 
False):
+# Alias didn't have its own documentation.
+return True
+if doc and any(w in doc for w in _exclkeywords):
+# Documentation has excluded keywords.
+return True
+if kw == "shortlist" and not getattr(func, 'helpbasic', False):
+# We're presenting the short list but the command is not basic.
 return True
 if ui.configbool('help', 'hidden-command.%s' % cmd):
+# Configuration explicitly hides the command.
 return True
 return False
 
@@ -230,13 +243,14 @@
 else:
 summary = ''
 # translate docs *before* searching there
-docs = _(pycompat.getdoc(entry[0])) or ''
+

D5076: help: allow commands to be hidden

2018-10-18 Thread rdamazio (Rodrigo Damazio Bovendorp)
rdamazio added a comment.


  In https://phab.mercurial-scm.org/D5076#76405, @yuja wrote:
  
  > > +if ui.configbool('help', 'hide.%s' % cmd):
  > >  +return True
  >
  > Nit: "hidden" or "hidden-command" seems better.
  
  
  Done.

REPOSITORY
  rHG Mercurial

REVISION DETAIL
  https://phab.mercurial-scm.org/D5076

To: rdamazio, #hg-reviewers
Cc: yuja, mercurial-devel
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


D5156: help: displaying extension commands by default

2018-10-18 Thread rdamazio (Rodrigo Damazio Bovendorp)
rdamazio created this revision.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.

REPOSITORY
  rHG Mercurial

REVISION DETAIL
  https://phab.mercurial-scm.org/D5156

AFFECTED FILES
  mercurial/help.py
  tests/test-help.t

CHANGE DETAILS

diff --git a/tests/test-help.t b/tests/test-help.t
--- a/tests/test-help.t
+++ b/tests/test-help.t
@@ -820,6 +820,11 @@
   > def nohelp(ui, *args, **kwargs):
   > pass
   > 
+  > @command(b'hashelp', [], b'hg hashelp', norepo=True)
+  > def hashelp(ui, *args, **kwargs):
+  > """Extension command's help"""
+  > pass
+  > 
   > def uisetup(ui):
   > ui.setconfig(b'alias', b'shellalias', b'!echo hi', b'helpext')
   > ui.setconfig(b'alias', b'hgalias', b'summary', b'helpext')
@@ -904,6 +909,19 @@
   
   (some details hidden, use --verbose to show complete help)
 
+Test that default list of commands includes extension commands that have help,
+but not those that don't, except in verbose mode, when a keyword is passed, or
+when help about the extension is requested.
+
+#if no-extraextensions
+
+  $ hg help | grep hashelp
+   hashelp   Extension command's help
+  $ hg help | grep nohelp
+  [1]
+  $ hg help -v | grep nohelp
+   nohelp(no help text available)
+
   $ hg help -k nohelp
   Commands:
   
@@ -913,144 +931,15 @@
   
nohelp (no help text available)
 
-Test that default list of commands omits extension commands
-
-#if no-extraextensions
-
-  $ hg help
-  Mercurial Distributed SCM
+  $ hg help helpext
+  helpext extension - no help text available
   
   list of commands:
   
-  Repository creation:
-  
-   clone make a copy of an existing repository
-   init  create a new repository in the given directory
-  
-  Remote repository management:
-  
-   incoming  show new changesets found in source
-   outgoing  show changesets not found in the destination
-   paths show aliases for remote repositories
-   pull  pull changes from the specified source
-   push  push changes to the specified destination
-   serve start stand-alone webserver
-  
-  Change creation:
-  
-   commitcommit the specified files or all outstanding changes
-  
-  Change manipulation:
-  
-   backout   reverse effect of earlier changeset
-   graft copy changes from other branches onto the current branch
-   merge merge another revision into working directory
-  
-  Change organization:
-  
-   bookmarks create a new bookmark or list existing bookmarks
-   branchset or show the current branch name
-   branches  list repository named branches
-   phase set or show the current phase name
-   tag   add one or more tags for the current or given revision
-   tags  list repository tags
-  
-  File content management:
-  
-   annotate  show changeset information by line for each file
-   cat   output the current or given revision of files
-   copy  mark files as copied for the next commit
-   diff  diff repository (or selected files)
-   grep  search revision history for a pattern in specified files
-  
-  Change navigation:
-  
-   bisectsubdivision search of changesets
-   heads show branch heads
-   hgalias   My doc
-   identify  identify the working directory or specified revision
-   log   show revision history of entire repository or files
-  
-  Working directory management:
-  
-   add   add the specified files on the next commit
-   addremove add all new files, delete all missing files
-   files list tracked files
-   forgetforget the specified files on the next commit
-   removeremove the specified files on the next commit
-   renamerename files; equivalent of copy + remove
-   resolve   redo merges or set/view the merge status of files
-   revertrestore files to their checkout state
-   root  print the root (top) of the current working directory
-   statusshow changed files in the working directory
-   summary   summarize working directory state
-   updateupdate working directory (or switch revisions)
-  
-  Change import/export:
-  
-   archive   create an unversioned archive of a repository revision
-   bundlecreate a bundle file
-   exportdump the header and diffs for one or more changesets
-   importimport an ordered set of patches
-   unbundle  apply one or more bundle files
-  
-  Repository maintenance:
-  
-   manifest  output the current or given revision of the project manifest
-   recover   roll back an interrupted transaction
-   verifyverify the integrity of the repository
-  
-  Help:
-  
-   configshow combined config settings from all hgrc files
-   help  show help for a given topic or a help overview
-   version   output version and copyright information
-  
-  enabled 

D5156: help: displaying extension commands by default

2018-10-23 Thread rdamazio (Rodrigo Damazio Bovendorp)
This revision was automatically updated to reflect the committed changes.
Closed by commit rHGdce0e0f78f0f: help: displaying extension commands by 
default (authored by rdamazio, committed by ).

CHANGED PRIOR TO COMMIT
  https://phab.mercurial-scm.org/D5156?vs=12257=12319#toc

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D5156?vs=12257=12319

REVISION DETAIL
  https://phab.mercurial-scm.org/D5156

AFFECTED FILES
  mercurial/help.py
  tests/test-help.t

CHANGE DETAILS

diff --git a/tests/test-help.t b/tests/test-help.t
--- a/tests/test-help.t
+++ b/tests/test-help.t
@@ -820,6 +820,11 @@
   > def nohelp(ui, *args, **kwargs):
   > pass
   > 
+  > @command(b'hashelp', [], b'hg hashelp', norepo=True)
+  > def hashelp(ui, *args, **kwargs):
+  > """Extension command's help"""
+  > pass
+  > 
   > def uisetup(ui):
   > ui.setconfig(b'alias', b'shellalias', b'!echo hi', b'helpext')
   > ui.setconfig(b'alias', b'hgalias', b'summary', b'helpext')
@@ -904,6 +909,19 @@
   
   (some details hidden, use --verbose to show complete help)
 
+Test that default list of commands includes extension commands that have help,
+but not those that don't, except in verbose mode, when a keyword is passed, or
+when help about the extension is requested.
+
+#if no-extraextensions
+
+  $ hg help | grep hashelp
+   hashelp   Extension command's help
+  $ hg help | grep nohelp
+  [1]
+  $ hg help -v | grep nohelp
+   nohelp(no help text available)
+
   $ hg help -k nohelp
   Commands:
   
@@ -913,144 +931,15 @@
   
nohelp (no help text available)
 
-Test that default list of commands omits extension commands
-
-#if no-extraextensions
-
-  $ hg help
-  Mercurial Distributed SCM
+  $ hg help helpext
+  helpext extension - no help text available
   
   list of commands:
   
-  Repository creation:
-  
-   clone make a copy of an existing repository
-   init  create a new repository in the given directory
-  
-  Remote repository management:
-  
-   incoming  show new changesets found in source
-   outgoing  show changesets not found in the destination
-   paths show aliases for remote repositories
-   pull  pull changes from the specified source
-   push  push changes to the specified destination
-   serve start stand-alone webserver
-  
-  Change creation:
-  
-   commitcommit the specified files or all outstanding changes
-  
-  Change manipulation:
-  
-   backout   reverse effect of earlier changeset
-   graft copy changes from other branches onto the current branch
-   merge merge another revision into working directory
-  
-  Change organization:
-  
-   bookmarks create a new bookmark or list existing bookmarks
-   branchset or show the current branch name
-   branches  list repository named branches
-   phase set or show the current phase name
-   tag   add one or more tags for the current or given revision
-   tags  list repository tags
-  
-  File content management:
-  
-   annotate  show changeset information by line for each file
-   cat   output the current or given revision of files
-   copy  mark files as copied for the next commit
-   diff  diff repository (or selected files)
-   grep  search revision history for a pattern in specified files
-  
-  Change navigation:
-  
-   bisectsubdivision search of changesets
-   heads show branch heads
-   hgalias   My doc
-   identify  identify the working directory or specified revision
-   log   show revision history of entire repository or files
-  
-  Working directory management:
-  
-   add   add the specified files on the next commit
-   addremove add all new files, delete all missing files
-   files list tracked files
-   forgetforget the specified files on the next commit
-   removeremove the specified files on the next commit
-   renamerename files; equivalent of copy + remove
-   resolve   redo merges or set/view the merge status of files
-   revertrestore files to their checkout state
-   root  print the root (top) of the current working directory
-   statusshow changed files in the working directory
-   summary   summarize working directory state
-   updateupdate working directory (or switch revisions)
-  
-  Change import/export:
-  
-   archive   create an unversioned archive of a repository revision
-   bundlecreate a bundle file
-   exportdump the header and diffs for one or more changesets
-   importimport an ordered set of patches
-   unbundle  apply one or more bundle files
-  
-  Repository maintenance:
-  
-   manifest  output the current or given revision of the project manifest
-   recover   roll back an interrupted transaction
-   verifyverify the integrity of the 

D5076: help: allow commands to be hidden

2018-10-23 Thread rdamazio (Rodrigo Damazio Bovendorp)
This revision was automatically updated to reflect the committed changes.
Closed by commit rHGab09e797fbed: help: allow commands to be hidden (authored 
by rdamazio, committed by ).

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D5076?vs=12254=12316

REVISION DETAIL
  https://phab.mercurial-scm.org/D5076

AFFECTED FILES
  mercurial/configitems.py
  mercurial/help.py
  tests/test-help-hide.t

CHANGE DETAILS

diff --git a/tests/test-help-hide.t b/tests/test-help-hide.t
new file mode 100644
--- /dev/null
+++ b/tests/test-help-hide.t
@@ -0,0 +1,127 @@
+Test hiding some commands (which also happens to hide an entire category).
+
+  $ hg --config help.hidden-command.clone=true \
+  > --config help.hidden-command.init=true help
+  Mercurial Distributed SCM
+  
+  list of commands:
+  
+  Remote repository management:
+  
+   incoming  show new changesets found in source
+   outgoing  show changesets not found in the destination
+   paths show aliases for remote repositories
+   pull  pull changes from the specified source
+   push  push changes to the specified destination
+   serve start stand-alone webserver
+  
+  Change creation:
+  
+   commitcommit the specified files or all outstanding changes
+  
+  Change manipulation:
+  
+   backout   reverse effect of earlier changeset
+   graft copy changes from other branches onto the current branch
+   merge merge another revision into working directory
+  
+  Change organization:
+  
+   bookmarks create a new bookmark or list existing bookmarks
+   branchset or show the current branch name
+   branches  list repository named branches
+   phase set or show the current phase name
+   tag   add one or more tags for the current or given revision
+   tags  list repository tags
+  
+  File content management:
+  
+   annotate  show changeset information by line for each file
+   cat   output the current or given revision of files
+   copy  mark files as copied for the next commit
+   diff  diff repository (or selected files)
+   grep  search revision history for a pattern in specified files
+  
+  Change navigation:
+  
+   bisectsubdivision search of changesets
+   heads show branch heads
+   identify  identify the working directory or specified revision
+   log   show revision history of entire repository or files
+  
+  Working directory management:
+  
+   add   add the specified files on the next commit
+   addremove add all new files, delete all missing files
+   files list tracked files
+   forgetforget the specified files on the next commit
+   removeremove the specified files on the next commit
+   renamerename files; equivalent of copy + remove
+   resolve   redo merges or set/view the merge status of files
+   revertrestore files to their checkout state
+   root  print the root (top) of the current working directory
+   statusshow changed files in the working directory
+   summary   summarize working directory state
+   updateupdate working directory (or switch revisions)
+  
+  Change import/export:
+  
+   archive   create an unversioned archive of a repository revision
+   bundlecreate a bundle file
+   exportdump the header and diffs for one or more changesets
+   importimport an ordered set of patches
+   unbundle  apply one or more bundle files
+  
+  Repository maintenance:
+  
+   manifest  output the current or given revision of the project manifest
+   recover   roll back an interrupted transaction
+   verifyverify the integrity of the repository
+  
+  Help:
+  
+   configshow combined config settings from all hgrc files
+   help  show help for a given topic or a help overview
+   version   output version and copyright information
+  
+  additional help topics:
+  
+  Mercurial identifiers:
+  
+   filesets  Specifying File Sets
+   hgignore  Syntax for Mercurial Ignore Files
+   patterns  File Name Patterns
+   revisions Specifying Revisions
+   urls  URL Paths
+  
+  Mercurial output:
+  
+   color Colorizing Outputs
+   dates Date Formats
+   diffs Diff Formats
+   templatingTemplate Usage
+  
+  Mercurial configuration:
+  
+   configConfiguration Files
+   environment   Environment Variables
+   extensionsUsing Additional Features
+   flags Command-line flags
+   hgweb Configuring hgweb
+   merge-tools   Merge Tools
+   pager Pager Support
+  
+  Concepts:
+  
+   bundlespecBundle File Formats
+   glossary  Glossary
+   phasesWorking with Phases
+   subrepos  Subrepositories
+  
+  Miscellaneous:
+  
+   deprecatedDeprecated Features
+   internals Technical 

D5077: help: allow hiding of help topics

2018-10-23 Thread rdamazio (Rodrigo Damazio Bovendorp)
This revision was automatically updated to reflect the committed changes.
Closed by commit rHG1ddd202c47d9: help: allow hiding of help topics (authored 
by rdamazio, committed by ).

CHANGED PRIOR TO COMMIT
  https://phab.mercurial-scm.org/D5077?vs=12255=12317#toc

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D5077?vs=12255=12317

REVISION DETAIL
  https://phab.mercurial-scm.org/D5077

AFFECTED FILES
  mercurial/configitems.py
  mercurial/help.py
  tests/test-help-hide.t

CHANGE DETAILS

diff --git a/tests/test-help-hide.t b/tests/test-help-hide.t
--- a/tests/test-help-hide.t
+++ b/tests/test-help-hide.t
@@ -125,3 +125,131 @@
scripting Using Mercurial from scripts and automation
   
   (use 'hg help -v' to show built-in aliases and global options)
+
+Test hiding some topics.
+
+  $ hg --config help.hidden-topic.deprecated=true \
+  > --config help.hidden-topic.internals=true \
+  > --config help.hidden-topic.scripting=true help
+  Mercurial Distributed SCM
+  
+  list of commands:
+  
+  Repository creation:
+  
+   clone make a copy of an existing repository
+   init  create a new repository in the given directory
+  
+  Remote repository management:
+  
+   incoming  show new changesets found in source
+   outgoing  show changesets not found in the destination
+   paths show aliases for remote repositories
+   pull  pull changes from the specified source
+   push  push changes to the specified destination
+   serve start stand-alone webserver
+  
+  Change creation:
+  
+   commitcommit the specified files or all outstanding changes
+  
+  Change manipulation:
+  
+   backout   reverse effect of earlier changeset
+   graft copy changes from other branches onto the current branch
+   merge merge another revision into working directory
+  
+  Change organization:
+  
+   bookmarks create a new bookmark or list existing bookmarks
+   branchset or show the current branch name
+   branches  list repository named branches
+   phase set or show the current phase name
+   tag   add one or more tags for the current or given revision
+   tags  list repository tags
+  
+  File content management:
+  
+   annotate  show changeset information by line for each file
+   cat   output the current or given revision of files
+   copy  mark files as copied for the next commit
+   diff  diff repository (or selected files)
+   grep  search revision history for a pattern in specified files
+  
+  Change navigation:
+  
+   bisectsubdivision search of changesets
+   heads show branch heads
+   identify  identify the working directory or specified revision
+   log   show revision history of entire repository or files
+  
+  Working directory management:
+  
+   add   add the specified files on the next commit
+   addremove add all new files, delete all missing files
+   files list tracked files
+   forgetforget the specified files on the next commit
+   removeremove the specified files on the next commit
+   renamerename files; equivalent of copy + remove
+   resolve   redo merges or set/view the merge status of files
+   revertrestore files to their checkout state
+   root  print the root (top) of the current working directory
+   statusshow changed files in the working directory
+   summary   summarize working directory state
+   updateupdate working directory (or switch revisions)
+  
+  Change import/export:
+  
+   archive   create an unversioned archive of a repository revision
+   bundlecreate a bundle file
+   exportdump the header and diffs for one or more changesets
+   importimport an ordered set of patches
+   unbundle  apply one or more bundle files
+  
+  Repository maintenance:
+  
+   manifest  output the current or given revision of the project manifest
+   recover   roll back an interrupted transaction
+   verifyverify the integrity of the repository
+  
+  Help:
+  
+   configshow combined config settings from all hgrc files
+   help  show help for a given topic or a help overview
+   version   output version and copyright information
+  
+  additional help topics:
+  
+  Mercurial identifiers:
+  
+   filesets  Specifying File Sets
+   hgignore  Syntax for Mercurial Ignore Files
+   patterns  File Name Patterns
+   revisions Specifying Revisions
+   urls  URL Paths
+  
+  Mercurial output:
+  
+   color Colorizing Outputs
+   dates Date Formats
+   diffs Diff Formats
+   templatingTemplate Usage
+  
+  Mercurial configuration:
+  
+   configConfiguration Files
+   environment   Environment Variables
+   extensionsUsing Additional Features
+   flags 

D5087: help: displaying documented aliases by default

2018-10-23 Thread rdamazio (Rodrigo Damazio Bovendorp)
This revision was automatically updated to reflect the committed changes.
Closed by commit rHG444861dc1e55: help: displaying documented aliases by 
default (authored by rdamazio, committed by ).

CHANGED PRIOR TO COMMIT
  https://phab.mercurial-scm.org/D5087?vs=12256=12318#toc

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D5087?vs=12256=12318

REVISION DETAIL
  https://phab.mercurial-scm.org/D5087

AFFECTED FILES
  mercurial/dispatch.py
  mercurial/help.py
  mercurial/registrar.py
  tests/test-alias.t
  tests/test-help.t

CHANGE DETAILS

diff --git a/tests/test-help.t b/tests/test-help.t
--- a/tests/test-help.t
+++ b/tests/test-help.t
@@ -823,18 +823,38 @@
   > def uisetup(ui):
   > ui.setconfig(b'alias', b'shellalias', b'!echo hi', b'helpext')
   > ui.setconfig(b'alias', b'hgalias', b'summary', b'helpext')
+  > ui.setconfig(b'alias', b'hgalias:doc', b'My doc', b'helpext')
+  > ui.setconfig(b'alias', b'hgalias:category', b'navigation', b'helpext')
+  > ui.setconfig(b'alias', b'hgaliasnodoc', b'summary', b'helpext')
   > 
   > EOF
   $ echo '[extensions]' >> $HGRCPATH
   $ echo "helpext = `pwd`/helpext.py" >> $HGRCPATH
 
 Test for aliases
 
+  $ hg help | grep hgalias
+   hgalias   My doc
+
   $ hg help hgalias
   hg hgalias [--remote]
   
   alias for: hg summary
   
+  My doc
+  
+  defined by: helpext
+  
+  options:
+  
+--remote check for push and pull
+  
+  (some details hidden, use --verbose to show complete help)
+  $ hg help hgaliasnodoc
+  hg hgaliasnodoc [--remote]
+  
+  alias for: hg summary
+  
   summarize working directory state
   
   This generates a brief summary of the working directory state, including
@@ -947,6 +967,7 @@
   
bisectsubdivision search of changesets
heads show branch heads
+   hgalias   My doc
identify  identify the working directory or specified revision
log   show revision history of entire repository or files
   
@@ -2662,6 +2683,13 @@
   hgalias
   
   
+  My doc
+  
+  
+  
+  hgaliasnodoc
+  
+  
   summarize working directory state
   
   
diff --git a/tests/test-alias.t b/tests/test-alias.t
--- a/tests/test-alias.t
+++ b/tests/test-alias.t
@@ -68,17 +68,17 @@
 help
 
   $ hg help -c | grep myinit
-   myinit This is my documented alias for init.
+   myinit   This is my documented alias for init.
   $ hg help -c | grep mycommit
-   mycommit   This is my alias with only doc.
+   mycommit This is my alias with only doc.
   $ hg help -c | grep cleanstatus
-   cleanstatusshow changed files in the working directory
+  [1]
   $ hg help -c | grep lognull
-   lognullLogs the null rev
+   lognull  Logs the null rev
   $ hg help -c | grep dln
-   dlnLogs the null rev
+  [1]
   $ hg help -c | grep recursivedoc
-   recursivedoc   Logs the null rev in debug mode
+   recursivedoc Logs the null rev in debug mode
   $ hg help myinit
   hg myinit [OPTIONS] [BLA] [BLE]
   
@@ -602,7 +602,7 @@
 help for a shell alias
 
   $ hg help -c | grep rebate
-   rebate This is my alias which just prints something.
+   rebate   This is my alias which just prints something.
   $ hg help rebate
   hg rebate [MYARGS]
   
diff --git a/mercurial/registrar.py b/mercurial/registrar.py
--- a/mercurial/registrar.py
+++ b/mercurial/registrar.py
@@ -169,6 +169,10 @@
 """
 
 # Command categories for grouping them in help output.
+# These can also be specified for aliases, like:
+# [alias]
+# myalias = something
+# myalias:category = repo
 CATEGORY_REPO_CREATION = 'repo'
 CATEGORY_REMOTE_REPO_MANAGEMENT = 'remote'
 CATEGORY_COMMITTING = 'commit'
diff --git a/mercurial/help.py b/mercurial/help.py
--- a/mercurial/help.py
+++ b/mercurial/help.py
@@ -189,12 +189,25 @@
 if notomitted:
 rst.append('\n\n.. container:: notomitted\n\n%s\n\n' % notomitted)
 
-def filtercmd(ui, cmd, kw, doc):
+def filtercmd(ui, cmd, func, kw, doc):
 if not ui.debugflag and cmd.startswith("debug") and kw != "debug":
+# Debug command, and user is not looking for those.
 return True
-if not ui.verbose and doc and any(w in doc for w in _exclkeywords):
+if not ui.verbose:
+if not kw and not doc:
+# Command had no documentation, no point in showing it by default.
+return True
+if getattr(func, 'alias', False) and not getattr(func, 'owndoc', 
False):
+# Alias didn't have its own documentation.
+return True
+if doc and any(w in doc for w in _exclkeywords):
+# Documentation has excluded keywords.
+return True
+if kw == "shortlist" and not getattr(func, 'helpbasic', False):
+# We're presenting the short list but the command is not basic.
 return True
 if ui.configbool('help', 'hidden-command.%s' % cmd):
+# Configuration explicitly 

D5227: pycompat: adding Linux detection and fixing Mac

2018-11-05 Thread rdamazio (Rodrigo Damazio Bovendorp)
rdamazio created this revision.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.

REVISION SUMMARY
  Python 3 recommends detecting OSs with the prefix of the platform, but we were
  comparing the full string for macOS. We also didn't have Linux detection, 
which
  is convenient for extensions to use (rather than have some OSs detected by hg
  and some by the extension).
  
  Reference:
  https://docs.python.org/3/library/sys.html#sys.platform

REPOSITORY
  rHG Mercurial

REVISION DETAIL
  https://phab.mercurial-scm.org/D5227

AFFECTED FILES
  mercurial/pycompat.py

CHANGE DETAILS

diff --git a/mercurial/pycompat.py b/mercurial/pycompat.py
--- a/mercurial/pycompat.py
+++ b/mercurial/pycompat.py
@@ -403,7 +403,8 @@
 
 isjython = sysplatform.startswith(b'java')
 
-isdarwin = sysplatform == b'darwin'
+isdarwin = sysplatform.startswith(b'darwin')
+islinux = sysplatform.startswith(b'linux')
 isposix = osname == b'posix'
 iswindows = osname == b'nt'
 



To: rdamazio, #hg-reviewers
Cc: mercurial-devel
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


D5227: pycompat: adding Linux detection and fixing Mac

2018-11-06 Thread rdamazio (Rodrigo Damazio Bovendorp)
This revision was automatically updated to reflect the committed changes.
Closed by commit rHG1b49b84d5ed5: pycompat: adding Linux detection and fixing 
Mac (authored by rdamazio, committed by ).

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D5227?vs=12439=12443

REVISION DETAIL
  https://phab.mercurial-scm.org/D5227

AFFECTED FILES
  mercurial/pycompat.py

CHANGE DETAILS

diff --git a/mercurial/pycompat.py b/mercurial/pycompat.py
--- a/mercurial/pycompat.py
+++ b/mercurial/pycompat.py
@@ -403,7 +403,8 @@
 
 isjython = sysplatform.startswith(b'java')
 
-isdarwin = sysplatform == b'darwin'
+isdarwin = sysplatform.startswith(b'darwin')
+islinux = sysplatform.startswith(b'linux')
 isposix = osname == b'posix'
 iswindows = osname == b'nt'
 



To: rdamazio, #hg-reviewers, lothiraldan
Cc: lothiraldan, mercurial-devel
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


D5409: remotefilelog: accepting a None node to cmp

2018-12-12 Thread rdamazio (Rodrigo Damazio Bovendorp)
rdamazio added a comment.


  Oops, my oversight - what's passed to cmp is not the same that's compared to 
None in that if :) I have even less confidence on this now.

REPOSITORY
  rHG Mercurial

REVISION DETAIL
  https://phab.mercurial-scm.org/D5409

To: rdamazio, #hg-reviewers
Cc: yuja, mercurial-devel
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


D5409: remotefilelog: accepting a None node to cmp

2018-12-12 Thread rdamazio (Rodrigo Damazio Bovendorp)
rdamazio added a comment.


  In https://phab.mercurial-scm.org/D5409#80203, @yuja wrote:
  
  > >   In context.py, basefilectx.cmp explicitly calls it with None, so it has 
to be
  > >   supported. Specifically, this breaks "hg absorb -i" currently.
  >
  > IIUC, `self._filenode` should never be `None` if the given `fctx._filenode`
  >  is `None`. If `None` were passed down to the filelog layer, exception would
  >  be raised.
  >
  > >   returns True if text is different than what is stored.
  > >   """
  > > 
  > > 
  > > - if node == nullid: +if not node or node == nullid: return True
  >
  > Are we sure that the working-directory data is different from the given 
text?
  
  
  TLDR: I don't know, to be honest, I don't understand RFL deeply enough to 
understand all the edge cases.
  
  About it being None - notice the block that calls this:
  
if (fctx._filenode is None
and (self._repo._encodefilterpats
 # if file data starts with '\1\n', empty metadata block is
 # prepended, which adds 4 bytes to filelog.size().
 or self.size() - 4 == fctx.size())
or self.size() == fctx.size()):
return self._filelog.cmp(self._filenode, fctx.data())
  
  which is essentially:
  
if f == None:
  return filelog.cmp(f)
  
  so I **assumed** it must be the intention to actually pass None, and with so 
much handling, that None was an ok value?
  
  Returning True seemed like the safe approach, rather than claiming the file 
was unmodified, but I'm not confident that it covers 100% of the cases.
  
  If someone has a better understanding of all the remotefilelog 
overriding/interaction here, I'm happy to propose or look at a different patch, 
but this one does fix the immediate issue (absorb -i crashing).

REPOSITORY
  rHG Mercurial

REVISION DETAIL
  https://phab.mercurial-scm.org/D5409

To: rdamazio, #hg-reviewers
Cc: yuja, mercurial-devel
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


D5409: remotefilelog: accepting a None node to cmp

2018-12-10 Thread rdamazio (Rodrigo Damazio Bovendorp)
rdamazio created this revision.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.

REVISION SUMMARY
  In context.py, basefilectx.cmp explicitly calls it with None, so it has to be
  supported. Specifically, this breaks "hg absorb -i" currently.

REPOSITORY
  rHG Mercurial

REVISION DETAIL
  https://phab.mercurial-scm.org/D5409

AFFECTED FILES
  hgext/remotefilelog/remotefilelog.py

CHANGE DETAILS

diff --git a/hgext/remotefilelog/remotefilelog.py 
b/hgext/remotefilelog/remotefilelog.py
--- a/hgext/remotefilelog/remotefilelog.py
+++ b/hgext/remotefilelog/remotefilelog.py
@@ -187,7 +187,7 @@
 returns True if text is different than what is stored.
 """
 
-if node == nullid:
+if not node or node == nullid:
 return True
 
 nodetext = self.read(node)



To: rdamazio, #hg-reviewers
Cc: mercurial-devel
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


D5409: remotefilelog: accepting a None node to cmp

2018-12-10 Thread rdamazio (Rodrigo Damazio Bovendorp)
This revision was automatically updated to reflect the committed changes.
Closed by commit rHG4e17679c336b: remotefilelog: accepting a None node to cmp 
(authored by rdamazio, committed by ).

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D5409?vs=12820=12821

REVISION DETAIL
  https://phab.mercurial-scm.org/D5409

AFFECTED FILES
  hgext/remotefilelog/remotefilelog.py

CHANGE DETAILS

diff --git a/hgext/remotefilelog/remotefilelog.py 
b/hgext/remotefilelog/remotefilelog.py
--- a/hgext/remotefilelog/remotefilelog.py
+++ b/hgext/remotefilelog/remotefilelog.py
@@ -187,7 +187,7 @@
 returns True if text is different than what is stored.
 """
 
-if node == nullid:
+if not node or node == nullid:
 return True
 
 nodetext = self.read(node)



To: rdamazio, #hg-reviewers
Cc: mercurial-devel
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


D5543: histedit: crashing with a more useful error message on empty defaultrev

2019-01-09 Thread rdamazio (Rodrigo Damazio Bovendorp)
rdamazio added a comment.


  (and btw I'd be happier with '' meaning the default, but the original author 
went through the trouble of checking both cases explicitly, so I kept that)

REPOSITORY
  rHG Mercurial

REVISION DETAIL
  https://phab.mercurial-scm.org/D5543

To: rdamazio, durin42, #hg-reviewers
Cc: mercurial-devel
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


D5543: histedit: crashing with a more useful error message on empty defaultrev

2019-01-09 Thread rdamazio (Rodrigo Damazio Bovendorp)
rdamazio created this revision.
Herald added a reviewer: durin42.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.

REVISION SUMMARY
  Before this, `hg --config histedit.defaultrev= histedit` would crash with
  File "destutil.py", line 385, in desthistedit
  
if revs:
  
  UnboundLocalError: local variable 'revs' referenced before assignment

REPOSITORY
  rHG Mercurial

REVISION DETAIL
  https://phab.mercurial-scm.org/D5543

AFFECTED FILES
  mercurial/destutil.py
  tests/test-histedit-arguments.t

CHANGE DETAILS

diff --git a/tests/test-histedit-arguments.t b/tests/test-histedit-arguments.t
--- a/tests/test-histedit-arguments.t
+++ b/tests/test-histedit-arguments.t
@@ -112,6 +112,13 @@
   > pick 08d98a8350f3 4 five
   > EOF
 
+Test invalid config default
+---
+
+  $ hg histedit --config "histedit.defaultrev="
+  abort: config option histedit.defaultrev can't be empty
+  [255]
+
 Run on a revision not descendants of the initial parent
 
 
diff --git a/mercurial/destutil.py b/mercurial/destutil.py
--- a/mercurial/destutil.py
+++ b/mercurial/destutil.py
@@ -381,6 +381,8 @@
 revs = stack.getstack(repo)
 elif default:
 revs = scmutil.revrange(repo, [default])
+else:
+raise error.Abort('config option histedit.defaultrev can\'t be empty')
 
 if revs:
 # Take the first revision of the revset as the root



To: rdamazio, durin42, #hg-reviewers
Cc: mercurial-devel
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


D5543: histedit: crashing with a more useful error message on empty defaultrev

2019-01-10 Thread rdamazio (Rodrigo Damazio Bovendorp)
This revision was automatically updated to reflect the committed changes.
Closed by commit rHGfbd168455b26: histedit: crashing with a more useful error 
message on empty defaultrev (authored by rdamazio, committed by ).

CHANGED PRIOR TO COMMIT
  https://phab.mercurial-scm.org/D5543?vs=13120=13132#toc

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D5543?vs=13120=13132

REVISION DETAIL
  https://phab.mercurial-scm.org/D5543

AFFECTED FILES
  mercurial/destutil.py
  tests/test-histedit-arguments.t

CHANGE DETAILS

diff --git a/tests/test-histedit-arguments.t b/tests/test-histedit-arguments.t
--- a/tests/test-histedit-arguments.t
+++ b/tests/test-histedit-arguments.t
@@ -112,6 +112,13 @@
   > pick 08d98a8350f3 4 five
   > EOF
 
+Test invalid config default
+---
+
+  $ hg histedit --config "histedit.defaultrev="
+  abort: config option histedit.defaultrev can't be empty
+  [255]
+
 Run on a revision not descendants of the initial parent
 
 
diff --git a/mercurial/destutil.py b/mercurial/destutil.py
--- a/mercurial/destutil.py
+++ b/mercurial/destutil.py
@@ -381,6 +381,8 @@
 revs = stack.getstack(repo)
 elif default:
 revs = scmutil.revrange(repo, [default])
+else:
+raise error.Abort(_("config option histedit.defaultrev can't be 
empty"))
 
 if revs:
 # Take the first revision of the revset as the root



To: rdamazio, durin42, #hg-reviewers
Cc: yuja, mercurial-devel
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


D6177: histedit: narrow the scope of discarded ui output

2019-04-01 Thread rdamazio (Rodrigo Damazio Bovendorp)
rdamazio updated this revision to Diff 14614.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D6177?vs=14613=14614

REVISION DETAIL
  https://phab.mercurial-scm.org/D6177

AFFECTED FILES
  hgext/histedit.py
  tests/test-histedit-arguments.t
  tests/test-histedit-edit.t
  tests/test-histedit-fold-non-commute.t
  tests/test-histedit-fold.t
  tests/test-histedit-merge-tools.t
  tests/test-histedit-non-commute.t
  tests/test-histedit-obsolete.t
  tests/test-qrecord.t

CHANGE DETAILS

diff --git a/tests/test-qrecord.t b/tests/test-qrecord.t
--- a/tests/test-qrecord.t
+++ b/tests/test-qrecord.t
@@ -446,7 +446,6 @@
   > edit ea55e2ae468f foo bar
   > EOF
   0 files updated, 0 files merged, 1 files removed, 0 files unresolved
-  adding a
   Editing (ea55e2ae468f), you may commit or record as needed now.
   (hg histedit --continue to resume)
   [1]
diff --git a/tests/test-histedit-obsolete.t b/tests/test-histedit-obsolete.t
--- a/tests/test-histedit-obsolete.t
+++ b/tests/test-histedit-obsolete.t
@@ -216,7 +216,6 @@
   > edit b346ab9a313d 6 c
   > EOF
   0 files updated, 0 files merged, 1 files removed, 0 files unresolved
-  adding c
   Editing (b346ab9a313d), you may commit or record as needed now.
   (hg histedit --continue to resume)
   [1]
@@ -351,7 +350,6 @@
   > pick ee118ab9fa44 16 k
   > EOF
   0 files updated, 0 files merged, 6 files removed, 0 files unresolved
-  adding f
   Editing (b449568bf7fc), you may commit or record as needed now.
   (hg histedit --continue to resume)
   [1]
@@ -394,7 +392,6 @@
   > pick ee118ab9fa44 16 k
   > EOF
   0 files updated, 0 files merged, 6 files removed, 0 files unresolved
-  adding f
   Editing (b449568bf7fc), you may commit or record as needed now.
   (hg histedit --continue to resume)
   [1]
diff --git a/tests/test-histedit-non-commute.t 
b/tests/test-histedit-non-commute.t
--- a/tests/test-histedit-non-commute.t
+++ b/tests/test-histedit-non-commute.t
@@ -87,7 +87,6 @@
 
 edit the history
   $ hg histedit 3 --commands $EDITED 2>&1 | fixbundle
-  2 files updated, 0 files merged, 0 files removed, 0 files unresolved
   merging e
   warning: conflicts while merging e! (edit, then use 'hg resolve --mark')
   Fix up the change (pick 39522b764e3d)
@@ -145,7 +144,6 @@
 
 edit the history
   $ hg histedit 3 --commands $EDITED 2>&1 | fixbundle
-  2 files updated, 0 files merged, 0 files removed, 0 files unresolved
   merging e
   warning: conflicts while merging e! (edit, then use 'hg resolve --mark')
   Fix up the change (pick 39522b764e3d)
@@ -241,7 +239,6 @@
 
 edit the history, this time with a fold action
   $ hg histedit 3 --commands $EDITED 2>&1 | fixbundle
-  2 files updated, 0 files merged, 0 files removed, 0 files unresolved
   merging e
   warning: conflicts while merging e! (edit, then use 'hg resolve --mark')
   Fix up the change (mess 39522b764e3d)
diff --git a/tests/test-histedit-merge-tools.t 
b/tests/test-histedit-merge-tools.t
new file mode 100644
--- /dev/null
+++ b/tests/test-histedit-merge-tools.t
@@ -0,0 +1,57 @@
+Test histedit extension: Merge tools
+
+
+Initialization
+---
+
+  $ . "$TESTDIR/histedit-helpers.sh"
+
+  $ cat >> $HGRCPATH < [alias]
+  > logt = log --template '{rev}:{node|short} {desc|firstline}\n'
+  > [extensions]
+  > histedit=
+  > mockmakedate = $TESTDIR/mockmakedate.py
+  > [ui]
+  > pre-merge-tool-output-template='pre-merge message for {node}\n'
+  > EOF
+
+Merge conflict
+--
+
+  $ hg init r
+  $ cd r
+  $ echo foo > file
+  $ hg add file
+  $ hg ci -m "First" -d "1 0"
+  $ echo bar > file
+  $ hg ci -m "Second" -d "2 0"
+
+  $ hg logt --graph
+  @  1:2aa920f62fb9 Second
+  |
+  o  0:7181f42b8fca First
+  
+
+Invert the order of the commits, but fail the merge.
+  $ hg histedit --config ui.merge=false --commands - 2>&1 < pick 2aa920f62fb9 Second
+  > pick 7181f42b8fca First
+  > EOF
+  merging file
+  pre-merge message for b90fa2e91a6d11013945a5f684be45b84a8ca6ec
+  merging file failed!
+  Fix up the change (pick 7181f42b8fca)
+  (hg histedit --continue to resume)
+
+  $ hg histedit --abort | fixbundle
+  1 files updated, 0 files merged, 0 files removed, 0 files unresolved
+
+Invert the order of the commits, and pretend the merge succeeded.
+  $ hg histedit --config ui.merge=true --commands - 2>&1 < pick 2aa920f62fb9 Second
+  > pick 7181f42b8fca First
+  > EOF
+  merging file
+  pre-merge message for b90fa2e91a6d11013945a5f684be45b84a8ca6ec
+  7181f42b8fca: skipping changeset (no changes)
diff --git a/tests/test-histedit-fold.t b/tests/test-histedit-fold.t
--- a/tests/test-histedit-fold.t
+++ b/tests/test-histedit-fold.t
@@ -287,7 +287,6 @@
   > drop 888f9082bf99 2 +5
   > fold 251d831eeec5 3 +6
   > EOF
-  1 files updated, 0 files merged, 0 files removed, 0 files unresolved
   merging file
   warning: conflicts while merging file! (edit, then use 'hg resolve --mark')
   Fix up the change (fold 251d831eeec5)
@@ -361,7 +360,6 @@
   

D6177: histedit: narrow the scope of discarded ui output

2019-04-01 Thread rdamazio (Rodrigo Damazio Bovendorp)
rdamazio created this revision.
Herald added a reviewer: durin42.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.

REVISION SUMMARY
  In 
https://phab.mercurial-scm.org/rHG34165875fa5df813bec3a0cd348932b304d44efb, a 
lot of the output from
  histedit was excluded. This slightly adjusts the scope of that exclusion,
  to both discard more uninsteresting messages, and ensure that pre-merge-tool
  output gets shown before the external merge tool is executed.

REPOSITORY
  rHG Mercurial

REVISION DETAIL
  https://phab.mercurial-scm.org/D6177

AFFECTED FILES
  hgext/histedit.py
  tests/test-histedit-arguments.t
  tests/test-histedit-edit.t
  tests/test-histedit-fold-non-commute.t
  tests/test-histedit-fold.t
  tests/test-histedit-merge-tools.t
  tests/test-histedit-non-commute.t
  tests/test-histedit-obsolete.t

CHANGE DETAILS

diff --git a/tests/test-histedit-obsolete.t b/tests/test-histedit-obsolete.t
--- a/tests/test-histedit-obsolete.t
+++ b/tests/test-histedit-obsolete.t
@@ -216,7 +216,6 @@
   > edit b346ab9a313d 6 c
   > EOF
   0 files updated, 0 files merged, 1 files removed, 0 files unresolved
-  adding c
   Editing (b346ab9a313d), you may commit or record as needed now.
   (hg histedit --continue to resume)
   [1]
@@ -351,7 +350,6 @@
   > pick ee118ab9fa44 16 k
   > EOF
   0 files updated, 0 files merged, 6 files removed, 0 files unresolved
-  adding f
   Editing (b449568bf7fc), you may commit or record as needed now.
   (hg histedit --continue to resume)
   [1]
@@ -394,7 +392,6 @@
   > pick ee118ab9fa44 16 k
   > EOF
   0 files updated, 0 files merged, 6 files removed, 0 files unresolved
-  adding f
   Editing (b449568bf7fc), you may commit or record as needed now.
   (hg histedit --continue to resume)
   [1]
diff --git a/tests/test-histedit-non-commute.t 
b/tests/test-histedit-non-commute.t
--- a/tests/test-histedit-non-commute.t
+++ b/tests/test-histedit-non-commute.t
@@ -87,7 +87,6 @@
 
 edit the history
   $ hg histedit 3 --commands $EDITED 2>&1 | fixbundle
-  2 files updated, 0 files merged, 0 files removed, 0 files unresolved
   merging e
   warning: conflicts while merging e! (edit, then use 'hg resolve --mark')
   Fix up the change (pick 39522b764e3d)
@@ -145,7 +144,6 @@
 
 edit the history
   $ hg histedit 3 --commands $EDITED 2>&1 | fixbundle
-  2 files updated, 0 files merged, 0 files removed, 0 files unresolved
   merging e
   warning: conflicts while merging e! (edit, then use 'hg resolve --mark')
   Fix up the change (pick 39522b764e3d)
@@ -241,7 +239,6 @@
 
 edit the history, this time with a fold action
   $ hg histedit 3 --commands $EDITED 2>&1 | fixbundle
-  2 files updated, 0 files merged, 0 files removed, 0 files unresolved
   merging e
   warning: conflicts while merging e! (edit, then use 'hg resolve --mark')
   Fix up the change (mess 39522b764e3d)
diff --git a/tests/test-histedit-merge-tools.t 
b/tests/test-histedit-merge-tools.t
new file mode 100644
--- /dev/null
+++ b/tests/test-histedit-merge-tools.t
@@ -0,0 +1,57 @@
+Test histedit extension: Merge tools
+
+
+Initialization
+---
+
+  $ . "$TESTDIR/histedit-helpers.sh"
+
+  $ cat >> $HGRCPATH < [alias]
+  > logt = log --template '{rev}:{node|short} {desc|firstline}\n'
+  > [extensions]
+  > histedit=
+  > mockmakedate = $TESTDIR/mockmakedate.py
+  > [ui]
+  > pre-merge-tool-output-template='pre-merge message for {node}\n'
+  > EOF
+
+Merge conflict
+--
+
+  $ hg init r
+  $ cd r
+  $ echo foo > file
+  $ hg add file
+  $ hg ci -m "First" -d "1 0"
+  $ echo bar > file
+  $ hg ci -m "Second" -d "2 0"
+
+  $ hg logt --graph
+  @  1:2aa920f62fb9 Second
+  |
+  o  0:7181f42b8fca First
+  
+
+Invert the order of the commits, but fail the merge.
+  $ hg histedit --config ui.merge=/bin/false --commands - 2>&1 < pick 2aa920f62fb9 Second
+  > pick 7181f42b8fca First
+  > EOF
+  merging file
+  pre-merge message for b90fa2e91a6d11013945a5f684be45b84a8ca6ec
+  merging file failed!
+  Fix up the change (pick 7181f42b8fca)
+  (hg histedit --continue to resume)
+
+  $ hg histedit --abort | fixbundle
+  1 files updated, 0 files merged, 0 files removed, 0 files unresolved
+
+Invert the order of the commits, and pretend the merge succeeded.
+  $ hg histedit --config ui.merge=/bin/true --commands - 2>&1 < pick 2aa920f62fb9 Second
+  > pick 7181f42b8fca First
+  > EOF
+  merging file
+  pre-merge message for b90fa2e91a6d11013945a5f684be45b84a8ca6ec
+  7181f42b8fca: skipping changeset (no changes)
diff --git a/tests/test-histedit-fold.t b/tests/test-histedit-fold.t
--- a/tests/test-histedit-fold.t
+++ b/tests/test-histedit-fold.t
@@ -287,7 +287,6 @@
   > drop 888f9082bf99 2 +5
   > fold 251d831eeec5 3 +6
   > EOF
-  1 files updated, 0 files merged, 0 files removed, 0 files unresolved
   merging file
   warning: conflicts while merging file! (edit, then use 'hg resolve --mark')
   Fix up the change (fold 251d831eeec5)
@@ -361,7 +360,6 @@
   > drop 

D6177: histedit: narrow the scope of discarded ui output

2019-04-02 Thread rdamazio (Rodrigo Damazio Bovendorp)
This revision was automatically updated to reflect the committed changes.
Closed by commit rHG15d2afa31e57: histedit: narrow the scope of discarded ui 
output (authored by rdamazio, committed by ).

CHANGED PRIOR TO COMMIT
  https://phab.mercurial-scm.org/D6177?vs=14614=14636#toc

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D6177?vs=14614=14636

REVISION DETAIL
  https://phab.mercurial-scm.org/D6177

AFFECTED FILES
  hgext/histedit.py
  tests/test-histedit-arguments.t
  tests/test-histedit-edit.t
  tests/test-histedit-fold-non-commute.t
  tests/test-histedit-fold.t
  tests/test-histedit-merge-tools.t
  tests/test-histedit-non-commute.t
  tests/test-histedit-obsolete.t
  tests/test-qrecord.t

CHANGE DETAILS

diff --git a/tests/test-qrecord.t b/tests/test-qrecord.t
--- a/tests/test-qrecord.t
+++ b/tests/test-qrecord.t
@@ -446,7 +446,6 @@
   > edit ea55e2ae468f foo bar
   > EOF
   0 files updated, 0 files merged, 1 files removed, 0 files unresolved
-  adding a
   Editing (ea55e2ae468f), you may commit or record as needed now.
   (hg histedit --continue to resume)
   [1]
diff --git a/tests/test-histedit-obsolete.t b/tests/test-histedit-obsolete.t
--- a/tests/test-histedit-obsolete.t
+++ b/tests/test-histedit-obsolete.t
@@ -216,7 +216,6 @@
   > edit b346ab9a313d 6 c
   > EOF
   0 files updated, 0 files merged, 1 files removed, 0 files unresolved
-  adding c
   Editing (b346ab9a313d), you may commit or record as needed now.
   (hg histedit --continue to resume)
   [1]
@@ -351,7 +350,6 @@
   > pick ee118ab9fa44 16 k
   > EOF
   0 files updated, 0 files merged, 6 files removed, 0 files unresolved
-  adding f
   Editing (b449568bf7fc), you may commit or record as needed now.
   (hg histedit --continue to resume)
   [1]
@@ -394,7 +392,6 @@
   > pick ee118ab9fa44 16 k
   > EOF
   0 files updated, 0 files merged, 6 files removed, 0 files unresolved
-  adding f
   Editing (b449568bf7fc), you may commit or record as needed now.
   (hg histedit --continue to resume)
   [1]
diff --git a/tests/test-histedit-non-commute.t 
b/tests/test-histedit-non-commute.t
--- a/tests/test-histedit-non-commute.t
+++ b/tests/test-histedit-non-commute.t
@@ -87,7 +87,6 @@
 
 edit the history
   $ hg histedit 3 --commands $EDITED 2>&1 | fixbundle
-  2 files updated, 0 files merged, 0 files removed, 0 files unresolved
   merging e
   warning: conflicts while merging e! (edit, then use 'hg resolve --mark')
   Fix up the change (pick 39522b764e3d)
@@ -145,7 +144,6 @@
 
 edit the history
   $ hg histedit 3 --commands $EDITED 2>&1 | fixbundle
-  2 files updated, 0 files merged, 0 files removed, 0 files unresolved
   merging e
   warning: conflicts while merging e! (edit, then use 'hg resolve --mark')
   Fix up the change (pick 39522b764e3d)
@@ -241,7 +239,6 @@
 
 edit the history, this time with a fold action
   $ hg histedit 3 --commands $EDITED 2>&1 | fixbundle
-  2 files updated, 0 files merged, 0 files removed, 0 files unresolved
   merging e
   warning: conflicts while merging e! (edit, then use 'hg resolve --mark')
   Fix up the change (mess 39522b764e3d)
diff --git a/tests/test-histedit-merge-tools.t 
b/tests/test-histedit-merge-tools.t
new file mode 100644
--- /dev/null
+++ b/tests/test-histedit-merge-tools.t
@@ -0,0 +1,57 @@
+Test histedit extension: Merge tools
+
+
+Initialization
+---
+
+  $ . "$TESTDIR/histedit-helpers.sh"
+
+  $ cat >> $HGRCPATH < [alias]
+  > logt = log --template '{rev}:{node|short} {desc|firstline}\n'
+  > [extensions]
+  > histedit=
+  > mockmakedate = $TESTDIR/mockmakedate.py
+  > [ui]
+  > pre-merge-tool-output-template='pre-merge message for {node}\n'
+  > EOF
+
+Merge conflict
+--
+
+  $ hg init r
+  $ cd r
+  $ echo foo > file
+  $ hg add file
+  $ hg ci -m "First" -d "1 0"
+  $ echo bar > file
+  $ hg ci -m "Second" -d "2 0"
+
+  $ hg logt --graph
+  @  1:2aa920f62fb9 Second
+  |
+  o  0:7181f42b8fca First
+  
+
+Invert the order of the commits, but fail the merge.
+  $ hg histedit --config ui.merge=false --commands - 2>&1 < pick 2aa920f62fb9 Second
+  > pick 7181f42b8fca First
+  > EOF
+  merging file
+  pre-merge message for b90fa2e91a6d11013945a5f684be45b84a8ca6ec
+  merging file failed!
+  Fix up the change (pick 7181f42b8fca)
+  (hg histedit --continue to resume)
+
+  $ hg histedit --abort | fixbundle
+  1 files updated, 0 files merged, 0 files removed, 0 files unresolved
+
+Invert the order of the commits, and pretend the merge succeeded.
+  $ hg histedit --config ui.merge=true --commands - 2>&1 < pick 2aa920f62fb9 Second
+  > pick 7181f42b8fca First
+  > EOF
+  merging file
+  pre-merge message for b90fa2e91a6d11013945a5f684be45b84a8ca6ec
+  7181f42b8fca: skipping changeset (no changes)
diff --git a/tests/test-histedit-fold.t b/tests/test-histedit-fold.t
--- a/tests/test-histedit-fold.t
+++ b/tests/test-histedit-fold.t
@@ -287,7 +287,6 @@
   > drop 888f9082bf99 2 +5
   > fold 251d831eeec5 3 +6
   > 

D5959: templates: adding a config() function for template customization

2019-02-17 Thread rdamazio (Rodrigo Damazio Bovendorp)
This revision was automatically updated to reflect the committed changes.
Closed by commit rHG6704696141b8: templates: adding a config() function for 
template customization (authored by rdamazio, committed by ).

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D5959?vs=14083=14133

REVISION DETAIL
  https://phab.mercurial-scm.org/D5959

AFFECTED FILES
  mercurial/configitems.py
  mercurial/templatefuncs.py
  tests/test-template-functions.t

CHANGE DETAILS

diff --git a/tests/test-template-functions.t b/tests/test-template-functions.t
--- a/tests/test-template-functions.t
+++ b/tests/test-template-functions.t
@@ -1549,4 +1549,31 @@
   $ HGENCODING=utf-8 hg debugtemplate "{pad('`cat utf-8`', 2, '-')}\n"
   \xc3\xa9- (esc)
 
+read config options:
+
+  $ hg log -T "{config('templateconfig', 'knob', 'foo')}\n"
+  foo
+  $ hg log -T "{config('templateconfig', 'knob', 'foo')}\n" \
+  > --config templateconfig.knob=bar
+  bar
+  $ hg log -T "{configbool('templateconfig', 'knob', True)}\n"
+  True
+  $ hg log -T "{configbool('templateconfig', 'knob', True)}\n" \
+  > --config templateconfig.knob=0
+  False
+  $ hg log -T "{configint('templateconfig', 'knob', 123)}\n"
+  123
+  $ hg log -T "{configint('templateconfig', 'knob', 123)}\n" \
+  > --config templateconfig.knob=456
+  456
+  $ hg log -T "{config('templateconfig', 'knob')}\n"
+  devel-warn: config item requires an explicit default value: 
'templateconfig.knob' at: * (glob)
+  
+  $ hg log -T "{configbool('ui', 'interactive')}\n"
+  False
+  $ hg log -T "{configbool('ui', 'interactive')}\n" --config ui.interactive=1
+  True
+  $ hg log -T "{config('templateconfig', 'knob', if(true, 'foo', 'bar'))}\n"
+  foo
+
   $ cd ..
diff --git a/mercurial/templatefuncs.py b/mercurial/templatefuncs.py
--- a/mercurial/templatefuncs.py
+++ b/mercurial/templatefuncs.py
@@ -295,6 +295,39 @@
 hint = _("get() expects a dict as first argument")
 raise error.ParseError(bytes(err), hint=hint)
 
+@templatefunc('config(section, name[, default])', requires={'ui'})
+def config(context, mapping, args):
+"""Returns the requested hgrc config option as a string."""
+fn = context.resource(mapping, 'ui').config
+return _config(context, mapping, args, fn, evalstring)
+
+@templatefunc('configbool(section, name[, default])', requires={'ui'})
+def configbool(context, mapping, args):
+"""Returns the requested hgrc config option as a boolean."""
+fn = context.resource(mapping, 'ui').configbool
+return _config(context, mapping, args, fn, evalboolean)
+
+@templatefunc('configint(section, name[, default])', requires={'ui'})
+def configint(context, mapping, args):
+"""Returns the requested hgrc config option as an integer."""
+fn = context.resource(mapping, 'ui').configint
+return _config(context, mapping, args, fn, evalinteger)
+
+def _config(context, mapping, args, configfn, defaultfn):
+if not (2 <= len(args) <= 3):
+raise error.ParseError(_("config expects two or three arguments"))
+
+# The config option can come from any section, though we specifically
+# reserve the [templateconfig] section for dynamically defining options
+# for this function without also requiring an extension.
+section = evalstringliteral(context, mapping, args[0])
+name = evalstringliteral(context, mapping, args[1])
+if len(args) == 3:
+default = defaultfn(context, mapping, args[2])
+return configfn(section, name, default)
+else:
+return configfn(section, name)
+
 @templatefunc('if(expr, then[, else])')
 def if_(context, mapping, args):
 """Conditionally execute based on the result of
diff --git a/mercurial/configitems.py b/mercurial/configitems.py
--- a/mercurial/configitems.py
+++ b/mercurial/configitems.py
@@ -1081,6 +1081,10 @@
 default=None,
 generic=True,
 )
+coreconfigitem('templateconfig', '.*',
+default=dynamicdefault,
+generic=True,
+)
 coreconfigitem('trusted', 'groups',
 default=list,
 )



To: rdamazio, #hg-reviewers, durin42
Cc: durin42, mercurial-devel
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


D5959: templates: adding a config() function for template customization.

2019-02-13 Thread rdamazio (Rodrigo Damazio Bovendorp)
rdamazio created this revision.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.

REVISION SUMMARY
  This allows templates to be written such that users can customize them easily,
  or that they can be customized based on other configuration of the system.  
For
  enterprise deployments, we often have complex template aliases, and right now
  the only way individual users can customize those is by replacing the whole
  template alias (which means they won't get company-wide updates to it anymore,
  plus most users don't want to have to get a complex template right).
  With this change, they can just set a config option which feeds into our
  templates for common changes (e.g. whether to limit commit descriptions to the
  width of their terminal or not).
  
  To work around the issue of having to register the config options, I declared
  a dedicated section [templateconfig] for these options to be dynamically
  declared. They can still reference any other config option that's registered
  elsewhere.
  
  I only did string, bool and int at this time - list and date would add other
  complications with parsing the default so I'll leave that as an exercise to
  the reader :)

REPOSITORY
  rHG Mercurial

REVISION DETAIL
  https://phab.mercurial-scm.org/D5959

AFFECTED FILES
  mercurial/configitems.py
  mercurial/templatefuncs.py
  tests/test-template-functions.t

CHANGE DETAILS

diff --git a/tests/test-template-functions.t b/tests/test-template-functions.t
--- a/tests/test-template-functions.t
+++ b/tests/test-template-functions.t
@@ -1549,4 +1549,31 @@
   $ HGENCODING=utf-8 hg debugtemplate "{pad('`cat utf-8`', 2, '-')}\n"
   \xc3\xa9- (esc)
 
+read config options:
+
+  $ hg log -T "{config('templateconfig', 'knob', 'foo')}\n"
+  foo
+  $ hg log -T "{config('templateconfig', 'knob', 'foo')}\n" \
+  > --config templateconfig.knob=bar
+  bar
+  $ hg log -T "{configbool('templateconfig', 'knob', True)}\n"
+  True
+  $ hg log -T "{configbool('templateconfig', 'knob', True)}\n" \
+  > --config templateconfig.knob=0
+  False
+  $ hg log -T "{configint('templateconfig', 'knob', 123)}\n"
+  123
+  $ hg log -T "{configint('templateconfig', 'knob', 123)}\n" \
+  > --config templateconfig.knob=456
+  456
+  $ hg log -T "{config('templateconfig', 'knob')}\n"
+  devel-warn: config item requires an explicit default value: 
'templateconfig.knob' at: * (glob)
+  
+  $ hg log -T "{configbool('ui', 'interactive')}\n"
+  False
+  $ hg log -T "{configbool('ui', 'interactive')}\n" --config ui.interactive=1
+  True
+  $ hg log -T "{config('templateconfig', 'knob', if(true, 'foo', 'bar'))}\n"
+  foo
+
   $ cd ..
diff --git a/mercurial/templatefuncs.py b/mercurial/templatefuncs.py
--- a/mercurial/templatefuncs.py
+++ b/mercurial/templatefuncs.py
@@ -295,6 +295,39 @@
 hint = _("get() expects a dict as first argument")
 raise error.ParseError(bytes(err), hint=hint)
 
+@templatefunc('config(section, name[, default])', requires={'ui'})
+def config(context, mapping, args):
+"""Returns the requested hgrc config option as a string."""
+fn = context.resource(mapping, 'ui').config
+return _config(context, mapping, args, fn, evalstring)
+
+@templatefunc('configbool(section, name[, default])', requires={'ui'})
+def configbool(context, mapping, args):
+"""Returns the requested hgrc config option as a boolean."""
+fn = context.resource(mapping, 'ui').configbool
+return _config(context, mapping, args, fn, evalboolean)
+
+@templatefunc('configint(section, name[, default])', requires={'ui'})
+def configint(context, mapping, args):
+"""Returns the requested hgrc config option as an integer."""
+fn = context.resource(mapping, 'ui').configint
+return _config(context, mapping, args, fn, evalinteger)
+
+def _config(context, mapping, args, configfn, defaultfn):
+if not (2 <= len(args) <= 3):
+raise error.ParseError(_("config expects two or three arguments"))
+
+# The config option can come from any section, though we specifically
+# reserve the [templateconfig] section for dynamically defining options
+# for this function without also requiring an extension.
+section = evalstringliteral(context, mapping, args[0])
+name = evalstringliteral(context, mapping, args[1])
+if len(args) == 3:
+default = defaultfn(context, mapping, args[2])
+return configfn(section, name, default)
+else:
+return configfn(section, name)
+
 @templatefunc('if(expr, then[, else])')
 def if_(context, mapping, args):
 """Conditionally execute based on the result of
diff --git a/mercurial/configitems.py b/mercurial/configitems.py
--- a/mercurial/configitems.py
+++ b/mercurial/configitems.py
@@ -1081,6 +1081,10 @@
 default=None,
 generic=True,
 )
+coreconfigitem('templateconfig', '.*',
+default=dynamicdefault,
+generic=True,
+)
 coreconfigitem('trusted', 'groups',
 default=list,
 )



To: rdamazio, #hg-reviewers
Cc: 

D6237: absorb: aborting if another operation is in progress

2019-04-16 Thread rdamazio (Rodrigo Damazio Bovendorp)
This revision was automatically updated to reflect the committed changes.
Closed by commit rHG537a8aeb9977: absorb: aborting if another operation is in 
progress (authored by rdamazio, committed by ).

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D6237?vs=14755=14760

REVISION DETAIL
  https://phab.mercurial-scm.org/D6237

AFFECTED FILES
  hgext/absorb.py
  tests/test-absorb-unfinished.t

CHANGE DETAILS

diff --git a/tests/test-absorb-unfinished.t b/tests/test-absorb-unfinished.t
new file mode 100644
--- /dev/null
+++ b/tests/test-absorb-unfinished.t
@@ -0,0 +1,30 @@
+  $ cat >> $HGRCPATH << EOF
+  > [extensions]
+  > absorb=
+  > EOF
+
+Abort absorb if there is an unfinished operation.
+
+  $ hg init abortunresolved
+  $ cd abortunresolved
+
+  $ echo "foo1" > foo.whole
+  $ hg commit -Aqm "foo 1"
+
+  $ hg update null
+  0 files updated, 0 files merged, 1 files removed, 0 files unresolved
+  $ echo "foo2" > foo.whole
+  $ hg commit -Aqm "foo 2"
+
+  $ hg --config extensions.rebase= rebase -r 1 -d 0
+  rebasing 1:c3b6dc0e177a "foo 2" (tip)
+  merging foo.whole
+  warning: conflicts while merging foo.whole! (edit, then use 'hg resolve 
--mark')
+  unresolved conflicts (see hg resolve, then hg rebase --continue)
+  [1]
+
+  $ hg --config extensions.rebase= absorb
+  abort: rebase in progress
+  (use 'hg rebase --continue' or 'hg rebase --abort')
+  [255]
+
diff --git a/hgext/absorb.py b/hgext/absorb.py
--- a/hgext/absorb.py
+++ b/hgext/absorb.py
@@ -682,13 +682,12 @@
 
 def commit(self):
 """commit changes. update self.finalnode, self.replacemap"""
-with self.repo.wlock(), self.repo.lock():
-with self.repo.transaction('absorb') as tr:
-self._commitstack()
-self._movebookmarks(tr)
-if self.repo['.'].node() in self.replacemap:
-self._moveworkingdirectoryparent()
-self._cleanupoldcommits()
+with self.repo.transaction('absorb') as tr:
+self._commitstack()
+self._movebookmarks(tr)
+if self.repo['.'].node() in self.replacemap:
+self._moveworkingdirectoryparent()
+self._cleanupoldcommits()
 return self.finalnode
 
 def printchunkstats(self):
@@ -1006,6 +1005,11 @@
 Returns 0 on success, 1 if all chunks were ignored and nothing amended.
 """
 opts = pycompat.byteskwargs(opts)
-state = absorb(ui, repo, pats=pats, opts=opts)
-if sum(s[0] for s in state.chunkstats.values()) == 0:
-return 1
+
+with repo.wlock(), repo.lock():
+if not opts['dry_run']:
+cmdutil.checkunfinished(repo)
+
+state = absorb(ui, repo, pats=pats, opts=opts)
+if sum(s[0] for s in state.chunkstats.values()) == 0:
+return 1



To: rdamazio, #hg-reviewers, pulkit
Cc: mercurial-devel
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


D6265: narrow: also warn when not deleting untracked or ignored files

2019-04-17 Thread rdamazio (Rodrigo Damazio Bovendorp)
rdamazio added inline comments.

INLINE COMMENTS

> narrowspec.py:310
> +for f in sorted(trackeddirty + status.unknown + status.ignored):
> +if f in unknownset:
> +repo.ui.status(_('not deleting unknown file %s\n') % uipathfn(f))

Just do a loop for each one? You probably also don't need them to be sets.

REPOSITORY
  rHG Mercurial

REVISION DETAIL
  https://phab.mercurial-scm.org/D6265

To: martinvonz, durin42, #hg-reviewers
Cc: rdamazio, mercurial-devel
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


D6436: narrow: use narrow_widen wireproto command to widen in case of ellipses

2019-06-04 Thread rdamazio (Rodrigo Damazio Bovendorp)
rdamazio added a comment.


  Hopefully not too late

INLINE COMMENTS

> pulkit wrote in narrowcommands.py:306
> I believe it streams rather than downloading the whole bundle into memory. 
> `getbundle()` uses the same function and I think we do streaming there. 
> https://www.mercurial-scm.org/repo/hg-committed/file/127937874395/mercurial/exchange.py#l1757
> 
> I also asked @marmoute and he also think that it does streaming.

The difference from the code you're pointing too is that you're calling 
.result() here, which blocks until the results are fully streamed in (see 
httppeer.py) - so I really think this is NOT streaming.

REPOSITORY
  rHG Mercurial

REVISION DETAIL
  https://phab.mercurial-scm.org/D6436

To: pulkit, durin42, martinvonz, #hg-reviewers
Cc: marmoute, rdamazio, mercurial-devel
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


D6436: narrow: use narrow_widen wireproto command to widen in case of ellipses

2019-06-03 Thread rdamazio (Rodrigo Damazio Bovendorp)
rdamazio added inline comments.

INLINE COMMENTS

> narrowcommands.py:306
> +'ellipses': True,
> +}).result()
> +trmanager = exchange.transactionmanager(repo, 'widen',

Being nosy here: does this mean that it'll download the whole bundle into 
memory before it starts applying it, rather than streaming it into the store? 
Bundles, especially in repos using narrow, can be very large, so that would not 
be ideal.

REPOSITORY
  rHG Mercurial

REVISION DETAIL
  https://phab.mercurial-scm.org/D6436

To: pulkit, durin42, martinvonz, #hg-reviewers
Cc: rdamazio, mercurial-devel
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


D6324: help: register the 'gpg' command category and give it a description

2019-05-06 Thread rdamazio (Rodrigo Damazio Bovendorp)
rdamazio added a comment.


  In https://phab.mercurial-scm.org/D6324#92158, @martinvonz wrote:
  
  > This doesn't actually seem to work for making it appear in `hg help`. 
@rdamazio (who added the categories stuff), have you thought about a way of 
letting extensions add categories?
  
  
  I did, this was supposed to be it - maybe I missed something or it broke 
somehow? :/
  I need to migrate Google's extension out of the internal version of help (now 
that I've upstreamed the help changes), I'll definitely need to mess with 
categories for that, too.

INLINE COMMENTS

> martinvonz wrote in gpg.py:56
> This feels a little too specific, but we can come up with a better category 
> for it if we get other related commands.

"Security"?

REPOSITORY
  rHG Mercurial

REVISION DETAIL
  https://phab.mercurial-scm.org/D6324

To: Sietse, #hg-reviewers, martinvonz
Cc: rdamazio, martinvonz, mercurial-devel
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


D6576: py3: use integer division for the value passed to xrange

2019-06-27 Thread rdamazio (Rodrigo Damazio Bovendorp)
Closed by commit rHGf3fa10a5877d: py3: use integer division for the value 
passed to xrange (authored by rdamazio).
This revision was automatically updated to reflect the committed changes.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D6576?vs=15659=15676

CHANGES SINCE LAST ACTION
  https://phab.mercurial-scm.org/D6576/new/

REVISION DETAIL
  https://phab.mercurial-scm.org/D6576

AFFECTED FILES
  mercurial/pure/osutil.py

CHANGE DETAILS

diff --git a/mercurial/pure/osutil.py b/mercurial/pure/osutil.py
--- a/mercurial/pure/osutil.py
+++ b/mercurial/pure/osutil.py
@@ -5,7 +5,7 @@
 # This software may be used and distributed according to the terms of the
 # GNU General Public License version 2 or any later version.
 
-from __future__ import absolute_import
+from __future__ import absolute_import, division
 
 import ctypes
 import ctypes.util
@@ -149,7 +149,7 @@
 cmsg.cmsg_type != _SCM_RIGHTS):
 return []
 rfds = ctypes.cast(cmsg.cmsg_data, ctypes.POINTER(ctypes.c_int))
-rfdscount = ((cmsg.cmsg_len - _cmsghdr.cmsg_data.offset) /
+rfdscount = ((cmsg.cmsg_len - _cmsghdr.cmsg_data.offset) //
  ctypes.sizeof(ctypes.c_int))
 return [rfds[i] for i in pycompat.xrange(rfdscount)]
 



To: rdamazio, #hg-reviewers, pulkit
Cc: mercurial-devel
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


  1   2   >