Mercurial > hg
annotate mercurial/help.py @ 27369:c48ecc0b5bc9 stable
copyfile: add an optional parameter to copy other stat data
Contrary to the comment, I didn't see any evidence that we were copying
atime/mtime at all. This adds a parameter to copyfile to optionally copy it and
other stat data, with the default being to not copy it.
Many systems don't support changing the timestamp of a symlink, but we don't
need that in general anyway -- copystat is mostly useful for editors, most of
which will dereference symlinks anyway.
author | Siddharth Agarwal <sid0@fb.com> |
---|---|
date | Sat, 12 Dec 2015 11:00:04 -0800 |
parents | 56b2bcea2529 |
children | 7a77ee434179 |
rev | line source |
---|---|
3795
17a11f4ff260
Add basic support for help topics and a dates topic
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
1 # help.py - help data for mercurial |
17a11f4ff260
Add basic support for help topics and a dates topic
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
2 # |
17a11f4ff260
Add basic support for help topics and a dates topic
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
3 # Copyright 2006 Matt Mackall <mpm@selenic.com> |
17a11f4ff260
Add basic support for help topics and a dates topic
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
4 # |
8225
46293a0c7e9f
updated license to be explicit about GPL version 2
Martin Geisler <mg@lazybytes.net>
parents:
8159
diff
changeset
|
5 # This software may be used and distributed according to the terms of the |
10263 | 6 # GNU General Public License version 2 or any later version. |
3795
17a11f4ff260
Add basic support for help topics and a dates topic
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
7 |
9539
c904e76e3834
help: move help topics from mercurial/help.py to help/*.txt
Martin Geisler <mg@lazybytes.net>
parents:
9536
diff
changeset
|
8 from i18n import gettext, _ |
24098
067540702f64
help: teach topic symbols how to dedent
Gregory Szorc <gregory.szorc@gmail.com>
parents:
24080
diff
changeset
|
9 import itertools, os, textwrap |
20034
1e5b38a919dd
cleanup: move stdlib imports to their own import statement
Augie Fackler <raf@durin42.com>
parents:
19769
diff
changeset
|
10 import error |
16126
0c4bec9596d8
filemerge: create detail of internal merge tools from documentation string
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
15996
diff
changeset
|
11 import extensions, revset, fileset, templatekw, templatefilters, filemerge |
24587
76c0b4cfa039
help: populate template functions via docstrings
Gregory Szorc <gregory.szorc@gmail.com>
parents:
24099
diff
changeset
|
12 import templater |
16781
c0b98f436cce
help: move some helper functions to help.py
Olav Reinert <seroton10@gmail.com>
parents:
16711
diff
changeset
|
13 import encoding, util, minirst |
18746
c0087d48ec3a
help: move the majority of the help command to the help module
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
17837
diff
changeset
|
14 import cmdutil |
24080
a3f2ea1d4943
help: add web commands to help documentation
Gregory Szorc <gregory.szorc@gmail.com>
parents:
23624
diff
changeset
|
15 import hgweb.webcommands as webcommands |
8863
7b19c3c0172b
help: adding a new help topic about extensions
Cédric Duval <cedricduval@free.fr>
parents:
8668
diff
changeset
|
16 |
26369
4799b5c4aaf4
help: define list of keywords that should be excluded from non-verbose output
Yuya Nishihara <yuya@tcha.org>
parents:
26238
diff
changeset
|
17 _exclkeywords = [ |
26370
44cc9f63a2f1
help: include parens in DEPRECATED/EXPERIMENTAL keywords
Yuya Nishihara <yuya@tcha.org>
parents:
26369
diff
changeset
|
18 "(DEPRECATED)", |
44cc9f63a2f1
help: include parens in DEPRECATED/EXPERIMENTAL keywords
Yuya Nishihara <yuya@tcha.org>
parents:
26369
diff
changeset
|
19 "(EXPERIMENTAL)", |
44cc9f63a2f1
help: include parens in DEPRECATED/EXPERIMENTAL keywords
Yuya Nishihara <yuya@tcha.org>
parents:
26369
diff
changeset
|
20 # i18n: "(DEPRECATED)" is a keyword, must be translated consistently |
44cc9f63a2f1
help: include parens in DEPRECATED/EXPERIMENTAL keywords
Yuya Nishihara <yuya@tcha.org>
parents:
26369
diff
changeset
|
21 _("(DEPRECATED)"), |
44cc9f63a2f1
help: include parens in DEPRECATED/EXPERIMENTAL keywords
Yuya Nishihara <yuya@tcha.org>
parents:
26369
diff
changeset
|
22 # i18n: "(EXPERIMENTAL)" is a keyword, must be translated consistently |
44cc9f63a2f1
help: include parens in DEPRECATED/EXPERIMENTAL keywords
Yuya Nishihara <yuya@tcha.org>
parents:
26369
diff
changeset
|
23 _("(EXPERIMENTAL)"), |
26369
4799b5c4aaf4
help: define list of keywords that should be excluded from non-verbose output
Yuya Nishihara <yuya@tcha.org>
parents:
26238
diff
changeset
|
24 ] |
4799b5c4aaf4
help: define list of keywords that should be excluded from non-verbose output
Yuya Nishihara <yuya@tcha.org>
parents:
26238
diff
changeset
|
25 |
20582
02c303f64917
help: exclude deprecated extensions in the disabled part of 'help extensions'
Augie Fackler <raf@durin42.com>
parents:
20034
diff
changeset
|
26 def listexts(header, exts, indent=1, showdeprecated=False): |
8879
d0a3eadfbdb3
help: more improvements for the extensions topic
Cédric Duval <cedricduval@free.fr>
parents:
8871
diff
changeset
|
27 '''return a text listing of the given extensions''' |
16852
af69b2b64d6e
help: format extension lists using RST
Olav Reinert <seroton10@gmail.com>
parents:
16845
diff
changeset
|
28 rst = [] |
af69b2b64d6e
help: format extension lists using RST
Olav Reinert <seroton10@gmail.com>
parents:
16845
diff
changeset
|
29 if exts: |
af69b2b64d6e
help: format extension lists using RST
Olav Reinert <seroton10@gmail.com>
parents:
16845
diff
changeset
|
30 rst.append('\n%s\n\n' % header) |
af69b2b64d6e
help: format extension lists using RST
Olav Reinert <seroton10@gmail.com>
parents:
16845
diff
changeset
|
31 for name, desc in sorted(exts.iteritems()): |
26371
51b309ce6c7d
help: unify handling of DEPRECATED/EXPERIMENTAL keywords
Yuya Nishihara <yuya@tcha.org>
parents:
26370
diff
changeset
|
32 if not showdeprecated and any(w in desc for w in _exclkeywords): |
20582
02c303f64917
help: exclude deprecated extensions in the disabled part of 'help extensions'
Augie Fackler <raf@durin42.com>
parents:
20034
diff
changeset
|
33 continue |
16852
af69b2b64d6e
help: format extension lists using RST
Olav Reinert <seroton10@gmail.com>
parents:
16845
diff
changeset
|
34 rst.append('%s:%s: %s\n' % (' ' * indent, name, desc)) |
af69b2b64d6e
help: format extension lists using RST
Olav Reinert <seroton10@gmail.com>
parents:
16845
diff
changeset
|
35 return rst |
8864
cad6370a15cb
help: refactor extensions listing, and show enabled ones in the dedicated topic
Cédric Duval <cedricduval@free.fr>
parents:
8863
diff
changeset
|
36 |
26413
e0c572d4d112
help: pass around ui to doc loader (API)
Yuya Nishihara <yuya@tcha.org>
parents:
26371
diff
changeset
|
37 def extshelp(ui): |
e0c572d4d112
help: pass around ui to doc loader (API)
Yuya Nishihara <yuya@tcha.org>
parents:
26371
diff
changeset
|
38 rst = loaddoc('extensions')(ui).splitlines(True) |
20582
02c303f64917
help: exclude deprecated extensions in the disabled part of 'help extensions'
Augie Fackler <raf@durin42.com>
parents:
20034
diff
changeset
|
39 rst.extend(listexts( |
02c303f64917
help: exclude deprecated extensions in the disabled part of 'help extensions'
Augie Fackler <raf@durin42.com>
parents:
20034
diff
changeset
|
40 _('enabled extensions:'), extensions.enabled(), showdeprecated=True)) |
16852
af69b2b64d6e
help: format extension lists using RST
Olav Reinert <seroton10@gmail.com>
parents:
16845
diff
changeset
|
41 rst.extend(listexts(_('disabled extensions:'), extensions.disabled())) |
af69b2b64d6e
help: format extension lists using RST
Olav Reinert <seroton10@gmail.com>
parents:
16845
diff
changeset
|
42 doc = ''.join(rst) |
8863
7b19c3c0172b
help: adding a new help topic about extensions
Cédric Duval <cedricduval@free.fr>
parents:
8668
diff
changeset
|
43 return doc |
7013
f56e788fa292
i18n: mark help strings for translation
Martin Geisler <mg@daimi.au.dk>
parents:
7012
diff
changeset
|
44 |
22116
161085f87b95
help: roll option list header into option formatter
Matt Mackall <mpm@selenic.com>
parents:
22115
diff
changeset
|
45 def optrst(header, options, verbose): |
16781
c0b98f436cce
help: move some helper functions to help.py
Olav Reinert <seroton10@gmail.com>
parents:
16711
diff
changeset
|
46 data = [] |
c0b98f436cce
help: move some helper functions to help.py
Olav Reinert <seroton10@gmail.com>
parents:
16711
diff
changeset
|
47 multioccur = False |
c0b98f436cce
help: move some helper functions to help.py
Olav Reinert <seroton10@gmail.com>
parents:
16711
diff
changeset
|
48 for option in options: |
c0b98f436cce
help: move some helper functions to help.py
Olav Reinert <seroton10@gmail.com>
parents:
16711
diff
changeset
|
49 if len(option) == 5: |
c0b98f436cce
help: move some helper functions to help.py
Olav Reinert <seroton10@gmail.com>
parents:
16711
diff
changeset
|
50 shortopt, longopt, default, desc, optlabel = option |
c0b98f436cce
help: move some helper functions to help.py
Olav Reinert <seroton10@gmail.com>
parents:
16711
diff
changeset
|
51 else: |
c0b98f436cce
help: move some helper functions to help.py
Olav Reinert <seroton10@gmail.com>
parents:
16711
diff
changeset
|
52 shortopt, longopt, default, desc = option |
c0b98f436cce
help: move some helper functions to help.py
Olav Reinert <seroton10@gmail.com>
parents:
16711
diff
changeset
|
53 optlabel = _("VALUE") # default label |
c0b98f436cce
help: move some helper functions to help.py
Olav Reinert <seroton10@gmail.com>
parents:
16711
diff
changeset
|
54 |
26369
4799b5c4aaf4
help: define list of keywords that should be excluded from non-verbose output
Yuya Nishihara <yuya@tcha.org>
parents:
26238
diff
changeset
|
55 if not verbose and any(w in desc for w in _exclkeywords): |
16781
c0b98f436cce
help: move some helper functions to help.py
Olav Reinert <seroton10@gmail.com>
parents:
16711
diff
changeset
|
56 continue |
c0b98f436cce
help: move some helper functions to help.py
Olav Reinert <seroton10@gmail.com>
parents:
16711
diff
changeset
|
57 |
c0b98f436cce
help: move some helper functions to help.py
Olav Reinert <seroton10@gmail.com>
parents:
16711
diff
changeset
|
58 so = '' |
c0b98f436cce
help: move some helper functions to help.py
Olav Reinert <seroton10@gmail.com>
parents:
16711
diff
changeset
|
59 if shortopt: |
c0b98f436cce
help: move some helper functions to help.py
Olav Reinert <seroton10@gmail.com>
parents:
16711
diff
changeset
|
60 so = '-' + shortopt |
c0b98f436cce
help: move some helper functions to help.py
Olav Reinert <seroton10@gmail.com>
parents:
16711
diff
changeset
|
61 lo = '--' + longopt |
c0b98f436cce
help: move some helper functions to help.py
Olav Reinert <seroton10@gmail.com>
parents:
16711
diff
changeset
|
62 if default: |
c0b98f436cce
help: move some helper functions to help.py
Olav Reinert <seroton10@gmail.com>
parents:
16711
diff
changeset
|
63 desc += _(" (default: %s)") % default |
c0b98f436cce
help: move some helper functions to help.py
Olav Reinert <seroton10@gmail.com>
parents:
16711
diff
changeset
|
64 |
c0b98f436cce
help: move some helper functions to help.py
Olav Reinert <seroton10@gmail.com>
parents:
16711
diff
changeset
|
65 if isinstance(default, list): |
c0b98f436cce
help: move some helper functions to help.py
Olav Reinert <seroton10@gmail.com>
parents:
16711
diff
changeset
|
66 lo += " %s [+]" % optlabel |
c0b98f436cce
help: move some helper functions to help.py
Olav Reinert <seroton10@gmail.com>
parents:
16711
diff
changeset
|
67 multioccur = True |
c0b98f436cce
help: move some helper functions to help.py
Olav Reinert <seroton10@gmail.com>
parents:
16711
diff
changeset
|
68 elif (default is not None) and not isinstance(default, bool): |
c0b98f436cce
help: move some helper functions to help.py
Olav Reinert <seroton10@gmail.com>
parents:
16711
diff
changeset
|
69 lo += " %s" % optlabel |
c0b98f436cce
help: move some helper functions to help.py
Olav Reinert <seroton10@gmail.com>
parents:
16711
diff
changeset
|
70 |
c0b98f436cce
help: move some helper functions to help.py
Olav Reinert <seroton10@gmail.com>
parents:
16711
diff
changeset
|
71 data.append((so, lo, desc)) |
c0b98f436cce
help: move some helper functions to help.py
Olav Reinert <seroton10@gmail.com>
parents:
16711
diff
changeset
|
72 |
22117
c1d93edcf004
help: fold repeatable option message into option table header
Matt Mackall <mpm@selenic.com>
parents:
22116
diff
changeset
|
73 if multioccur: |
c1d93edcf004
help: fold repeatable option message into option table header
Matt Mackall <mpm@selenic.com>
parents:
22116
diff
changeset
|
74 header += (_(" ([+] can be repeated)")) |
16781
c0b98f436cce
help: move some helper functions to help.py
Olav Reinert <seroton10@gmail.com>
parents:
16711
diff
changeset
|
75 |
22116
161085f87b95
help: roll option list header into option formatter
Matt Mackall <mpm@selenic.com>
parents:
22115
diff
changeset
|
76 rst = ['\n%s:\n\n' % header] |
161085f87b95
help: roll option list header into option formatter
Matt Mackall <mpm@selenic.com>
parents:
22115
diff
changeset
|
77 rst.extend(minirst.maketable(data, 1)) |
16781
c0b98f436cce
help: move some helper functions to help.py
Olav Reinert <seroton10@gmail.com>
parents:
16711
diff
changeset
|
78 |
16815
e740746ea557
minirst: generate tables as a list of joined lines
Olav Reinert <seroton10@gmail.com>
parents:
16781
diff
changeset
|
79 return ''.join(rst) |
16781
c0b98f436cce
help: move some helper functions to help.py
Olav Reinert <seroton10@gmail.com>
parents:
16711
diff
changeset
|
80 |
17837
b623e323c561
help: indicate help omitting if help document is not fully displayed
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
17323
diff
changeset
|
81 def indicateomitted(rst, omitted, notomitted=None): |
b623e323c561
help: indicate help omitting if help document is not fully displayed
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
17323
diff
changeset
|
82 rst.append('\n\n.. container:: omitted\n\n %s\n\n' % omitted) |
b623e323c561
help: indicate help omitting if help document is not fully displayed
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
17323
diff
changeset
|
83 if notomitted: |
b623e323c561
help: indicate help omitting if help document is not fully displayed
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
17323
diff
changeset
|
84 rst.append('\n\n.. container:: notomitted\n\n %s\n\n' % notomitted) |
b623e323c561
help: indicate help omitting if help document is not fully displayed
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
17323
diff
changeset
|
85 |
26413
e0c572d4d112
help: pass around ui to doc loader (API)
Yuya Nishihara <yuya@tcha.org>
parents:
26371
diff
changeset
|
86 def topicmatch(ui, kw): |
16710
a17983680f12
help: introduce topicmatch for finding topics matching a keyword
Augie Fackler <raf@durin42.com>
parents:
16568
diff
changeset
|
87 """Return help topics matching kw. |
a17983680f12
help: introduce topicmatch for finding topics matching a keyword
Augie Fackler <raf@durin42.com>
parents:
16568
diff
changeset
|
88 |
a17983680f12
help: introduce topicmatch for finding topics matching a keyword
Augie Fackler <raf@durin42.com>
parents:
16568
diff
changeset
|
89 Returns {'section': [(name, summary), ...], ...} where section is |
a17983680f12
help: introduce topicmatch for finding topics matching a keyword
Augie Fackler <raf@durin42.com>
parents:
16568
diff
changeset
|
90 one of topics, commands, extensions, or extensioncommands. |
a17983680f12
help: introduce topicmatch for finding topics matching a keyword
Augie Fackler <raf@durin42.com>
parents:
16568
diff
changeset
|
91 """ |
a17983680f12
help: introduce topicmatch for finding topics matching a keyword
Augie Fackler <raf@durin42.com>
parents:
16568
diff
changeset
|
92 kw = encoding.lower(kw) |
a17983680f12
help: introduce topicmatch for finding topics matching a keyword
Augie Fackler <raf@durin42.com>
parents:
16568
diff
changeset
|
93 def lowercontains(container): |
16845
4594729c61ee
help: fix search with `-k` option in non-ASCII locales
Nikolaj Sjujskij <sterkrig@myopera.com>
parents:
16816
diff
changeset
|
94 return kw in encoding.lower(container) # translated in helptable |
16710
a17983680f12
help: introduce topicmatch for finding topics matching a keyword
Augie Fackler <raf@durin42.com>
parents:
16568
diff
changeset
|
95 results = {'topics': [], |
a17983680f12
help: introduce topicmatch for finding topics matching a keyword
Augie Fackler <raf@durin42.com>
parents:
16568
diff
changeset
|
96 'commands': [], |
a17983680f12
help: introduce topicmatch for finding topics matching a keyword
Augie Fackler <raf@durin42.com>
parents:
16568
diff
changeset
|
97 'extensions': [], |
a17983680f12
help: introduce topicmatch for finding topics matching a keyword
Augie Fackler <raf@durin42.com>
parents:
16568
diff
changeset
|
98 'extensioncommands': [], |
a17983680f12
help: introduce topicmatch for finding topics matching a keyword
Augie Fackler <raf@durin42.com>
parents:
16568
diff
changeset
|
99 } |
a17983680f12
help: introduce topicmatch for finding topics matching a keyword
Augie Fackler <raf@durin42.com>
parents:
16568
diff
changeset
|
100 for names, header, doc in helptable: |
22322
e284de138f00
help: only call doc() when it is callable
Gregory Szorc <gregory.szorc@gmail.com>
parents:
21796
diff
changeset
|
101 # Old extensions may use a str as doc. |
16710
a17983680f12
help: introduce topicmatch for finding topics matching a keyword
Augie Fackler <raf@durin42.com>
parents:
16568
diff
changeset
|
102 if (sum(map(lowercontains, names)) |
a17983680f12
help: introduce topicmatch for finding topics matching a keyword
Augie Fackler <raf@durin42.com>
parents:
16568
diff
changeset
|
103 or lowercontains(header) |
26413
e0c572d4d112
help: pass around ui to doc loader (API)
Yuya Nishihara <yuya@tcha.org>
parents:
26371
diff
changeset
|
104 or (callable(doc) and lowercontains(doc(ui)))): |
16710
a17983680f12
help: introduce topicmatch for finding topics matching a keyword
Augie Fackler <raf@durin42.com>
parents:
16568
diff
changeset
|
105 results['topics'].append((names[0], header)) |
a17983680f12
help: introduce topicmatch for finding topics matching a keyword
Augie Fackler <raf@durin42.com>
parents:
16568
diff
changeset
|
106 import commands # avoid cycle |
a17983680f12
help: introduce topicmatch for finding topics matching a keyword
Augie Fackler <raf@durin42.com>
parents:
16568
diff
changeset
|
107 for cmd, entry in commands.table.iteritems(): |
a17983680f12
help: introduce topicmatch for finding topics matching a keyword
Augie Fackler <raf@durin42.com>
parents:
16568
diff
changeset
|
108 if len(entry) == 3: |
a17983680f12
help: introduce topicmatch for finding topics matching a keyword
Augie Fackler <raf@durin42.com>
parents:
16568
diff
changeset
|
109 summary = entry[2] |
a17983680f12
help: introduce topicmatch for finding topics matching a keyword
Augie Fackler <raf@durin42.com>
parents:
16568
diff
changeset
|
110 else: |
a17983680f12
help: introduce topicmatch for finding topics matching a keyword
Augie Fackler <raf@durin42.com>
parents:
16568
diff
changeset
|
111 summary = '' |
16845
4594729c61ee
help: fix search with `-k` option in non-ASCII locales
Nikolaj Sjujskij <sterkrig@myopera.com>
parents:
16816
diff
changeset
|
112 # translate docs *before* searching there |
4594729c61ee
help: fix search with `-k` option in non-ASCII locales
Nikolaj Sjujskij <sterkrig@myopera.com>
parents:
16816
diff
changeset
|
113 docs = _(getattr(entry[0], '__doc__', None)) or '' |
16710
a17983680f12
help: introduce topicmatch for finding topics matching a keyword
Augie Fackler <raf@durin42.com>
parents:
16568
diff
changeset
|
114 if kw in cmd or lowercontains(summary) or lowercontains(docs): |
16845
4594729c61ee
help: fix search with `-k` option in non-ASCII locales
Nikolaj Sjujskij <sterkrig@myopera.com>
parents:
16816
diff
changeset
|
115 doclines = docs.splitlines() |
16710
a17983680f12
help: introduce topicmatch for finding topics matching a keyword
Augie Fackler <raf@durin42.com>
parents:
16568
diff
changeset
|
116 if doclines: |
a17983680f12
help: introduce topicmatch for finding topics matching a keyword
Augie Fackler <raf@durin42.com>
parents:
16568
diff
changeset
|
117 summary = doclines[0] |
a17983680f12
help: introduce topicmatch for finding topics matching a keyword
Augie Fackler <raf@durin42.com>
parents:
16568
diff
changeset
|
118 cmdname = cmd.split('|')[0].lstrip('^') |
a17983680f12
help: introduce topicmatch for finding topics matching a keyword
Augie Fackler <raf@durin42.com>
parents:
16568
diff
changeset
|
119 results['commands'].append((cmdname, summary)) |
a17983680f12
help: introduce topicmatch for finding topics matching a keyword
Augie Fackler <raf@durin42.com>
parents:
16568
diff
changeset
|
120 for name, docs in itertools.chain( |
19769
83d79a00cc24
help: use full name of extensions to look up them for keyword search
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
18748
diff
changeset
|
121 extensions.enabled(False).iteritems(), |
16710
a17983680f12
help: introduce topicmatch for finding topics matching a keyword
Augie Fackler <raf@durin42.com>
parents:
16568
diff
changeset
|
122 extensions.disabled().iteritems()): |
a17983680f12
help: introduce topicmatch for finding topics matching a keyword
Augie Fackler <raf@durin42.com>
parents:
16568
diff
changeset
|
123 # extensions.load ignores the UI argument |
a17983680f12
help: introduce topicmatch for finding topics matching a keyword
Augie Fackler <raf@durin42.com>
parents:
16568
diff
changeset
|
124 mod = extensions.load(None, name, '') |
19769
83d79a00cc24
help: use full name of extensions to look up them for keyword search
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
18748
diff
changeset
|
125 name = name.split('.')[-1] |
16710
a17983680f12
help: introduce topicmatch for finding topics matching a keyword
Augie Fackler <raf@durin42.com>
parents:
16568
diff
changeset
|
126 if lowercontains(name) or lowercontains(docs): |
16845
4594729c61ee
help: fix search with `-k` option in non-ASCII locales
Nikolaj Sjujskij <sterkrig@myopera.com>
parents:
16816
diff
changeset
|
127 # extension docs are already translated |
4594729c61ee
help: fix search with `-k` option in non-ASCII locales
Nikolaj Sjujskij <sterkrig@myopera.com>
parents:
16816
diff
changeset
|
128 results['extensions'].append((name, docs.splitlines()[0])) |
16710
a17983680f12
help: introduce topicmatch for finding topics matching a keyword
Augie Fackler <raf@durin42.com>
parents:
16568
diff
changeset
|
129 for cmd, entry in getattr(mod, 'cmdtable', {}).iteritems(): |
16711
497deec204d1
help: add --keyword (-k) for searching help
Augie Fackler <raf@durin42.com>
parents:
16710
diff
changeset
|
130 if kw in cmd or (len(entry) > 2 and lowercontains(entry[2])): |
16710
a17983680f12
help: introduce topicmatch for finding topics matching a keyword
Augie Fackler <raf@durin42.com>
parents:
16568
diff
changeset
|
131 cmdname = cmd.split('|')[0].lstrip('^') |
16942
87882c8753d4
help: fix extension commands help in keyword search
Olav Reinert <seroton10@gmail.com>
parents:
16884
diff
changeset
|
132 if entry[0].__doc__: |
87882c8753d4
help: fix extension commands help in keyword search
Olav Reinert <seroton10@gmail.com>
parents:
16884
diff
changeset
|
133 cmddoc = gettext(entry[0].__doc__).splitlines()[0] |
16884
4fd1f1d7569b
help: fix 'hg help -k' matching an extension without docs
Thomas Arendsen Hein <thomas@intevation.de>
parents:
16855
diff
changeset
|
134 else: |
4fd1f1d7569b
help: fix 'hg help -k' matching an extension without docs
Thomas Arendsen Hein <thomas@intevation.de>
parents:
16855
diff
changeset
|
135 cmddoc = _('(no help text available)') |
4fd1f1d7569b
help: fix 'hg help -k' matching an extension without docs
Thomas Arendsen Hein <thomas@intevation.de>
parents:
16855
diff
changeset
|
136 results['extensioncommands'].append((cmdname, cmddoc)) |
16710
a17983680f12
help: introduce topicmatch for finding topics matching a keyword
Augie Fackler <raf@durin42.com>
parents:
16568
diff
changeset
|
137 return results |
a17983680f12
help: introduce topicmatch for finding topics matching a keyword
Augie Fackler <raf@durin42.com>
parents:
16568
diff
changeset
|
138 |
9539
c904e76e3834
help: move help topics from mercurial/help.py to help/*.txt
Martin Geisler <mg@lazybytes.net>
parents:
9536
diff
changeset
|
139 def loaddoc(topic): |
c904e76e3834
help: move help topics from mercurial/help.py to help/*.txt
Martin Geisler <mg@lazybytes.net>
parents:
9536
diff
changeset
|
140 """Return a delayed loader for help/topic.txt.""" |
3798 | 141 |
26413
e0c572d4d112
help: pass around ui to doc loader (API)
Yuya Nishihara <yuya@tcha.org>
parents:
26371
diff
changeset
|
142 def loader(ui): |
22637
149141c3a25f
help: don't search randomly for help data - trust util.datapath
Mads Kiilerich <madski@unity3d.com>
parents:
22633
diff
changeset
|
143 docdir = os.path.join(util.datapath, 'help') |
9539
c904e76e3834
help: move help topics from mercurial/help.py to help/*.txt
Martin Geisler <mg@lazybytes.net>
parents:
9536
diff
changeset
|
144 path = os.path.join(docdir, topic + ".txt") |
14168
135e244776f0
prevent transient leaks of file handle by using new helper functions
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
14044
diff
changeset
|
145 doc = gettext(util.readfile(path)) |
12820
0edc0aa7432d
help: add topic rewriting hooks
Patrick Mezard <pmezard@gmail.com>
parents:
12818
diff
changeset
|
146 for rewriter in helphooks.get(topic, []): |
26414
c44b507e7c78
help: pass around ui to rewriter hooks (API)
Yuya Nishihara <yuya@tcha.org>
parents:
26413
diff
changeset
|
147 doc = rewriter(ui, topic, doc) |
12820
0edc0aa7432d
help: add topic rewriting hooks
Patrick Mezard <pmezard@gmail.com>
parents:
12818
diff
changeset
|
148 return doc |
0edc0aa7432d
help: add topic rewriting hooks
Patrick Mezard <pmezard@gmail.com>
parents:
12818
diff
changeset
|
149 |
9539
c904e76e3834
help: move help topics from mercurial/help.py to help/*.txt
Martin Geisler <mg@lazybytes.net>
parents:
9536
diff
changeset
|
150 return loader |
7677
6a0bc2dc9da6
help: add a topic about some of the templating features
Alexander Solovyov <piranha@piranha.org.ua>
parents:
7387
diff
changeset
|
151 |
13888
9e5407a67dea
help: sort help topics to make the output more readable (issue2751)
Yun Lee <yunlee.bj@gmail.com>
parents:
13593
diff
changeset
|
152 helptable = sorted([ |
12145
c407b4ca666e
help: make "hg help hgrc" an alias for "hg help config"
Martin Geisler <mg@lazybytes.net>
parents:
11657
diff
changeset
|
153 (["config", "hgrc"], _("Configuration Files"), loaddoc('config')), |
9539
c904e76e3834
help: move help topics from mercurial/help.py to help/*.txt
Martin Geisler <mg@lazybytes.net>
parents:
9536
diff
changeset
|
154 (["dates"], _("Date Formats"), loaddoc('dates')), |
c904e76e3834
help: move help topics from mercurial/help.py to help/*.txt
Martin Geisler <mg@lazybytes.net>
parents:
9536
diff
changeset
|
155 (["patterns"], _("File Name Patterns"), loaddoc('patterns')), |
10282
08a0f04b56bd
many, many trivial check-code fixups
Matt Mackall <mpm@selenic.com>
parents:
10263
diff
changeset
|
156 (['environment', 'env'], _('Environment Variables'), |
08a0f04b56bd
many, many trivial check-code fixups
Matt Mackall <mpm@selenic.com>
parents:
10263
diff
changeset
|
157 loaddoc('environment')), |
17322
7124f984dc8d
help: use the first topic name from helptable, not the longest alias
Mads Kiilerich <mads@kiilerich.com>
parents:
17321
diff
changeset
|
158 (['revisions', 'revs'], _('Specifying Single Revisions'), |
10282
08a0f04b56bd
many, many trivial check-code fixups
Matt Mackall <mpm@selenic.com>
parents:
10263
diff
changeset
|
159 loaddoc('revisions')), |
17322
7124f984dc8d
help: use the first topic name from helptable, not the longest alias
Mads Kiilerich <mads@kiilerich.com>
parents:
17321
diff
changeset
|
160 (['multirevs', 'mrevs'], _('Specifying Multiple Revisions'), |
10282
08a0f04b56bd
many, many trivial check-code fixups
Matt Mackall <mpm@selenic.com>
parents:
10263
diff
changeset
|
161 loaddoc('multirevs')), |
17322
7124f984dc8d
help: use the first topic name from helptable, not the longest alias
Mads Kiilerich <mads@kiilerich.com>
parents:
17321
diff
changeset
|
162 (['revsets', 'revset'], _("Specifying Revision Sets"), loaddoc('revsets')), |
7124f984dc8d
help: use the first topic name from helptable, not the longest alias
Mads Kiilerich <mads@kiilerich.com>
parents:
17321
diff
changeset
|
163 (['filesets', 'fileset'], _("Specifying File Sets"), loaddoc('filesets')), |
9539
c904e76e3834
help: move help topics from mercurial/help.py to help/*.txt
Martin Geisler <mg@lazybytes.net>
parents:
9536
diff
changeset
|
164 (['diffs'], _('Diff Formats'), loaddoc('diffs')), |
17323
2be2a070f294
help: add 'mergetools' alias for the 'merge-tools' help topic
Mads Kiilerich <mads@kiilerich.com>
parents:
17322
diff
changeset
|
165 (['merge-tools', 'mergetools'], _('Merge Tools'), loaddoc('merge-tools')), |
16568
770190bff625
help: add reference to template help (issue3413)
A. S. Budden <abudden@gmail.com>
parents:
16547
diff
changeset
|
166 (['templating', 'templates', 'template', 'style'], _('Template Usage'), |
10282
08a0f04b56bd
many, many trivial check-code fixups
Matt Mackall <mpm@selenic.com>
parents:
10263
diff
changeset
|
167 loaddoc('templates')), |
9539
c904e76e3834
help: move help topics from mercurial/help.py to help/*.txt
Martin Geisler <mg@lazybytes.net>
parents:
9536
diff
changeset
|
168 (['urls'], _('URL Paths'), loaddoc('urls')), |
16547
23072be2eaa3
help: consistently use title capitalization for help topics
Martin Geisler <mg@aragost.com>
parents:
16250
diff
changeset
|
169 (["extensions"], _("Using Additional Features"), extshelp), |
17322
7124f984dc8d
help: use the first topic name from helptable, not the longest alias
Mads Kiilerich <mads@kiilerich.com>
parents:
17321
diff
changeset
|
170 (["subrepos", "subrepo"], _("Subrepositories"), loaddoc('subrepos')), |
17321
f3fd9d6802b7
help: fix helptable indentation
Mads Kiilerich <mads@kiilerich.com>
parents:
17187
diff
changeset
|
171 (["hgweb"], _("Configuring hgweb"), loaddoc('hgweb')), |
f3fd9d6802b7
help: fix helptable indentation
Mads Kiilerich <mads@kiilerich.com>
parents:
17187
diff
changeset
|
172 (["glossary"], _("Glossary"), loaddoc('glossary')), |
f3fd9d6802b7
help: fix helptable indentation
Mads Kiilerich <mads@kiilerich.com>
parents:
17187
diff
changeset
|
173 (["hgignore", "ignore"], _("Syntax for Mercurial Ignore Files"), |
f3fd9d6802b7
help: fix helptable indentation
Mads Kiilerich <mads@kiilerich.com>
parents:
17187
diff
changeset
|
174 loaddoc('hgignore')), |
f3fd9d6802b7
help: fix helptable indentation
Mads Kiilerich <mads@kiilerich.com>
parents:
17187
diff
changeset
|
175 (["phases"], _("Working with Phases"), loaddoc('phases')), |
25881
9de443515f1d
help: scripting help topic
Gregory Szorc <gregory.szorc@gmail.com>
parents:
25660
diff
changeset
|
176 (['scripting'], _('Using Mercurial from scripts and automation'), |
9de443515f1d
help: scripting help topic
Gregory Szorc <gregory.szorc@gmail.com>
parents:
25660
diff
changeset
|
177 loaddoc('scripting')), |
13888
9e5407a67dea
help: sort help topics to make the output more readable (issue2751)
Yun Lee <yunlee.bj@gmail.com>
parents:
13593
diff
changeset
|
178 ]) |
12820
0edc0aa7432d
help: add topic rewriting hooks
Patrick Mezard <pmezard@gmail.com>
parents:
12818
diff
changeset
|
179 |
0edc0aa7432d
help: add topic rewriting hooks
Patrick Mezard <pmezard@gmail.com>
parents:
12818
diff
changeset
|
180 # Map topics to lists of callable taking the current topic help and |
0edc0aa7432d
help: add topic rewriting hooks
Patrick Mezard <pmezard@gmail.com>
parents:
12818
diff
changeset
|
181 # returning the updated version |
14318
1f46be4689ed
help: consolidate topic hooks in help.py
Matt Mackall <mpm@selenic.com>
parents:
14317
diff
changeset
|
182 helphooks = {} |
12820
0edc0aa7432d
help: add topic rewriting hooks
Patrick Mezard <pmezard@gmail.com>
parents:
12818
diff
changeset
|
183 |
0edc0aa7432d
help: add topic rewriting hooks
Patrick Mezard <pmezard@gmail.com>
parents:
12818
diff
changeset
|
184 def addtopichook(topic, rewriter): |
0edc0aa7432d
help: add topic rewriting hooks
Patrick Mezard <pmezard@gmail.com>
parents:
12818
diff
changeset
|
185 helphooks.setdefault(topic, []).append(rewriter) |
13593
cc4721ed7a2a
help: extract items doc generation function
Patrick Mezard <pmezard@gmail.com>
parents:
12828
diff
changeset
|
186 |
26414
c44b507e7c78
help: pass around ui to rewriter hooks (API)
Yuya Nishihara <yuya@tcha.org>
parents:
26413
diff
changeset
|
187 def makeitemsdoc(ui, topic, doc, marker, items, dedent=False): |
13593
cc4721ed7a2a
help: extract items doc generation function
Patrick Mezard <pmezard@gmail.com>
parents:
12828
diff
changeset
|
188 """Extract docstring from the items key to function mapping, build a |
26196
3a4620ad4490
help: fix makeitemsdoc English description
timeless@mozdev.org
parents:
25881
diff
changeset
|
189 single documentation block and use it to overwrite the marker in doc. |
13593
cc4721ed7a2a
help: extract items doc generation function
Patrick Mezard <pmezard@gmail.com>
parents:
12828
diff
changeset
|
190 """ |
cc4721ed7a2a
help: extract items doc generation function
Patrick Mezard <pmezard@gmail.com>
parents:
12828
diff
changeset
|
191 entries = [] |
cc4721ed7a2a
help: extract items doc generation function
Patrick Mezard <pmezard@gmail.com>
parents:
12828
diff
changeset
|
192 for name in sorted(items): |
cc4721ed7a2a
help: extract items doc generation function
Patrick Mezard <pmezard@gmail.com>
parents:
12828
diff
changeset
|
193 text = (items[name].__doc__ or '').rstrip() |
26415
46af0adb5c37
help: hide deprecated filesets, revsets and template items if not verbose
Yuya Nishihara <yuya@tcha.org>
parents:
26414
diff
changeset
|
194 if (not text |
46af0adb5c37
help: hide deprecated filesets, revsets and template items if not verbose
Yuya Nishihara <yuya@tcha.org>
parents:
26414
diff
changeset
|
195 or not ui.verbose and any(w in text for w in _exclkeywords)): |
13593
cc4721ed7a2a
help: extract items doc generation function
Patrick Mezard <pmezard@gmail.com>
parents:
12828
diff
changeset
|
196 continue |
cc4721ed7a2a
help: extract items doc generation function
Patrick Mezard <pmezard@gmail.com>
parents:
12828
diff
changeset
|
197 text = gettext(text) |
24098
067540702f64
help: teach topic symbols how to dedent
Gregory Szorc <gregory.szorc@gmail.com>
parents:
24080
diff
changeset
|
198 if dedent: |
067540702f64
help: teach topic symbols how to dedent
Gregory Szorc <gregory.szorc@gmail.com>
parents:
24080
diff
changeset
|
199 text = textwrap.dedent(text) |
13593
cc4721ed7a2a
help: extract items doc generation function
Patrick Mezard <pmezard@gmail.com>
parents:
12828
diff
changeset
|
200 lines = text.splitlines() |
16250
684864d54903
help: strip doctest from dochelp
"Yann E. MORIN" <yann.morin.1998@free.fr>
parents:
16126
diff
changeset
|
201 doclines = [(lines[0])] |
684864d54903
help: strip doctest from dochelp
"Yann E. MORIN" <yann.morin.1998@free.fr>
parents:
16126
diff
changeset
|
202 for l in lines[1:]: |
684864d54903
help: strip doctest from dochelp
"Yann E. MORIN" <yann.morin.1998@free.fr>
parents:
16126
diff
changeset
|
203 # Stop once we find some Python doctest |
684864d54903
help: strip doctest from dochelp
"Yann E. MORIN" <yann.morin.1998@free.fr>
parents:
16126
diff
changeset
|
204 if l.strip().startswith('>>>'): |
684864d54903
help: strip doctest from dochelp
"Yann E. MORIN" <yann.morin.1998@free.fr>
parents:
16126
diff
changeset
|
205 break |
24098
067540702f64
help: teach topic symbols how to dedent
Gregory Szorc <gregory.szorc@gmail.com>
parents:
24080
diff
changeset
|
206 if dedent: |
067540702f64
help: teach topic symbols how to dedent
Gregory Szorc <gregory.szorc@gmail.com>
parents:
24080
diff
changeset
|
207 doclines.append(l.rstrip()) |
067540702f64
help: teach topic symbols how to dedent
Gregory Szorc <gregory.szorc@gmail.com>
parents:
24080
diff
changeset
|
208 else: |
067540702f64
help: teach topic symbols how to dedent
Gregory Szorc <gregory.szorc@gmail.com>
parents:
24080
diff
changeset
|
209 doclines.append(' ' + l.strip()) |
16250
684864d54903
help: strip doctest from dochelp
"Yann E. MORIN" <yann.morin.1998@free.fr>
parents:
16126
diff
changeset
|
210 entries.append('\n'.join(doclines)) |
13593
cc4721ed7a2a
help: extract items doc generation function
Patrick Mezard <pmezard@gmail.com>
parents:
12828
diff
changeset
|
211 entries = '\n\n'.join(entries) |
cc4721ed7a2a
help: extract items doc generation function
Patrick Mezard <pmezard@gmail.com>
parents:
12828
diff
changeset
|
212 return doc.replace(marker, entries) |
14318
1f46be4689ed
help: consolidate topic hooks in help.py
Matt Mackall <mpm@selenic.com>
parents:
14317
diff
changeset
|
213 |
24098
067540702f64
help: teach topic symbols how to dedent
Gregory Szorc <gregory.szorc@gmail.com>
parents:
24080
diff
changeset
|
214 def addtopicsymbols(topic, marker, symbols, dedent=False): |
26414
c44b507e7c78
help: pass around ui to rewriter hooks (API)
Yuya Nishihara <yuya@tcha.org>
parents:
26413
diff
changeset
|
215 def add(ui, topic, doc): |
c44b507e7c78
help: pass around ui to rewriter hooks (API)
Yuya Nishihara <yuya@tcha.org>
parents:
26413
diff
changeset
|
216 return makeitemsdoc(ui, topic, doc, marker, symbols, dedent=dedent) |
14318
1f46be4689ed
help: consolidate topic hooks in help.py
Matt Mackall <mpm@selenic.com>
parents:
14317
diff
changeset
|
217 addtopichook(topic, add) |
1f46be4689ed
help: consolidate topic hooks in help.py
Matt Mackall <mpm@selenic.com>
parents:
14317
diff
changeset
|
218 |
14686 | 219 addtopicsymbols('filesets', '.. predicatesmarker', fileset.symbols) |
24099
be83fd9d46d5
help.merge-tools: do not double document merge tools
Gregory Szorc <gregory.szorc@gmail.com>
parents:
24098
diff
changeset
|
220 addtopicsymbols('merge-tools', '.. internaltoolsmarker', |
be83fd9d46d5
help.merge-tools: do not double document merge tools
Gregory Szorc <gregory.szorc@gmail.com>
parents:
24098
diff
changeset
|
221 filemerge.internalsdoc) |
14318
1f46be4689ed
help: consolidate topic hooks in help.py
Matt Mackall <mpm@selenic.com>
parents:
14317
diff
changeset
|
222 addtopicsymbols('revsets', '.. predicatesmarker', revset.symbols) |
26436
a2291c9c85a1
templatekw: remove dockeywords hack
Yuya Nishihara <yuya@tcha.org>
parents:
26415
diff
changeset
|
223 addtopicsymbols('templates', '.. keywordsmarker', templatekw.keywords) |
14318
1f46be4689ed
help: consolidate topic hooks in help.py
Matt Mackall <mpm@selenic.com>
parents:
14317
diff
changeset
|
224 addtopicsymbols('templates', '.. filtersmarker', templatefilters.filters) |
24587
76c0b4cfa039
help: populate template functions via docstrings
Gregory Szorc <gregory.szorc@gmail.com>
parents:
24099
diff
changeset
|
225 addtopicsymbols('templates', '.. functionsmarker', templater.funcs) |
24098
067540702f64
help: teach topic symbols how to dedent
Gregory Szorc <gregory.szorc@gmail.com>
parents:
24080
diff
changeset
|
226 addtopicsymbols('hgweb', '.. webcommandsmarker', webcommands.commands, |
067540702f64
help: teach topic symbols how to dedent
Gregory Szorc <gregory.szorc@gmail.com>
parents:
24080
diff
changeset
|
227 dedent=True) |
18746
c0087d48ec3a
help: move the majority of the help command to the help module
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
17837
diff
changeset
|
228 |
c0087d48ec3a
help: move the majority of the help command to the help module
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
17837
diff
changeset
|
229 def help_(ui, name, unknowncmd=False, full=True, **opts): |
c0087d48ec3a
help: move the majority of the help command to the help module
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
17837
diff
changeset
|
230 ''' |
c0087d48ec3a
help: move the majority of the help command to the help module
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
17837
diff
changeset
|
231 Generate the help for 'name' as unformatted restructured text. If |
c0087d48ec3a
help: move the majority of the help command to the help module
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
17837
diff
changeset
|
232 'name' is None, describe the commands available. |
c0087d48ec3a
help: move the majority of the help command to the help module
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
17837
diff
changeset
|
233 ''' |
c0087d48ec3a
help: move the majority of the help command to the help module
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
17837
diff
changeset
|
234 |
c0087d48ec3a
help: move the majority of the help command to the help module
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
17837
diff
changeset
|
235 import commands # avoid cycle |
c0087d48ec3a
help: move the majority of the help command to the help module
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
17837
diff
changeset
|
236 |
c0087d48ec3a
help: move the majority of the help command to the help module
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
17837
diff
changeset
|
237 def helpcmd(name): |
c0087d48ec3a
help: move the majority of the help command to the help module
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
17837
diff
changeset
|
238 try: |
c0087d48ec3a
help: move the majority of the help command to the help module
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
17837
diff
changeset
|
239 aliases, entry = cmdutil.findcmd(name, commands.table, |
c0087d48ec3a
help: move the majority of the help command to the help module
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
17837
diff
changeset
|
240 strict=unknowncmd) |
25660
328739ea70c3
global: mass rewrite to use modern exception syntax
Gregory Szorc <gregory.szorc@gmail.com>
parents:
24871
diff
changeset
|
241 except error.AmbiguousCommand as inst: |
18746
c0087d48ec3a
help: move the majority of the help command to the help module
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
17837
diff
changeset
|
242 # py3k fix: except vars can't be used outside the scope of the |
c0087d48ec3a
help: move the majority of the help command to the help module
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
17837
diff
changeset
|
243 # except block, nor can be used inside a lambda. python issue4617 |
c0087d48ec3a
help: move the majority of the help command to the help module
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
17837
diff
changeset
|
244 prefix = inst.args[0] |
c0087d48ec3a
help: move the majority of the help command to the help module
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
17837
diff
changeset
|
245 select = lambda c: c.lstrip('^').startswith(prefix) |
c0087d48ec3a
help: move the majority of the help command to the help module
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
17837
diff
changeset
|
246 rst = helplist(select) |
c0087d48ec3a
help: move the majority of the help command to the help module
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
17837
diff
changeset
|
247 return rst |
c0087d48ec3a
help: move the majority of the help command to the help module
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
17837
diff
changeset
|
248 |
c0087d48ec3a
help: move the majority of the help command to the help module
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
17837
diff
changeset
|
249 rst = [] |
c0087d48ec3a
help: move the majority of the help command to the help module
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
17837
diff
changeset
|
250 |
c0087d48ec3a
help: move the majority of the help command to the help module
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
17837
diff
changeset
|
251 # check if it's an invalid alias and display its error if it is |
22160
645457f73aa6
alias: keep error message in "badalias" so that help can see it
Yuya Nishihara <yuya@tcha.org>
parents:
22118
diff
changeset
|
252 if getattr(entry[0], 'badalias', None): |
22162
7ada34676db8
help: provide help of bad alias without executing aliascmd()
Yuya Nishihara <yuya@tcha.org>
parents:
22160
diff
changeset
|
253 rst.append(entry[0].badalias + '\n') |
7ada34676db8
help: provide help of bad alias without executing aliascmd()
Yuya Nishihara <yuya@tcha.org>
parents:
22160
diff
changeset
|
254 if entry[0].unknowncmd: |
7ada34676db8
help: provide help of bad alias without executing aliascmd()
Yuya Nishihara <yuya@tcha.org>
parents:
22160
diff
changeset
|
255 try: |
7ada34676db8
help: provide help of bad alias without executing aliascmd()
Yuya Nishihara <yuya@tcha.org>
parents:
22160
diff
changeset
|
256 rst.extend(helpextcmd(entry[0].cmdname)) |
7ada34676db8
help: provide help of bad alias without executing aliascmd()
Yuya Nishihara <yuya@tcha.org>
parents:
22160
diff
changeset
|
257 except error.UnknownCommand: |
7ada34676db8
help: provide help of bad alias without executing aliascmd()
Yuya Nishihara <yuya@tcha.org>
parents:
22160
diff
changeset
|
258 pass |
18746
c0087d48ec3a
help: move the majority of the help command to the help module
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
17837
diff
changeset
|
259 return rst |
c0087d48ec3a
help: move the majority of the help command to the help module
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
17837
diff
changeset
|
260 |
c0087d48ec3a
help: move the majority of the help command to the help module
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
17837
diff
changeset
|
261 # synopsis |
c0087d48ec3a
help: move the majority of the help command to the help module
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
17837
diff
changeset
|
262 if len(entry) > 2: |
c0087d48ec3a
help: move the majority of the help command to the help module
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
17837
diff
changeset
|
263 if entry[2].startswith('hg'): |
c0087d48ec3a
help: move the majority of the help command to the help module
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
17837
diff
changeset
|
264 rst.append("%s\n" % entry[2]) |
c0087d48ec3a
help: move the majority of the help command to the help module
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
17837
diff
changeset
|
265 else: |
c0087d48ec3a
help: move the majority of the help command to the help module
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
17837
diff
changeset
|
266 rst.append('hg %s %s\n' % (aliases[0], entry[2])) |
c0087d48ec3a
help: move the majority of the help command to the help module
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
17837
diff
changeset
|
267 else: |
c0087d48ec3a
help: move the majority of the help command to the help module
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
17837
diff
changeset
|
268 rst.append('hg %s\n' % aliases[0]) |
c0087d48ec3a
help: move the majority of the help command to the help module
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
17837
diff
changeset
|
269 # aliases |
c0087d48ec3a
help: move the majority of the help command to the help module
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
17837
diff
changeset
|
270 if full and not ui.quiet and len(aliases) > 1: |
c0087d48ec3a
help: move the majority of the help command to the help module
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
17837
diff
changeset
|
271 rst.append(_("\naliases: %s\n") % ', '.join(aliases[1:])) |
c0087d48ec3a
help: move the majority of the help command to the help module
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
17837
diff
changeset
|
272 rst.append('\n') |
c0087d48ec3a
help: move the majority of the help command to the help module
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
17837
diff
changeset
|
273 |
c0087d48ec3a
help: move the majority of the help command to the help module
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
17837
diff
changeset
|
274 # description |
c0087d48ec3a
help: move the majority of the help command to the help module
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
17837
diff
changeset
|
275 doc = gettext(entry[0].__doc__) |
c0087d48ec3a
help: move the majority of the help command to the help module
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
17837
diff
changeset
|
276 if not doc: |
c0087d48ec3a
help: move the majority of the help command to the help module
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
17837
diff
changeset
|
277 doc = _("(no help text available)") |
c0087d48ec3a
help: move the majority of the help command to the help module
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
17837
diff
changeset
|
278 if util.safehasattr(entry[0], 'definition'): # aliased command |
c0087d48ec3a
help: move the majority of the help command to the help module
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
17837
diff
changeset
|
279 if entry[0].definition.startswith('!'): # shell alias |
c0087d48ec3a
help: move the majority of the help command to the help module
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
17837
diff
changeset
|
280 doc = _('shell alias for::\n\n %s') % entry[0].definition[1:] |
c0087d48ec3a
help: move the majority of the help command to the help module
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
17837
diff
changeset
|
281 else: |
c0087d48ec3a
help: move the majority of the help command to the help module
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
17837
diff
changeset
|
282 doc = _('alias for: hg %s\n\n%s') % (entry[0].definition, doc) |
c0087d48ec3a
help: move the majority of the help command to the help module
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
17837
diff
changeset
|
283 doc = doc.splitlines(True) |
c0087d48ec3a
help: move the majority of the help command to the help module
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
17837
diff
changeset
|
284 if ui.quiet or not full: |
c0087d48ec3a
help: move the majority of the help command to the help module
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
17837
diff
changeset
|
285 rst.append(doc[0]) |
c0087d48ec3a
help: move the majority of the help command to the help module
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
17837
diff
changeset
|
286 else: |
c0087d48ec3a
help: move the majority of the help command to the help module
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
17837
diff
changeset
|
287 rst.extend(doc) |
c0087d48ec3a
help: move the majority of the help command to the help module
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
17837
diff
changeset
|
288 rst.append('\n') |
c0087d48ec3a
help: move the majority of the help command to the help module
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
17837
diff
changeset
|
289 |
c0087d48ec3a
help: move the majority of the help command to the help module
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
17837
diff
changeset
|
290 # check if this command shadows a non-trivial (multi-line) |
c0087d48ec3a
help: move the majority of the help command to the help module
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
17837
diff
changeset
|
291 # extension help text |
c0087d48ec3a
help: move the majority of the help command to the help module
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
17837
diff
changeset
|
292 try: |
c0087d48ec3a
help: move the majority of the help command to the help module
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
17837
diff
changeset
|
293 mod = extensions.find(name) |
c0087d48ec3a
help: move the majority of the help command to the help module
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
17837
diff
changeset
|
294 doc = gettext(mod.__doc__) or '' |
c0087d48ec3a
help: move the majority of the help command to the help module
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
17837
diff
changeset
|
295 if '\n' in doc.strip(): |
22112
d968f4741a22
help: normalize extension shadow hint
Matt Mackall <mpm@selenic.com>
parents:
22111
diff
changeset
|
296 msg = _('(use "hg help -e %s" to show help for ' |
d968f4741a22
help: normalize extension shadow hint
Matt Mackall <mpm@selenic.com>
parents:
22111
diff
changeset
|
297 'the %s extension)') % (name, name) |
18746
c0087d48ec3a
help: move the majority of the help command to the help module
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
17837
diff
changeset
|
298 rst.append('\n%s\n' % msg) |
c0087d48ec3a
help: move the majority of the help command to the help module
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
17837
diff
changeset
|
299 except KeyError: |
c0087d48ec3a
help: move the majority of the help command to the help module
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
17837
diff
changeset
|
300 pass |
c0087d48ec3a
help: move the majority of the help command to the help module
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
17837
diff
changeset
|
301 |
c0087d48ec3a
help: move the majority of the help command to the help module
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
17837
diff
changeset
|
302 # options |
c0087d48ec3a
help: move the majority of the help command to the help module
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
17837
diff
changeset
|
303 if not ui.quiet and entry[1]: |
22116
161085f87b95
help: roll option list header into option formatter
Matt Mackall <mpm@selenic.com>
parents:
22115
diff
changeset
|
304 rst.append(optrst(_("options"), entry[1], ui.verbose)) |
18746
c0087d48ec3a
help: move the majority of the help command to the help module
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
17837
diff
changeset
|
305 |
c0087d48ec3a
help: move the majority of the help command to the help module
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
17837
diff
changeset
|
306 if ui.verbose: |
22116
161085f87b95
help: roll option list header into option formatter
Matt Mackall <mpm@selenic.com>
parents:
22115
diff
changeset
|
307 rst.append(optrst(_("global options"), |
161085f87b95
help: roll option list header into option formatter
Matt Mackall <mpm@selenic.com>
parents:
22115
diff
changeset
|
308 commands.globalopts, ui.verbose)) |
18746
c0087d48ec3a
help: move the majority of the help command to the help module
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
17837
diff
changeset
|
309 |
c0087d48ec3a
help: move the majority of the help command to the help module
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
17837
diff
changeset
|
310 if not ui.verbose: |
c0087d48ec3a
help: move the majority of the help command to the help module
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
17837
diff
changeset
|
311 if not full: |
22111
aa5e256839d5
help: improve command summary hint
Matt Mackall <mpm@selenic.com>
parents:
22110
diff
changeset
|
312 rst.append(_('\n(use "hg %s -h" to show more help)\n') |
18746
c0087d48ec3a
help: move the majority of the help command to the help module
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
17837
diff
changeset
|
313 % name) |
c0087d48ec3a
help: move the majority of the help command to the help module
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
17837
diff
changeset
|
314 elif not ui.quiet: |
22110
26f7c8033bed
help: tweak --verbose command help hint
Matt Mackall <mpm@selenic.com>
parents:
21796
diff
changeset
|
315 rst.append(_('\n(some details hidden, use --verbose ' |
26f7c8033bed
help: tweak --verbose command help hint
Matt Mackall <mpm@selenic.com>
parents:
21796
diff
changeset
|
316 'to show complete help)')) |
18746
c0087d48ec3a
help: move the majority of the help command to the help module
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
17837
diff
changeset
|
317 |
c0087d48ec3a
help: move the majority of the help command to the help module
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
17837
diff
changeset
|
318 return rst |
c0087d48ec3a
help: move the majority of the help command to the help module
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
17837
diff
changeset
|
319 |
c0087d48ec3a
help: move the majority of the help command to the help module
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
17837
diff
changeset
|
320 |
c0087d48ec3a
help: move the majority of the help command to the help module
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
17837
diff
changeset
|
321 def helplist(select=None): |
c0087d48ec3a
help: move the majority of the help command to the help module
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
17837
diff
changeset
|
322 # list of commands |
c0087d48ec3a
help: move the majority of the help command to the help module
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
17837
diff
changeset
|
323 if name == "shortlist": |
c0087d48ec3a
help: move the majority of the help command to the help module
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
17837
diff
changeset
|
324 header = _('basic commands:\n\n') |
20822
be87397f98c9
help: let 'hg help debug' show the list of secret debug commands
Mads Kiilerich <madski@unity3d.com>
parents:
20743
diff
changeset
|
325 elif name == "debug": |
be87397f98c9
help: let 'hg help debug' show the list of secret debug commands
Mads Kiilerich <madski@unity3d.com>
parents:
20743
diff
changeset
|
326 header = _('debug commands (internal and unsupported):\n\n') |
18746
c0087d48ec3a
help: move the majority of the help command to the help module
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
17837
diff
changeset
|
327 else: |
c0087d48ec3a
help: move the majority of the help command to the help module
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
17837
diff
changeset
|
328 header = _('list of commands:\n\n') |
c0087d48ec3a
help: move the majority of the help command to the help module
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
17837
diff
changeset
|
329 |
c0087d48ec3a
help: move the majority of the help command to the help module
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
17837
diff
changeset
|
330 h = {} |
c0087d48ec3a
help: move the majority of the help command to the help module
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
17837
diff
changeset
|
331 cmds = {} |
c0087d48ec3a
help: move the majority of the help command to the help module
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
17837
diff
changeset
|
332 for c, e in commands.table.iteritems(): |
c0087d48ec3a
help: move the majority of the help command to the help module
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
17837
diff
changeset
|
333 f = c.split("|", 1)[0] |
c0087d48ec3a
help: move the majority of the help command to the help module
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
17837
diff
changeset
|
334 if select and not select(f): |
c0087d48ec3a
help: move the majority of the help command to the help module
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
17837
diff
changeset
|
335 continue |
c0087d48ec3a
help: move the majority of the help command to the help module
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
17837
diff
changeset
|
336 if (not select and name != 'shortlist' and |
c0087d48ec3a
help: move the majority of the help command to the help module
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
17837
diff
changeset
|
337 e[0].__module__ != commands.__name__): |
c0087d48ec3a
help: move the majority of the help command to the help module
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
17837
diff
changeset
|
338 continue |
c0087d48ec3a
help: move the majority of the help command to the help module
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
17837
diff
changeset
|
339 if name == "shortlist" and not f.startswith("^"): |
c0087d48ec3a
help: move the majority of the help command to the help module
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
17837
diff
changeset
|
340 continue |
c0087d48ec3a
help: move the majority of the help command to the help module
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
17837
diff
changeset
|
341 f = f.lstrip("^") |
20822
be87397f98c9
help: let 'hg help debug' show the list of secret debug commands
Mads Kiilerich <madski@unity3d.com>
parents:
20743
diff
changeset
|
342 if not ui.debugflag and f.startswith("debug") and name != "debug": |
18746
c0087d48ec3a
help: move the majority of the help command to the help module
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
17837
diff
changeset
|
343 continue |
c0087d48ec3a
help: move the majority of the help command to the help module
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
17837
diff
changeset
|
344 doc = e[0].__doc__ |
26371
51b309ce6c7d
help: unify handling of DEPRECATED/EXPERIMENTAL keywords
Yuya Nishihara <yuya@tcha.org>
parents:
26370
diff
changeset
|
345 if not ui.verbose and doc and any(w in doc for w in _exclkeywords): |
18746
c0087d48ec3a
help: move the majority of the help command to the help module
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
17837
diff
changeset
|
346 continue |
c0087d48ec3a
help: move the majority of the help command to the help module
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
17837
diff
changeset
|
347 doc = gettext(doc) |
c0087d48ec3a
help: move the majority of the help command to the help module
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
17837
diff
changeset
|
348 if not doc: |
c0087d48ec3a
help: move the majority of the help command to the help module
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
17837
diff
changeset
|
349 doc = _("(no help text available)") |
c0087d48ec3a
help: move the majority of the help command to the help module
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
17837
diff
changeset
|
350 h[f] = doc.splitlines()[0].rstrip() |
c0087d48ec3a
help: move the majority of the help command to the help module
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
17837
diff
changeset
|
351 cmds[f] = c.lstrip("^") |
c0087d48ec3a
help: move the majority of the help command to the help module
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
17837
diff
changeset
|
352 |
c0087d48ec3a
help: move the majority of the help command to the help module
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
17837
diff
changeset
|
353 rst = [] |
c0087d48ec3a
help: move the majority of the help command to the help module
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
17837
diff
changeset
|
354 if not h: |
c0087d48ec3a
help: move the majority of the help command to the help module
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
17837
diff
changeset
|
355 if not ui.quiet: |
c0087d48ec3a
help: move the majority of the help command to the help module
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
17837
diff
changeset
|
356 rst.append(_('no commands defined\n')) |
c0087d48ec3a
help: move the majority of the help command to the help module
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
17837
diff
changeset
|
357 return rst |
c0087d48ec3a
help: move the majority of the help command to the help module
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
17837
diff
changeset
|
358 |
c0087d48ec3a
help: move the majority of the help command to the help module
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
17837
diff
changeset
|
359 if not ui.quiet: |
c0087d48ec3a
help: move the majority of the help command to the help module
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
17837
diff
changeset
|
360 rst.append(header) |
c0087d48ec3a
help: move the majority of the help command to the help module
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
17837
diff
changeset
|
361 fns = sorted(h) |
c0087d48ec3a
help: move the majority of the help command to the help module
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
17837
diff
changeset
|
362 for f in fns: |
c0087d48ec3a
help: move the majority of the help command to the help module
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
17837
diff
changeset
|
363 if ui.verbose: |
c0087d48ec3a
help: move the majority of the help command to the help module
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
17837
diff
changeset
|
364 commacmds = cmds[f].replace("|",", ") |
c0087d48ec3a
help: move the majority of the help command to the help module
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
17837
diff
changeset
|
365 rst.append(" :%s: %s\n" % (commacmds, h[f])) |
c0087d48ec3a
help: move the majority of the help command to the help module
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
17837
diff
changeset
|
366 else: |
c0087d48ec3a
help: move the majority of the help command to the help module
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
17837
diff
changeset
|
367 rst.append(' :%s: %s\n' % (f, h[f])) |
c0087d48ec3a
help: move the majority of the help command to the help module
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
17837
diff
changeset
|
368 |
c0087d48ec3a
help: move the majority of the help command to the help module
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
17837
diff
changeset
|
369 if not name: |
c0087d48ec3a
help: move the majority of the help command to the help module
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
17837
diff
changeset
|
370 exts = listexts(_('enabled extensions:'), extensions.enabled()) |
c0087d48ec3a
help: move the majority of the help command to the help module
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
17837
diff
changeset
|
371 if exts: |
c0087d48ec3a
help: move the majority of the help command to the help module
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
17837
diff
changeset
|
372 rst.append('\n') |
c0087d48ec3a
help: move the majority of the help command to the help module
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
17837
diff
changeset
|
373 rst.extend(exts) |
c0087d48ec3a
help: move the majority of the help command to the help module
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
17837
diff
changeset
|
374 |
c0087d48ec3a
help: move the majority of the help command to the help module
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
17837
diff
changeset
|
375 rst.append(_("\nadditional help topics:\n\n")) |
c0087d48ec3a
help: move the majority of the help command to the help module
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
17837
diff
changeset
|
376 topics = [] |
c0087d48ec3a
help: move the majority of the help command to the help module
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
17837
diff
changeset
|
377 for names, header, doc in helptable: |
c0087d48ec3a
help: move the majority of the help command to the help module
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
17837
diff
changeset
|
378 topics.append((names[0], header)) |
c0087d48ec3a
help: move the majority of the help command to the help module
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
17837
diff
changeset
|
379 for t, desc in topics: |
c0087d48ec3a
help: move the majority of the help command to the help module
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
17837
diff
changeset
|
380 rst.append(" :%s: %s\n" % (t, desc)) |
c0087d48ec3a
help: move the majority of the help command to the help module
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
17837
diff
changeset
|
381 |
22115
8465625f7364
help: refactor helplist optlist mess
Matt Mackall <mpm@selenic.com>
parents:
22114
diff
changeset
|
382 if ui.quiet: |
8465625f7364
help: refactor helplist optlist mess
Matt Mackall <mpm@selenic.com>
parents:
22114
diff
changeset
|
383 pass |
8465625f7364
help: refactor helplist optlist mess
Matt Mackall <mpm@selenic.com>
parents:
22114
diff
changeset
|
384 elif ui.verbose: |
22116
161085f87b95
help: roll option list header into option formatter
Matt Mackall <mpm@selenic.com>
parents:
22115
diff
changeset
|
385 rst.append('\n%s\n' % optrst(_("global options"), |
161085f87b95
help: roll option list header into option formatter
Matt Mackall <mpm@selenic.com>
parents:
22115
diff
changeset
|
386 commands.globalopts, ui.verbose)) |
22115
8465625f7364
help: refactor helplist optlist mess
Matt Mackall <mpm@selenic.com>
parents:
22114
diff
changeset
|
387 if name == 'shortlist': |
22118
9a299c39de01
help: normalize helplist hints
Matt Mackall <mpm@selenic.com>
parents:
22117
diff
changeset
|
388 rst.append(_('\n(use "hg help" for the full list ' |
9a299c39de01
help: normalize helplist hints
Matt Mackall <mpm@selenic.com>
parents:
22117
diff
changeset
|
389 'of commands)\n')) |
22115
8465625f7364
help: refactor helplist optlist mess
Matt Mackall <mpm@selenic.com>
parents:
22114
diff
changeset
|
390 else: |
8465625f7364
help: refactor helplist optlist mess
Matt Mackall <mpm@selenic.com>
parents:
22114
diff
changeset
|
391 if name == 'shortlist': |
22118
9a299c39de01
help: normalize helplist hints
Matt Mackall <mpm@selenic.com>
parents:
22117
diff
changeset
|
392 rst.append(_('\n(use "hg help" for the full list of commands ' |
9a299c39de01
help: normalize helplist hints
Matt Mackall <mpm@selenic.com>
parents:
22117
diff
changeset
|
393 'or "hg -v" for details)\n')) |
22115
8465625f7364
help: refactor helplist optlist mess
Matt Mackall <mpm@selenic.com>
parents:
22114
diff
changeset
|
394 elif name and not full: |
22118
9a299c39de01
help: normalize helplist hints
Matt Mackall <mpm@selenic.com>
parents:
22117
diff
changeset
|
395 rst.append(_('\n(use "hg help %s" to show the full help ' |
9a299c39de01
help: normalize helplist hints
Matt Mackall <mpm@selenic.com>
parents:
22117
diff
changeset
|
396 'text)\n') % name) |
23624
861ddedfb402
help: suggest '-v -e' to get built-in aliases for extensions (issue4461)
Chingis Dugarzhapov <chingis.dug@gmail.com>
parents:
22637
diff
changeset
|
397 elif name and cmds and name in cmds.keys(): |
861ddedfb402
help: suggest '-v -e' to get built-in aliases for extensions (issue4461)
Chingis Dugarzhapov <chingis.dug@gmail.com>
parents:
22637
diff
changeset
|
398 rst.append(_('\n(use "hg help -v -e %s" to show built-in ' |
861ddedfb402
help: suggest '-v -e' to get built-in aliases for extensions (issue4461)
Chingis Dugarzhapov <chingis.dug@gmail.com>
parents:
22637
diff
changeset
|
399 'aliases and global options)\n') % name) |
18746
c0087d48ec3a
help: move the majority of the help command to the help module
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
17837
diff
changeset
|
400 else: |
22118
9a299c39de01
help: normalize helplist hints
Matt Mackall <mpm@selenic.com>
parents:
22117
diff
changeset
|
401 rst.append(_('\n(use "hg help -v%s" to show built-in aliases ' |
9a299c39de01
help: normalize helplist hints
Matt Mackall <mpm@selenic.com>
parents:
22117
diff
changeset
|
402 'and global options)\n') |
9a299c39de01
help: normalize helplist hints
Matt Mackall <mpm@selenic.com>
parents:
22117
diff
changeset
|
403 % (name and " " + name or "")) |
18746
c0087d48ec3a
help: move the majority of the help command to the help module
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
17837
diff
changeset
|
404 return rst |
c0087d48ec3a
help: move the majority of the help command to the help module
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
17837
diff
changeset
|
405 |
c0087d48ec3a
help: move the majority of the help command to the help module
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
17837
diff
changeset
|
406 def helptopic(name): |
c0087d48ec3a
help: move the majority of the help command to the help module
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
17837
diff
changeset
|
407 for names, header, doc in helptable: |
c0087d48ec3a
help: move the majority of the help command to the help module
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
17837
diff
changeset
|
408 if name in names: |
c0087d48ec3a
help: move the majority of the help command to the help module
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
17837
diff
changeset
|
409 break |
c0087d48ec3a
help: move the majority of the help command to the help module
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
17837
diff
changeset
|
410 else: |
c0087d48ec3a
help: move the majority of the help command to the help module
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
17837
diff
changeset
|
411 raise error.UnknownCommand(name) |
c0087d48ec3a
help: move the majority of the help command to the help module
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
17837
diff
changeset
|
412 |
18748
6e676fb6ea44
help: use a full header for topic titles
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
18746
diff
changeset
|
413 rst = [minirst.section(header)] |
6e676fb6ea44
help: use a full header for topic titles
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
18746
diff
changeset
|
414 |
18746
c0087d48ec3a
help: move the majority of the help command to the help module
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
17837
diff
changeset
|
415 # description |
c0087d48ec3a
help: move the majority of the help command to the help module
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
17837
diff
changeset
|
416 if not doc: |
c0087d48ec3a
help: move the majority of the help command to the help module
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
17837
diff
changeset
|
417 rst.append(" %s\n" % _("(no help text available)")) |
21796
8225bb1f0ad3
help: restore use of callable() since it was readded in Python 3.2
Augie Fackler <raf@durin42.com>
parents:
21289
diff
changeset
|
418 if callable(doc): |
26413
e0c572d4d112
help: pass around ui to doc loader (API)
Yuya Nishihara <yuya@tcha.org>
parents:
26371
diff
changeset
|
419 rst += [" %s\n" % l for l in doc(ui).splitlines()] |
18746
c0087d48ec3a
help: move the majority of the help command to the help module
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
17837
diff
changeset
|
420 |
c0087d48ec3a
help: move the majority of the help command to the help module
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
17837
diff
changeset
|
421 if not ui.verbose: |
22114
3ba1d7ca3dfd
help: normalize topic and extension verbose hints
Matt Mackall <mpm@selenic.com>
parents:
22113
diff
changeset
|
422 omitted = _('(some details hidden, use --verbose' |
3ba1d7ca3dfd
help: normalize topic and extension verbose hints
Matt Mackall <mpm@selenic.com>
parents:
22113
diff
changeset
|
423 ' to show complete help)') |
18746
c0087d48ec3a
help: move the majority of the help command to the help module
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
17837
diff
changeset
|
424 indicateomitted(rst, omitted) |
c0087d48ec3a
help: move the majority of the help command to the help module
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
17837
diff
changeset
|
425 |
c0087d48ec3a
help: move the majority of the help command to the help module
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
17837
diff
changeset
|
426 try: |
c0087d48ec3a
help: move the majority of the help command to the help module
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
17837
diff
changeset
|
427 cmdutil.findcmd(name, commands.table) |
c0087d48ec3a
help: move the majority of the help command to the help module
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
17837
diff
changeset
|
428 rst.append(_('\nuse "hg help -c %s" to see help for ' |
c0087d48ec3a
help: move the majority of the help command to the help module
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
17837
diff
changeset
|
429 'the %s command\n') % (name, name)) |
c0087d48ec3a
help: move the majority of the help command to the help module
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
17837
diff
changeset
|
430 except error.UnknownCommand: |
c0087d48ec3a
help: move the majority of the help command to the help module
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
17837
diff
changeset
|
431 pass |
c0087d48ec3a
help: move the majority of the help command to the help module
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
17837
diff
changeset
|
432 return rst |
c0087d48ec3a
help: move the majority of the help command to the help module
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
17837
diff
changeset
|
433 |
c0087d48ec3a
help: move the majority of the help command to the help module
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
17837
diff
changeset
|
434 def helpext(name): |
c0087d48ec3a
help: move the majority of the help command to the help module
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
17837
diff
changeset
|
435 try: |
c0087d48ec3a
help: move the majority of the help command to the help module
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
17837
diff
changeset
|
436 mod = extensions.find(name) |
c0087d48ec3a
help: move the majority of the help command to the help module
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
17837
diff
changeset
|
437 doc = gettext(mod.__doc__) or _('no help text available') |
c0087d48ec3a
help: move the majority of the help command to the help module
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
17837
diff
changeset
|
438 except KeyError: |
c0087d48ec3a
help: move the majority of the help command to the help module
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
17837
diff
changeset
|
439 mod = None |
c0087d48ec3a
help: move the majority of the help command to the help module
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
17837
diff
changeset
|
440 doc = extensions.disabledext(name) |
c0087d48ec3a
help: move the majority of the help command to the help module
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
17837
diff
changeset
|
441 if not doc: |
c0087d48ec3a
help: move the majority of the help command to the help module
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
17837
diff
changeset
|
442 raise error.UnknownCommand(name) |
c0087d48ec3a
help: move the majority of the help command to the help module
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
17837
diff
changeset
|
443 |
c0087d48ec3a
help: move the majority of the help command to the help module
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
17837
diff
changeset
|
444 if '\n' not in doc: |
c0087d48ec3a
help: move the majority of the help command to the help module
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
17837
diff
changeset
|
445 head, tail = doc, "" |
c0087d48ec3a
help: move the majority of the help command to the help module
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
17837
diff
changeset
|
446 else: |
c0087d48ec3a
help: move the majority of the help command to the help module
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
17837
diff
changeset
|
447 head, tail = doc.split('\n', 1) |
c0087d48ec3a
help: move the majority of the help command to the help module
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
17837
diff
changeset
|
448 rst = [_('%s extension - %s\n\n') % (name.split('.')[-1], head)] |
c0087d48ec3a
help: move the majority of the help command to the help module
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
17837
diff
changeset
|
449 if tail: |
c0087d48ec3a
help: move the majority of the help command to the help module
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
17837
diff
changeset
|
450 rst.extend(tail.splitlines(True)) |
c0087d48ec3a
help: move the majority of the help command to the help module
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
17837
diff
changeset
|
451 rst.append('\n') |
c0087d48ec3a
help: move the majority of the help command to the help module
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
17837
diff
changeset
|
452 |
c0087d48ec3a
help: move the majority of the help command to the help module
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
17837
diff
changeset
|
453 if not ui.verbose: |
22114
3ba1d7ca3dfd
help: normalize topic and extension verbose hints
Matt Mackall <mpm@selenic.com>
parents:
22113
diff
changeset
|
454 omitted = _('(some details hidden, use --verbose' |
3ba1d7ca3dfd
help: normalize topic and extension verbose hints
Matt Mackall <mpm@selenic.com>
parents:
22113
diff
changeset
|
455 ' to show complete help)') |
18746
c0087d48ec3a
help: move the majority of the help command to the help module
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
17837
diff
changeset
|
456 indicateomitted(rst, omitted) |
c0087d48ec3a
help: move the majority of the help command to the help module
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
17837
diff
changeset
|
457 |
c0087d48ec3a
help: move the majority of the help command to the help module
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
17837
diff
changeset
|
458 if mod: |
c0087d48ec3a
help: move the majority of the help command to the help module
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
17837
diff
changeset
|
459 try: |
c0087d48ec3a
help: move the majority of the help command to the help module
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
17837
diff
changeset
|
460 ct = mod.cmdtable |
c0087d48ec3a
help: move the majority of the help command to the help module
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
17837
diff
changeset
|
461 except AttributeError: |
c0087d48ec3a
help: move the majority of the help command to the help module
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
17837
diff
changeset
|
462 ct = {} |
c0087d48ec3a
help: move the majority of the help command to the help module
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
17837
diff
changeset
|
463 modcmds = set([c.split('|', 1)[0] for c in ct]) |
c0087d48ec3a
help: move the majority of the help command to the help module
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
17837
diff
changeset
|
464 rst.extend(helplist(modcmds.__contains__)) |
c0087d48ec3a
help: move the majority of the help command to the help module
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
17837
diff
changeset
|
465 else: |
22113
2d2cb5e50095
help: normalize hint about enabling extensions
Matt Mackall <mpm@selenic.com>
parents:
22112
diff
changeset
|
466 rst.append(_('(use "hg help extensions" for information on enabling' |
2d2cb5e50095
help: normalize hint about enabling extensions
Matt Mackall <mpm@selenic.com>
parents:
22112
diff
changeset
|
467 ' extensions)\n')) |
18746
c0087d48ec3a
help: move the majority of the help command to the help module
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
17837
diff
changeset
|
468 return rst |
c0087d48ec3a
help: move the majority of the help command to the help module
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
17837
diff
changeset
|
469 |
c0087d48ec3a
help: move the majority of the help command to the help module
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
17837
diff
changeset
|
470 def helpextcmd(name): |
c0087d48ec3a
help: move the majority of the help command to the help module
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
17837
diff
changeset
|
471 cmd, ext, mod = extensions.disabledcmd(ui, name, |
c0087d48ec3a
help: move the majority of the help command to the help module
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
17837
diff
changeset
|
472 ui.configbool('ui', 'strict')) |
c0087d48ec3a
help: move the majority of the help command to the help module
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
17837
diff
changeset
|
473 doc = gettext(mod.__doc__).splitlines()[0] |
c0087d48ec3a
help: move the majority of the help command to the help module
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
17837
diff
changeset
|
474 |
c0087d48ec3a
help: move the majority of the help command to the help module
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
17837
diff
changeset
|
475 rst = listexts(_("'%s' is provided by the following " |
c0087d48ec3a
help: move the majority of the help command to the help module
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
17837
diff
changeset
|
476 "extension:") % cmd, {ext: doc}, indent=4) |
c0087d48ec3a
help: move the majority of the help command to the help module
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
17837
diff
changeset
|
477 rst.append('\n') |
22113
2d2cb5e50095
help: normalize hint about enabling extensions
Matt Mackall <mpm@selenic.com>
parents:
22112
diff
changeset
|
478 rst.append(_('(use "hg help extensions" for information on enabling ' |
2d2cb5e50095
help: normalize hint about enabling extensions
Matt Mackall <mpm@selenic.com>
parents:
22112
diff
changeset
|
479 'extensions)\n')) |
18746
c0087d48ec3a
help: move the majority of the help command to the help module
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
17837
diff
changeset
|
480 return rst |
c0087d48ec3a
help: move the majority of the help command to the help module
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
17837
diff
changeset
|
481 |
c0087d48ec3a
help: move the majority of the help command to the help module
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
17837
diff
changeset
|
482 |
c0087d48ec3a
help: move the majority of the help command to the help module
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
17837
diff
changeset
|
483 rst = [] |
c0087d48ec3a
help: move the majority of the help command to the help module
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
17837
diff
changeset
|
484 kw = opts.get('keyword') |
c0087d48ec3a
help: move the majority of the help command to the help module
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
17837
diff
changeset
|
485 if kw: |
26413
e0c572d4d112
help: pass around ui to doc loader (API)
Yuya Nishihara <yuya@tcha.org>
parents:
26371
diff
changeset
|
486 matches = topicmatch(ui, name) |
26238
69da16b366ad
help: fix help argument parsing and documentation
timeless@mozdev.org
parents:
26196
diff
changeset
|
487 helpareas = [] |
69da16b366ad
help: fix help argument parsing and documentation
timeless@mozdev.org
parents:
26196
diff
changeset
|
488 if opts.get('extension'): |
69da16b366ad
help: fix help argument parsing and documentation
timeless@mozdev.org
parents:
26196
diff
changeset
|
489 helpareas += [('extensions', _('Extensions'))] |
69da16b366ad
help: fix help argument parsing and documentation
timeless@mozdev.org
parents:
26196
diff
changeset
|
490 if opts.get('command'): |
69da16b366ad
help: fix help argument parsing and documentation
timeless@mozdev.org
parents:
26196
diff
changeset
|
491 helpareas += [('commands', _('Commands'))] |
69da16b366ad
help: fix help argument parsing and documentation
timeless@mozdev.org
parents:
26196
diff
changeset
|
492 if not helpareas: |
69da16b366ad
help: fix help argument parsing and documentation
timeless@mozdev.org
parents:
26196
diff
changeset
|
493 helpareas = [('topics', _('Topics')), |
18746
c0087d48ec3a
help: move the majority of the help command to the help module
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
17837
diff
changeset
|
494 ('commands', _('Commands')), |
c0087d48ec3a
help: move the majority of the help command to the help module
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
17837
diff
changeset
|
495 ('extensions', _('Extensions')), |
26238
69da16b366ad
help: fix help argument parsing and documentation
timeless@mozdev.org
parents:
26196
diff
changeset
|
496 ('extensioncommands', _('Extension Commands'))] |
69da16b366ad
help: fix help argument parsing and documentation
timeless@mozdev.org
parents:
26196
diff
changeset
|
497 for t, title in helpareas: |
18746
c0087d48ec3a
help: move the majority of the help command to the help module
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
17837
diff
changeset
|
498 if matches[t]: |
c0087d48ec3a
help: move the majority of the help command to the help module
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
17837
diff
changeset
|
499 rst.append('%s:\n\n' % title) |
c0087d48ec3a
help: move the majority of the help command to the help module
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
17837
diff
changeset
|
500 rst.extend(minirst.maketable(sorted(matches[t]), 1)) |
c0087d48ec3a
help: move the majority of the help command to the help module
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
17837
diff
changeset
|
501 rst.append('\n') |
21288
eb6eaef7ae44
help: provide a more helpful message when no keyword are matched
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
20823
diff
changeset
|
502 if not rst: |
eb6eaef7ae44
help: provide a more helpful message when no keyword are matched
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
20823
diff
changeset
|
503 msg = _('no matches') |
eb6eaef7ae44
help: provide a more helpful message when no keyword are matched
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
20823
diff
changeset
|
504 hint = _('try "hg help" for a list of topics') |
26587
56b2bcea2529
error: get Abort from 'error' instead of 'util'
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
26436
diff
changeset
|
505 raise error.Abort(msg, hint=hint) |
18746
c0087d48ec3a
help: move the majority of the help command to the help module
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
17837
diff
changeset
|
506 elif name and name != 'shortlist': |
26238
69da16b366ad
help: fix help argument parsing and documentation
timeless@mozdev.org
parents:
26196
diff
changeset
|
507 queries = [] |
18746
c0087d48ec3a
help: move the majority of the help command to the help module
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
17837
diff
changeset
|
508 if unknowncmd: |
26238
69da16b366ad
help: fix help argument parsing and documentation
timeless@mozdev.org
parents:
26196
diff
changeset
|
509 queries += [helpextcmd] |
69da16b366ad
help: fix help argument parsing and documentation
timeless@mozdev.org
parents:
26196
diff
changeset
|
510 if opts.get('extension'): |
69da16b366ad
help: fix help argument parsing and documentation
timeless@mozdev.org
parents:
26196
diff
changeset
|
511 queries += [helpext] |
69da16b366ad
help: fix help argument parsing and documentation
timeless@mozdev.org
parents:
26196
diff
changeset
|
512 if opts.get('command'): |
69da16b366ad
help: fix help argument parsing and documentation
timeless@mozdev.org
parents:
26196
diff
changeset
|
513 queries += [helpcmd] |
69da16b366ad
help: fix help argument parsing and documentation
timeless@mozdev.org
parents:
26196
diff
changeset
|
514 if not queries: |
18746
c0087d48ec3a
help: move the majority of the help command to the help module
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
17837
diff
changeset
|
515 queries = (helptopic, helpcmd, helpext, helpextcmd) |
c0087d48ec3a
help: move the majority of the help command to the help module
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
17837
diff
changeset
|
516 for f in queries: |
c0087d48ec3a
help: move the majority of the help command to the help module
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
17837
diff
changeset
|
517 try: |
c0087d48ec3a
help: move the majority of the help command to the help module
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
17837
diff
changeset
|
518 rst = f(name) |
c0087d48ec3a
help: move the majority of the help command to the help module
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
17837
diff
changeset
|
519 break |
21289
c3784e3c3e8d
help: suggest keyword search when no topic is found
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
21288
diff
changeset
|
520 except error.UnknownCommand: |
c3784e3c3e8d
help: suggest keyword search when no topic is found
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
21288
diff
changeset
|
521 pass |
c3784e3c3e8d
help: suggest keyword search when no topic is found
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
21288
diff
changeset
|
522 else: |
c3784e3c3e8d
help: suggest keyword search when no topic is found
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
21288
diff
changeset
|
523 if unknowncmd: |
c3784e3c3e8d
help: suggest keyword search when no topic is found
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
21288
diff
changeset
|
524 raise error.UnknownCommand(name) |
c3784e3c3e8d
help: suggest keyword search when no topic is found
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
21288
diff
changeset
|
525 else: |
c3784e3c3e8d
help: suggest keyword search when no topic is found
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
21288
diff
changeset
|
526 msg = _('no such help topic: %s') % name |
c3784e3c3e8d
help: suggest keyword search when no topic is found
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
21288
diff
changeset
|
527 hint = _('try "hg help --keyword %s"') % name |
26587
56b2bcea2529
error: get Abort from 'error' instead of 'util'
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
26436
diff
changeset
|
528 raise error.Abort(msg, hint=hint) |
18746
c0087d48ec3a
help: move the majority of the help command to the help module
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
17837
diff
changeset
|
529 else: |
c0087d48ec3a
help: move the majority of the help command to the help module
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
17837
diff
changeset
|
530 # program name |
c0087d48ec3a
help: move the majority of the help command to the help module
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
17837
diff
changeset
|
531 if not ui.quiet: |
c0087d48ec3a
help: move the majority of the help command to the help module
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
17837
diff
changeset
|
532 rst = [_("Mercurial Distributed SCM\n"), '\n'] |
c0087d48ec3a
help: move the majority of the help command to the help module
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
17837
diff
changeset
|
533 rst.extend(helplist()) |
c0087d48ec3a
help: move the majority of the help command to the help module
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
17837
diff
changeset
|
534 |
c0087d48ec3a
help: move the majority of the help command to the help module
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
17837
diff
changeset
|
535 return ''.join(rst) |