Commit Graph

189 Commits

Author SHA1 Message Date
Augie Fackler
2e832efca3 pager: move most help to a new help topic and deprecate extension 2017-02-07 00:07:53 -05:00
Augie Fackler
01f8d0793b help: move rst formatting of help documents into help.py
This slight refactor will help me improve the 'unknown command'
experience in our new glorious pager future.
2017-02-21 14:17:31 -05:00
Gregory Szorc
550169e48e help: make "mergetool" an alias for "merge-tools"
I've probably typed `hg help mergetool` dozens of times. I'm tired
of it not working.
2017-01-13 21:21:02 -08:00
Martin von Zweigbergk
1840263a8c help: merge revsets.txt into revisions.txt
Selecting single and multiple revisions is closely related, so let's
put it in one place, so users can easily find it. We actually did not
even point to "hg help revsets" from "hg help revisions", but now that
they're on a single page, that won't be necessary.
2017-01-11 11:37:38 -08:00
Martin von Zweigbergk
8f2ed099c1 help: make multirevs just an alias for revsets
The multirevs topis seems to be covered well by the revsets topic, so
just make it an alias and remove multirevs.txt.
2016-12-16 09:48:14 -08:00
Pierre-Yves David
d482e52866 help: backout 6f89f03ad369 (mark boolean flags with [no-] in help) for now
The ability to negate any boolean flags itself is great, but I think we are not
ready to expose the help side of it yet.

First, while there exist a handful of such flags whose default value can be
changed (eg: git diff, patchwork confirmation), there is only a few of them. The
users who benefit the most from this change are alias users and large
installation that can deploy extension to change behavior (eg: facebook
tweakdefault).  So the majority of user who will be affected by a large change
to command help that is not yet relevant to them. (I expect this to become
relevant when ui.progressive start to exists).

Below is an example of the impact of the new help on 'hg help diff':

  -r --rev REV [+]              revision
  -c --change REV               change made by revision
  -a --[no-]text                treat all files as text
  -g --[no-]git                 use git extended diff format
     --[no-]nodates             omit dates from diff headers
     --[no-]noprefix            omit a/ and b/ prefixes from filenames
  -p --[no-]show-function       show which function each change is in
     --[no-]reverse             produce a diff that undoes the changes
  -w --[no-]ignore-all-space    ignore white space when comparing lines
  -b --[no-]ignore-space-change ignore changes in the amount of white space
  -B --[no-]ignore-blank-lines  ignore changes whose lines are all blank
  -U --unified NUM              number of lines of context to show
     --[no-]stat                output diffstat-style summary of changes
     --root DIR                 produce diffs relative to subdirectory
  -I --include PATTERN [+]      include names matching the given patterns
  -X --exclude PATTERN [+]      exclude names matching the given patterns
  -S --[no-]subrepos            recurse into subrepositories

Another issue with the current state of help, the default value for the
flag is not conveyed to the user. For example in the 'backout' help, there is
no real distinction between "--[no-]backup" (default to True) and "--[no-]keep"
(default) to False:

  --[no-]backup        no backups
  --[no-]keep          do not modify working directory during strip

In addition, I've discussed with Augie Fackler and the last batch of the work on
this have burned him out quite some. Therefore he is not intending to perform
any more work on this topic. Quoting him, he would rather see the help part
backed out than spending more time on it.

I do not think we are ready to expose this to users in 4.0 (freeze in a week),
especially because we cannot expect quick improvement on these aspect as this
topic no longer have an owner. We should be able to reintroduce that change in
the future when someone get back on it and the main issues are solves:

* Introduction of  ui.progressive makes it relevant for a majority of user,
* Current default value are efficiently conveyed to the user.

(In addition, the excerpt from diff help show that we still have some issue with
some negative option like '--nodates' so further improvement are probably
welcome there.)
2016-10-09 03:11:18 +02:00
Augie Fackler
8843ab4c98 help: mark boolean flags with [no-] to explain that they can be negated
That is, help gets tweaked thus:

  global options ([+] can be repeated):
   -v --[no-]verbose      enable additional output


Other proposals have included:

  global options ([+] can be repeated, options marked [?] are boolean flags):
   -v --verbose[?]        enable additional output

and

  global options ([+] can be repeated, options marked [^] are boolean flags):
   -v --verbose[^]        enable additional output

which avoid the unfortunate visual noise in this patch. In this
version's favor, it's consistent with what I'm used to seeing in man
pages and similar documentation venues.
2016-09-13 22:58:12 -04:00
timeless
5fd9e9e1b5 help: use single quotes in use warning 2016-09-20 23:47:46 +00:00
Gregory Szorc
5c136c2209 help: internals topic for wire protocol
The Mercurial wire protocol is under-documented. This includes a lack
of source docstrings and comments as well as pages on the official
wiki.

This patch adds the beginnings of "internals" documentation on the
wire protocol.

The documentation should have nearly complete coverage on the
lower-level parts of the protocol, such as the different transport
mechanims, how commands and arguments are sent, capabilities, and,
of course, the commands themselves.

As part of writing this documentation, I discovered a number of
deficiencies in the protocol and bugs in the implementation. I've
started sending patches for some of the issues. I hope to send a lot
more.

This patch starts with the scaffolding for a new internals page.
2016-08-22 19:46:39 -07:00
Gregory Szorc
efb3c4ff63 help: don't try to render a section on sub-topics
This patch subtly changes the behavior of the parsing of "X.Y" values
to not set the "section" variable when rendering a known sub-topic.
Previously, "section" would be the same as the sub-topic name. This
required the sub-topic RST to have a section named the same as the
sub-topic name.

When I made this change, the descriptions from help.internalstable
started being rendered in command line output. This didn't look correct
to me, as it didn't match the formatting of main help pages. I
corrected this by moving the top section to help.internalstable and
changing the section levels of all the "internals" topics.

The end result is that "internals" topics now match the rendering of
main topics on both the CLI and HTML. And, "internals" topics no longer
require a main section matching the name of the topic.
2016-08-06 17:04:22 -07:00
timeless
4fdfca9cff help: report source of aliases 2016-04-08 18:35:49 +00:00
Gregory Szorc
891be7d008 help: document requirements
We didn't have unified documentation of the various repository
requirements. This patch changes that.
2016-03-12 18:51:07 -08:00
Simon Farnsworth
ff988aaa4b help: don't crash in keyword search if an extension fails to provide docs
Not all external extensions provide docs; if you use such an extension, you
will experience a crash if you use "hg help --keyword <word>", and <word>
happens to match the extension name.
2016-02-10 01:48:58 -08:00
Jun Wu
ea41b32b83 mercurial: pass ui to extensions.load (issue5007)
extensions.load does need ui argument to print error if an extension
fails to load.
2015-12-17 10:30:17 +00:00
Gregory Szorc
8e5f315fff internals: document revlog format
It seems like a good idea to document the revlog format.

There is a lot more that could be added to this documentation.
But you have to start somewhere.
2015-12-30 16:21:57 -07:00
Gregory Szorc
68a8e8f9f4 help: use absolute_import 2015-12-21 21:33:27 -08:00
Yuya Nishihara
c1ebc705e5 help: add missed last new line to "internals" topic
Caught by test-gendoc.t.
2015-12-17 22:29:41 +09:00
timeless
8e17ef3397 help: filter extension commands 2015-12-14 05:29:55 +00:00
Gregory Szorc
aaa8195abf help: support loading sub-topics
If a sub-topic/section is requested and the main topic corresponds to
a topic with sub-topics, we now look for and return content for a
sub-topic if found.

With this patch, `hg help internals.X` now works. hgweb does not yet
render sub-topics, however.
2015-12-13 11:19:55 -08:00
Gregory Szorc
66558406c4 help: pass sub-topic into help query functions
While we will likely only use this variable in helptopic(), all these
functions are called with the same arguments, so we have to be
consistent.
2015-12-13 11:29:01 -08:00
Gregory Szorc
56babdcfc2 help: pass subtopic into help()
Now that we have multiple directories where help topics can live,
we need a mechanism to access them. We already use "." to
separate topic from section. So it seems logical to also use "." to
denote the sub-directory of a topic.

This patch teaches the help command to parse out the possible
sub-topic and pass it to the help system.
2015-12-13 11:04:45 -08:00
Gregory Szorc
82617319e9 help: add "internals" topic
We introduce the "internals" help topic, which renders an index of
available sub-topics. The sub-topics themselves are still not
reachable via the help system.
2015-12-13 10:35:03 -08:00
Gregory Szorc
eb14869664 help: teach loaddoc to load from a different directory
The help system currently only supports showing help topics from a
single directory. We'll need to teach it to show results from
different directories in order to show the internals topics.

The first step is to teach loaddoc() to load documentation from
a sub-directory.
2015-12-13 10:45:27 -08:00
timeless
65f4d64bf2 help: fix help -c/help -e/help -k
Before, hg help -c was the same as hg help, now it only shows commands.
Before, hg help -e was the same as hg help, now it only shows extensions.
Before, hg help -k crashed, now it shows all topics.
2015-12-09 05:56:54 +00:00
timeless
2d7d422638 help: call filtercmd from topicmatch
update test coverage to explicitly define when help -c should
list debug/deprecated items.
2015-12-09 19:09:35 +00:00
timeless
068f6ee2a2 help: refactor filtercmd 2015-12-09 19:09:06 +00:00
timeless
fc1657cf34 help: make help deprecated mention the extension
before this, you got an empty list of extensions, which was unhelpful
2015-11-30 20:45:07 +00:00
timeless
ad3d46dba7 help: make listexts less confusing for deprecated exts
Return an empty array instead of a heading and no items
2015-11-30 20:44:22 +00:00
Anton Shestakov
df6b074b5d help: replace some str.split() calls by str.partition() or str.rpartition()
Since Python 2.5 str has new methods: partition and rpartition. They are more
specialized than the usual split and rsplit, and they sometimes convey the
intent of code better and also are a bit faster (faster than split/rsplit with
maxsplit specified). Let's use them in appropriate places for a small speedup.

Example performance (partition):

$ python -m timeit 'assert "apple|orange|banana".split("|")[0] == "apple"'
1000000 loops, best of 3: 0.376 usec per loop

$ python -m timeit 'assert "apple|orange|banana".split("|", 1)[0] == "apple"'
1000000 loops, best of 3: 0.327 usec per loop

$ python -m timeit 'assert "apple|orange|banana".partition("|")[0] == "apple"'
1000000 loops, best of 3: 0.214 usec per loop

Example performance (rpartition):

$ python -m timeit 'assert "apple|orange|banana".rsplit("|")[-1] == "banana"'
1000000 loops, best of 3: 0.372 usec per loop

$ python -m timeit 'assert "apple|orange|banana".rsplit("|", 1)[-1] == "banana"'
1000000 loops, best of 3: 0.332 usec per loop

$ python -m timeit 'assert "apple|orange|banana".rpartition("|")[-1] == "banana"'
1000000 loops, best of 3: 0.219 usec per loop
2015-11-02 23:37:14 +08:00
Pierre-Yves David
30913031d4 error: get Abort from 'error' instead of 'util'
The home of 'Abort' is 'error' not 'util' however, a lot of code seems to be
confused about that and gives all the credit to 'util' instead of the
hardworking 'error'. In a spirit of equity, we break the cycle of injustice and
give back to 'error' the respect it deserves. And screw that 'util' poser.

For great justice.
2015-10-08 12:55:45 -07:00
Yuya Nishihara
897f0202e7 templatekw: remove dockeywords hack
Now all template keywords are defined as real functions.
2015-09-26 12:39:13 +09:00
Yuya Nishihara
727976289b help: hide deprecated filesets, revsets and template items if not verbose
This allows us to hide {branches} template keyword in a better way. Currently
it is achieved by copying keywords table and deleting 'branches' from it.
2015-09-26 12:17:44 +09:00
Yuya Nishihara
46fcad08f6 help: pass around ui to rewriter hooks (API)
makeitemsdoc() will hide DEPRECATED items conditionally.
2015-09-26 12:11:46 +09:00
Yuya Nishihara
2f746aa9d3 help: pass around ui to doc loader (API)
This is necessary to hide DEPRECATED items conditionally.

Flagged as API change because it will break "hg help git|subversion".
2015-09-26 12:06:30 +09:00
Yuya Nishihara
2843fbb322 help: unify handling of DEPRECATED/EXPERIMENTAL keywords
This fixes listexts() to exclude translated "(DEPRECATED)" marker correctly.

On the other hand, help_() doesn't need translated keywords, but I don't think
it's worth to separate untranslated keywords just for it.
2015-09-26 11:50:47 +09:00
Yuya Nishihara
dac7167e8f help: include parens in DEPRECATED/EXPERIMENTAL keywords
In some languages that have no caps, "DEPRECATED" and "deprecated" can be
translated to the same byte sequence. So it is too wild to exclude messages
by _("DEPRECATED").
2015-09-26 11:38:39 +09:00
Yuya Nishihara
4c633e1b68 help: define list of keywords that should be excluded from non-verbose output
This list will be reused by the other deprecated/experimental handling.
2015-09-26 11:25:38 +09:00
timeless@mozdev.org
a14fb0ee13 help: fix help argument parsing and documentation
support combining -c and -e

previously -k was misdocumented:
 * the first line didn't mention it
 * the help half implied you could do help -k keyword topic

with these changes, -k just changes the search method

support -c and -e for -k searches
2015-09-10 20:22:37 -04:00
timeless@mozdev.org
df6e67baf9 help: fix makeitemsdoc English description 2015-08-30 18:54:31 -04:00
Gregory Szorc
db719a7a87 help: scripting help topic
There are a lot of non-human consumers of Mercurial. And the challenges
and considerations for machines consuming Mercurial is significantly
different from what humans face.

I think there are enough special considerations around how machines
consume Mercurial that a dedicated help topic is warranted. I concede
the audience for this topic is probably small compared to the general
audience. However, lots of normal Mercurial users do things like create
one-off shell scripts for common workflows that I think this is useful
enough to be in the install (as opposed to, say, a wiki page - which
most users will likely never find).

This text is by no means perfect. But you have to start somewhere. I
think I did cover the important parts, though.
2015-07-18 17:10:28 -07:00
Gregory Szorc
5380dea2a7 global: mass rewrite to use modern exception syntax
Python 2.6 introduced the "except type as instance" syntax, replacing
the "except type, instance" syntax that came before. Python 3 dropped
support for the latter syntax. Since we no longer support Python 2.4 or
2.5, we have no need to continue supporting the "except type, instance".

This patch mass rewrites the exception syntax to be Python 2.6+ and
Python 3 compatible.

This patch was produced by running `2to3 -f except -w -n .`.
2015-06-23 22:20:08 -07:00
Siddharth Agarwal
222edc51db help: also hide options marked EXPERIMENTAL
Similar to DEPRECATED, add a way to indicate that options are EXPERIMENTAL.
2015-04-27 15:12:41 -07:00
Gregory Szorc
acb5f54ecc help: populate template functions via docstrings
We do this for revsets, template keywrods, and template filters. Now we
do it for template functions as well.
2015-04-01 20:23:58 -07:00
Gregory Szorc
bfb9e38893 help.merge-tools: do not double document merge tools
Merge tools were being double documented in help system output due
to functions being defined under multiple names in the merge tools
dictionary.

Establish a new dictionary for just the tools to document and
use it from the help system so we don't get double output.

Double documentation likely plagues other auto-documented items
as well. It might be a good idea to eventually compare function
instances to filter out duplicate entries from dictionaries
passed to ``makeitemsdoc``. However, without an easy way to break
ties, this may result in some functions being advertised over
their modern equivalents. This would be a noble patch series.
But it isn't one this author is willing to tackle at this time.
2015-02-09 23:07:39 -08:00
Gregory Szorc
2a9673b3df help: teach topic symbols how to dedent
When using docstrings for documenting symbols such as revsets,
templates, or hgweb commands, documentation likely has leading
whitespace corresponding to the indentation from the Python source
file.

Up until this point, the help system stripped all leading and
trailing whitespace and replaced it with 2 spaces of leading
whitespace. There were a few bad side-effects. First, sections
could not be used in docstrings because they would be indented
and the rst parser would fail to parse them as sections. Also,
any rst elements that required indentation would lose their
indentation, again causing them to be parsed and rendered
incorrectly.

In this patch, we teach the topic symbols system how to dedent
text properly. I argue this mode should be enabled by default.
However, I stopped short of changing that because it would cause
a lot of documentation reformatting to occur. I'm not sure if
people are relying on or wanting indentation. So, dedenting has
only been turned on for hgweb symbols. This decision should be
scrutinized.
2015-02-09 14:59:04 -08:00
Gregory Szorc
c26c3581a4 help: add web commands to help documentation
The capabilities and URL endpoints of the hgweb server can currently
only be inferred by looking at links in `hg serve` output or by reading
the source code. I've frequently found myself wanting to quickly see
what URLs and capabilities are available.

This patch teaches the help system how to display information about
web commands and their URLs. Using a mechanism similar to revsets,
templates, etc, we can now iterate over the docstrings of registered
web command functions and display them in the help output.

Unfortunately, web commands don't currently have docstrings, so the
output is currently empty. This will be addressed in the following
patches. I apologize for the patch bomb.
2015-02-06 20:27:56 -08:00
Chingis Dugarzhapov
3f0e231547 help: suggest '-v -e' to get built-in aliases for extensions (issue4461)
If extension name matches one of command names, suggest user to type
'hg help -v -e <extension>' to get full list of built-in aliases
2014-12-22 03:20:50 +01:00
Mads Kiilerich
634a855966 help: don't search randomly for help data - trust util.datapath
The search was introduced in 73b7669a499c without a convincing explanation why
it should be necessary ... except for consistency with templater handling.

Now, just keep it simple.
2014-09-28 16:57:47 +02:00
Mads Kiilerich
e9c0145df2 util: introduce datapath for getting the location of supporting data files
templates, help and locale data is normally stored as sub folders in the
directory containing the source of the mercurial module. In a frozen build they
live as sub folders next to 'hg.exe' and 'library.zip'.

These different kind of data were handled in different ways. Unify that by
introducing util.datapath. The value is computed from the environment and is
always used, so we just calculate the value on module load.
2014-09-28 16:57:06 +02:00
Augie Fackler
f41d193435 merge with stable 2014-09-04 09:59:23 -04:00