Commit Graph

179 Commits

Author SHA1 Message Date
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
Gregory Szorc
a57721695a help: only call doc() when it is callable
`hg help -k` on my machine was aborting because the hg-prompt extension
was inserting a string and not a function into help.helptable and help
was blindly calling it.

This patch changes keyword searching to be more robust against
unexpected types.
2014-08-30 20:06:24 +02:00
Yuya Nishihara
5ffa20b315 help: provide help of bad alias without executing aliascmd()
The output is slightly changed because of minirst formatting.  Previously,
ui.pushbuffer() had no effect because "badalias" message was written to stderr.

"if not unknowncmd" should no longer be needed because there's no call loop.
2014-08-13 19:38:47 +09:00
Yuya Nishihara
9f46c8b964 alias: keep error message in "badalias" so that help can see it
Upcoming patches will

 - change help_() to get badalias message without executing cmdalias()
 - raise Abort on bad alias
2014-05-17 21:13:31 +09:00
Matt Mackall
d2e240d48e help: normalize helplist hints 2014-08-12 04:11:32 -05:00
Matt Mackall
68762ac0d2 help: fold repeatable option message into option table header
This will hopefully conserve some limited user attention.
2014-08-12 04:00:42 -05:00
Matt Mackall
0ba980d3fa help: roll option list header into option formatter 2014-08-12 03:53:33 -05:00
Matt Mackall
ddad209d92 help: refactor helplist optlist mess
No output changes
2014-08-12 03:42:09 -05:00
Matt Mackall
fef3609a90 help: normalize topic and extension verbose hints 2014-08-12 03:25:51 -05:00
Matt Mackall
e6f86f6aa5 help: normalize hint about enabling extensions 2014-08-12 03:18:50 -05:00
Matt Mackall
c6e73a8a42 help: normalize extension shadow hint 2014-08-12 03:12:24 -05:00