Show More
@@ -1,580 +1,599 b'' | |||
|
1 | 1 | # help.py - help data for mercurial |
|
2 | 2 | # |
|
3 | 3 | # Copyright 2006 Matt Mackall <mpm@selenic.com> |
|
4 | 4 | # |
|
5 | 5 | # This software may be used and distributed according to the terms of the |
|
6 | 6 | # GNU General Public License version 2 or any later version. |
|
7 | 7 | |
|
8 | from i18n import gettext, _ | |
|
9 | import itertools, os, textwrap | |
|
10 |
import |
|
|
11 | import extensions, revset, fileset, templatekw, templatefilters, filemerge | |
|
12 |
import te |
|
|
13 | import encoding, util, minirst | |
|
14 | import cmdutil | |
|
15 | import hgweb.webcommands as webcommands | |
|
8 | from __future__ import absolute_import | |
|
9 | ||
|
10 | import itertools | |
|
11 | import os | |
|
12 | import textwrap | |
|
13 | ||
|
14 | from .i18n import ( | |
|
15 | _, | |
|
16 | gettext, | |
|
17 | ) | |
|
18 | from . import ( | |
|
19 | cmdutil, | |
|
20 | encoding, | |
|
21 | error, | |
|
22 | extensions, | |
|
23 | filemerge, | |
|
24 | fileset, | |
|
25 | minirst, | |
|
26 | revset, | |
|
27 | templatefilters, | |
|
28 | templatekw, | |
|
29 | templater, | |
|
30 | util, | |
|
31 | ) | |
|
32 | from .hgweb import ( | |
|
33 | webcommands, | |
|
34 | ) | |
|
16 | 35 | |
|
17 | 36 | _exclkeywords = [ |
|
18 | 37 | "(DEPRECATED)", |
|
19 | 38 | "(EXPERIMENTAL)", |
|
20 | 39 | # i18n: "(DEPRECATED)" is a keyword, must be translated consistently |
|
21 | 40 | _("(DEPRECATED)"), |
|
22 | 41 | # i18n: "(EXPERIMENTAL)" is a keyword, must be translated consistently |
|
23 | 42 | _("(EXPERIMENTAL)"), |
|
24 | 43 | ] |
|
25 | 44 | |
|
26 | 45 | def listexts(header, exts, indent=1, showdeprecated=False): |
|
27 | 46 | '''return a text listing of the given extensions''' |
|
28 | 47 | rst = [] |
|
29 | 48 | if exts: |
|
30 | 49 | for name, desc in sorted(exts.iteritems()): |
|
31 | 50 | if not showdeprecated and any(w in desc for w in _exclkeywords): |
|
32 | 51 | continue |
|
33 | 52 | rst.append('%s:%s: %s\n' % (' ' * indent, name, desc)) |
|
34 | 53 | if rst: |
|
35 | 54 | rst.insert(0, '\n%s\n\n' % header) |
|
36 | 55 | return rst |
|
37 | 56 | |
|
38 | 57 | def extshelp(ui): |
|
39 | 58 | rst = loaddoc('extensions')(ui).splitlines(True) |
|
40 | 59 | rst.extend(listexts( |
|
41 | 60 | _('enabled extensions:'), extensions.enabled(), showdeprecated=True)) |
|
42 | 61 | rst.extend(listexts(_('disabled extensions:'), extensions.disabled())) |
|
43 | 62 | doc = ''.join(rst) |
|
44 | 63 | return doc |
|
45 | 64 | |
|
46 | 65 | def optrst(header, options, verbose): |
|
47 | 66 | data = [] |
|
48 | 67 | multioccur = False |
|
49 | 68 | for option in options: |
|
50 | 69 | if len(option) == 5: |
|
51 | 70 | shortopt, longopt, default, desc, optlabel = option |
|
52 | 71 | else: |
|
53 | 72 | shortopt, longopt, default, desc = option |
|
54 | 73 | optlabel = _("VALUE") # default label |
|
55 | 74 | |
|
56 | 75 | if not verbose and any(w in desc for w in _exclkeywords): |
|
57 | 76 | continue |
|
58 | 77 | |
|
59 | 78 | so = '' |
|
60 | 79 | if shortopt: |
|
61 | 80 | so = '-' + shortopt |
|
62 | 81 | lo = '--' + longopt |
|
63 | 82 | if default: |
|
64 | 83 | desc += _(" (default: %s)") % default |
|
65 | 84 | |
|
66 | 85 | if isinstance(default, list): |
|
67 | 86 | lo += " %s [+]" % optlabel |
|
68 | 87 | multioccur = True |
|
69 | 88 | elif (default is not None) and not isinstance(default, bool): |
|
70 | 89 | lo += " %s" % optlabel |
|
71 | 90 | |
|
72 | 91 | data.append((so, lo, desc)) |
|
73 | 92 | |
|
74 | 93 | if multioccur: |
|
75 | 94 | header += (_(" ([+] can be repeated)")) |
|
76 | 95 | |
|
77 | 96 | rst = ['\n%s:\n\n' % header] |
|
78 | 97 | rst.extend(minirst.maketable(data, 1)) |
|
79 | 98 | |
|
80 | 99 | return ''.join(rst) |
|
81 | 100 | |
|
82 | 101 | def indicateomitted(rst, omitted, notomitted=None): |
|
83 | 102 | rst.append('\n\n.. container:: omitted\n\n %s\n\n' % omitted) |
|
84 | 103 | if notomitted: |
|
85 | 104 | rst.append('\n\n.. container:: notomitted\n\n %s\n\n' % notomitted) |
|
86 | 105 | |
|
87 | 106 | def filtercmd(ui, cmd, kw, doc): |
|
88 | 107 | if not ui.debugflag and cmd.startswith("debug") and kw != "debug": |
|
89 | 108 | return True |
|
90 | 109 | if not ui.verbose and doc and any(w in doc for w in _exclkeywords): |
|
91 | 110 | return True |
|
92 | 111 | return False |
|
93 | 112 | |
|
94 | 113 | def topicmatch(ui, kw): |
|
95 | 114 | """Return help topics matching kw. |
|
96 | 115 | |
|
97 | 116 | Returns {'section': [(name, summary), ...], ...} where section is |
|
98 | 117 | one of topics, commands, extensions, or extensioncommands. |
|
99 | 118 | """ |
|
100 | 119 | kw = encoding.lower(kw) |
|
101 | 120 | def lowercontains(container): |
|
102 | 121 | return kw in encoding.lower(container) # translated in helptable |
|
103 | 122 | results = {'topics': [], |
|
104 | 123 | 'commands': [], |
|
105 | 124 | 'extensions': [], |
|
106 | 125 | 'extensioncommands': [], |
|
107 | 126 | } |
|
108 | 127 | for names, header, doc in helptable: |
|
109 | 128 | # Old extensions may use a str as doc. |
|
110 | 129 | if (sum(map(lowercontains, names)) |
|
111 | 130 | or lowercontains(header) |
|
112 | 131 | or (callable(doc) and lowercontains(doc(ui)))): |
|
113 | 132 | results['topics'].append((names[0], header)) |
|
114 | import commands # avoid cycle | |
|
133 | from . import commands # avoid cycle | |
|
115 | 134 | for cmd, entry in commands.table.iteritems(): |
|
116 | 135 | if len(entry) == 3: |
|
117 | 136 | summary = entry[2] |
|
118 | 137 | else: |
|
119 | 138 | summary = '' |
|
120 | 139 | # translate docs *before* searching there |
|
121 | 140 | docs = _(getattr(entry[0], '__doc__', None)) or '' |
|
122 | 141 | if kw in cmd or lowercontains(summary) or lowercontains(docs): |
|
123 | 142 | doclines = docs.splitlines() |
|
124 | 143 | if doclines: |
|
125 | 144 | summary = doclines[0] |
|
126 | 145 | cmdname = cmd.partition('|')[0].lstrip('^') |
|
127 | 146 | if filtercmd(ui, cmdname, kw, docs): |
|
128 | 147 | continue |
|
129 | 148 | results['commands'].append((cmdname, summary)) |
|
130 | 149 | for name, docs in itertools.chain( |
|
131 | 150 | extensions.enabled(False).iteritems(), |
|
132 | 151 | extensions.disabled().iteritems()): |
|
133 | 152 | # extensions.load ignores the UI argument |
|
134 | 153 | mod = extensions.load(None, name, '') |
|
135 | 154 | name = name.rpartition('.')[-1] |
|
136 | 155 | if lowercontains(name) or lowercontains(docs): |
|
137 | 156 | # extension docs are already translated |
|
138 | 157 | results['extensions'].append((name, docs.splitlines()[0])) |
|
139 | 158 | for cmd, entry in getattr(mod, 'cmdtable', {}).iteritems(): |
|
140 | 159 | if kw in cmd or (len(entry) > 2 and lowercontains(entry[2])): |
|
141 | 160 | cmdname = cmd.partition('|')[0].lstrip('^') |
|
142 | 161 | if entry[0].__doc__: |
|
143 | 162 | cmddoc = gettext(entry[0].__doc__).splitlines()[0] |
|
144 | 163 | else: |
|
145 | 164 | cmddoc = _('(no help text available)') |
|
146 | 165 | if filtercmd(ui, cmdname, kw, cmddoc): |
|
147 | 166 | continue |
|
148 | 167 | results['extensioncommands'].append((cmdname, cmddoc)) |
|
149 | 168 | return results |
|
150 | 169 | |
|
151 | 170 | def loaddoc(topic, subdir=None): |
|
152 | 171 | """Return a delayed loader for help/topic.txt.""" |
|
153 | 172 | |
|
154 | 173 | def loader(ui): |
|
155 | 174 | docdir = os.path.join(util.datapath, 'help') |
|
156 | 175 | if subdir: |
|
157 | 176 | docdir = os.path.join(docdir, subdir) |
|
158 | 177 | path = os.path.join(docdir, topic + ".txt") |
|
159 | 178 | doc = gettext(util.readfile(path)) |
|
160 | 179 | for rewriter in helphooks.get(topic, []): |
|
161 | 180 | doc = rewriter(ui, topic, doc) |
|
162 | 181 | return doc |
|
163 | 182 | |
|
164 | 183 | return loader |
|
165 | 184 | |
|
166 | 185 | internalstable = sorted([ |
|
167 | 186 | (['bundles'], _('container for exchange of repository data'), |
|
168 | 187 | loaddoc('bundles', subdir='internals')), |
|
169 | 188 | (['changegroups'], _('representation of revlog data'), |
|
170 | 189 | loaddoc('changegroups', subdir='internals')), |
|
171 | 190 | ]) |
|
172 | 191 | |
|
173 | 192 | def internalshelp(ui): |
|
174 | 193 | """Generate the index for the "internals" topic.""" |
|
175 | 194 | lines = [] |
|
176 | 195 | for names, header, doc in internalstable: |
|
177 | 196 | lines.append(' :%s: %s\n' % (names[0], header)) |
|
178 | 197 | |
|
179 | 198 | return ''.join(lines) |
|
180 | 199 | |
|
181 | 200 | helptable = sorted([ |
|
182 | 201 | (["config", "hgrc"], _("Configuration Files"), loaddoc('config')), |
|
183 | 202 | (["dates"], _("Date Formats"), loaddoc('dates')), |
|
184 | 203 | (["patterns"], _("File Name Patterns"), loaddoc('patterns')), |
|
185 | 204 | (['environment', 'env'], _('Environment Variables'), |
|
186 | 205 | loaddoc('environment')), |
|
187 | 206 | (['revisions', 'revs'], _('Specifying Single Revisions'), |
|
188 | 207 | loaddoc('revisions')), |
|
189 | 208 | (['multirevs', 'mrevs'], _('Specifying Multiple Revisions'), |
|
190 | 209 | loaddoc('multirevs')), |
|
191 | 210 | (['revsets', 'revset'], _("Specifying Revision Sets"), loaddoc('revsets')), |
|
192 | 211 | (['filesets', 'fileset'], _("Specifying File Sets"), loaddoc('filesets')), |
|
193 | 212 | (['diffs'], _('Diff Formats'), loaddoc('diffs')), |
|
194 | 213 | (['merge-tools', 'mergetools'], _('Merge Tools'), loaddoc('merge-tools')), |
|
195 | 214 | (['templating', 'templates', 'template', 'style'], _('Template Usage'), |
|
196 | 215 | loaddoc('templates')), |
|
197 | 216 | (['urls'], _('URL Paths'), loaddoc('urls')), |
|
198 | 217 | (["extensions"], _("Using Additional Features"), extshelp), |
|
199 | 218 | (["subrepos", "subrepo"], _("Subrepositories"), loaddoc('subrepos')), |
|
200 | 219 | (["hgweb"], _("Configuring hgweb"), loaddoc('hgweb')), |
|
201 | 220 | (["glossary"], _("Glossary"), loaddoc('glossary')), |
|
202 | 221 | (["hgignore", "ignore"], _("Syntax for Mercurial Ignore Files"), |
|
203 | 222 | loaddoc('hgignore')), |
|
204 | 223 | (["phases"], _("Working with Phases"), loaddoc('phases')), |
|
205 | 224 | (['scripting'], _('Using Mercurial from scripts and automation'), |
|
206 | 225 | loaddoc('scripting')), |
|
207 | 226 | (['internals'], _("Technical implementation topics"), |
|
208 | 227 | internalshelp), |
|
209 | 228 | ]) |
|
210 | 229 | |
|
211 | 230 | # Maps topics with sub-topics to a list of their sub-topics. |
|
212 | 231 | subtopics = { |
|
213 | 232 | 'internals': internalstable, |
|
214 | 233 | } |
|
215 | 234 | |
|
216 | 235 | # Map topics to lists of callable taking the current topic help and |
|
217 | 236 | # returning the updated version |
|
218 | 237 | helphooks = {} |
|
219 | 238 | |
|
220 | 239 | def addtopichook(topic, rewriter): |
|
221 | 240 | helphooks.setdefault(topic, []).append(rewriter) |
|
222 | 241 | |
|
223 | 242 | def makeitemsdoc(ui, topic, doc, marker, items, dedent=False): |
|
224 | 243 | """Extract docstring from the items key to function mapping, build a |
|
225 | 244 | single documentation block and use it to overwrite the marker in doc. |
|
226 | 245 | """ |
|
227 | 246 | entries = [] |
|
228 | 247 | for name in sorted(items): |
|
229 | 248 | text = (items[name].__doc__ or '').rstrip() |
|
230 | 249 | if (not text |
|
231 | 250 | or not ui.verbose and any(w in text for w in _exclkeywords)): |
|
232 | 251 | continue |
|
233 | 252 | text = gettext(text) |
|
234 | 253 | if dedent: |
|
235 | 254 | text = textwrap.dedent(text) |
|
236 | 255 | lines = text.splitlines() |
|
237 | 256 | doclines = [(lines[0])] |
|
238 | 257 | for l in lines[1:]: |
|
239 | 258 | # Stop once we find some Python doctest |
|
240 | 259 | if l.strip().startswith('>>>'): |
|
241 | 260 | break |
|
242 | 261 | if dedent: |
|
243 | 262 | doclines.append(l.rstrip()) |
|
244 | 263 | else: |
|
245 | 264 | doclines.append(' ' + l.strip()) |
|
246 | 265 | entries.append('\n'.join(doclines)) |
|
247 | 266 | entries = '\n\n'.join(entries) |
|
248 | 267 | return doc.replace(marker, entries) |
|
249 | 268 | |
|
250 | 269 | def addtopicsymbols(topic, marker, symbols, dedent=False): |
|
251 | 270 | def add(ui, topic, doc): |
|
252 | 271 | return makeitemsdoc(ui, topic, doc, marker, symbols, dedent=dedent) |
|
253 | 272 | addtopichook(topic, add) |
|
254 | 273 | |
|
255 | 274 | addtopicsymbols('filesets', '.. predicatesmarker', fileset.symbols) |
|
256 | 275 | addtopicsymbols('merge-tools', '.. internaltoolsmarker', |
|
257 | 276 | filemerge.internalsdoc) |
|
258 | 277 | addtopicsymbols('revsets', '.. predicatesmarker', revset.symbols) |
|
259 | 278 | addtopicsymbols('templates', '.. keywordsmarker', templatekw.keywords) |
|
260 | 279 | addtopicsymbols('templates', '.. filtersmarker', templatefilters.filters) |
|
261 | 280 | addtopicsymbols('templates', '.. functionsmarker', templater.funcs) |
|
262 | 281 | addtopicsymbols('hgweb', '.. webcommandsmarker', webcommands.commands, |
|
263 | 282 | dedent=True) |
|
264 | 283 | |
|
265 | 284 | def help_(ui, name, unknowncmd=False, full=True, subtopic=None, **opts): |
|
266 | 285 | ''' |
|
267 | 286 | Generate the help for 'name' as unformatted restructured text. If |
|
268 | 287 | 'name' is None, describe the commands available. |
|
269 | 288 | ''' |
|
270 | 289 | |
|
271 | import commands # avoid cycle | |
|
290 | from . import commands # avoid cycle | |
|
272 | 291 | |
|
273 | 292 | def helpcmd(name, subtopic=None): |
|
274 | 293 | try: |
|
275 | 294 | aliases, entry = cmdutil.findcmd(name, commands.table, |
|
276 | 295 | strict=unknowncmd) |
|
277 | 296 | except error.AmbiguousCommand as inst: |
|
278 | 297 | # py3k fix: except vars can't be used outside the scope of the |
|
279 | 298 | # except block, nor can be used inside a lambda. python issue4617 |
|
280 | 299 | prefix = inst.args[0] |
|
281 | 300 | select = lambda c: c.lstrip('^').startswith(prefix) |
|
282 | 301 | rst = helplist(select) |
|
283 | 302 | return rst |
|
284 | 303 | |
|
285 | 304 | rst = [] |
|
286 | 305 | |
|
287 | 306 | # check if it's an invalid alias and display its error if it is |
|
288 | 307 | if getattr(entry[0], 'badalias', None): |
|
289 | 308 | rst.append(entry[0].badalias + '\n') |
|
290 | 309 | if entry[0].unknowncmd: |
|
291 | 310 | try: |
|
292 | 311 | rst.extend(helpextcmd(entry[0].cmdname)) |
|
293 | 312 | except error.UnknownCommand: |
|
294 | 313 | pass |
|
295 | 314 | return rst |
|
296 | 315 | |
|
297 | 316 | # synopsis |
|
298 | 317 | if len(entry) > 2: |
|
299 | 318 | if entry[2].startswith('hg'): |
|
300 | 319 | rst.append("%s\n" % entry[2]) |
|
301 | 320 | else: |
|
302 | 321 | rst.append('hg %s %s\n' % (aliases[0], entry[2])) |
|
303 | 322 | else: |
|
304 | 323 | rst.append('hg %s\n' % aliases[0]) |
|
305 | 324 | # aliases |
|
306 | 325 | if full and not ui.quiet and len(aliases) > 1: |
|
307 | 326 | rst.append(_("\naliases: %s\n") % ', '.join(aliases[1:])) |
|
308 | 327 | rst.append('\n') |
|
309 | 328 | |
|
310 | 329 | # description |
|
311 | 330 | doc = gettext(entry[0].__doc__) |
|
312 | 331 | if not doc: |
|
313 | 332 | doc = _("(no help text available)") |
|
314 | 333 | if util.safehasattr(entry[0], 'definition'): # aliased command |
|
315 | 334 | if entry[0].definition.startswith('!'): # shell alias |
|
316 | 335 | doc = _('shell alias for::\n\n %s') % entry[0].definition[1:] |
|
317 | 336 | else: |
|
318 | 337 | doc = _('alias for: hg %s\n\n%s') % (entry[0].definition, doc) |
|
319 | 338 | doc = doc.splitlines(True) |
|
320 | 339 | if ui.quiet or not full: |
|
321 | 340 | rst.append(doc[0]) |
|
322 | 341 | else: |
|
323 | 342 | rst.extend(doc) |
|
324 | 343 | rst.append('\n') |
|
325 | 344 | |
|
326 | 345 | # check if this command shadows a non-trivial (multi-line) |
|
327 | 346 | # extension help text |
|
328 | 347 | try: |
|
329 | 348 | mod = extensions.find(name) |
|
330 | 349 | doc = gettext(mod.__doc__) or '' |
|
331 | 350 | if '\n' in doc.strip(): |
|
332 | 351 | msg = _('(use "hg help -e %s" to show help for ' |
|
333 | 352 | 'the %s extension)') % (name, name) |
|
334 | 353 | rst.append('\n%s\n' % msg) |
|
335 | 354 | except KeyError: |
|
336 | 355 | pass |
|
337 | 356 | |
|
338 | 357 | # options |
|
339 | 358 | if not ui.quiet and entry[1]: |
|
340 | 359 | rst.append(optrst(_("options"), entry[1], ui.verbose)) |
|
341 | 360 | |
|
342 | 361 | if ui.verbose: |
|
343 | 362 | rst.append(optrst(_("global options"), |
|
344 | 363 | commands.globalopts, ui.verbose)) |
|
345 | 364 | |
|
346 | 365 | if not ui.verbose: |
|
347 | 366 | if not full: |
|
348 | 367 | rst.append(_('\n(use "hg %s -h" to show more help)\n') |
|
349 | 368 | % name) |
|
350 | 369 | elif not ui.quiet: |
|
351 | 370 | rst.append(_('\n(some details hidden, use --verbose ' |
|
352 | 371 | 'to show complete help)')) |
|
353 | 372 | |
|
354 | 373 | return rst |
|
355 | 374 | |
|
356 | 375 | |
|
357 | 376 | def helplist(select=None, **opts): |
|
358 | 377 | # list of commands |
|
359 | 378 | if name == "shortlist": |
|
360 | 379 | header = _('basic commands:\n\n') |
|
361 | 380 | elif name == "debug": |
|
362 | 381 | header = _('debug commands (internal and unsupported):\n\n') |
|
363 | 382 | else: |
|
364 | 383 | header = _('list of commands:\n\n') |
|
365 | 384 | |
|
366 | 385 | h = {} |
|
367 | 386 | cmds = {} |
|
368 | 387 | for c, e in commands.table.iteritems(): |
|
369 | 388 | f = c.partition("|")[0] |
|
370 | 389 | if select and not select(f): |
|
371 | 390 | continue |
|
372 | 391 | if (not select and name != 'shortlist' and |
|
373 | 392 | e[0].__module__ != commands.__name__): |
|
374 | 393 | continue |
|
375 | 394 | if name == "shortlist" and not f.startswith("^"): |
|
376 | 395 | continue |
|
377 | 396 | f = f.lstrip("^") |
|
378 | 397 | doc = e[0].__doc__ |
|
379 | 398 | if filtercmd(ui, f, name, doc): |
|
380 | 399 | continue |
|
381 | 400 | doc = gettext(doc) |
|
382 | 401 | if not doc: |
|
383 | 402 | doc = _("(no help text available)") |
|
384 | 403 | h[f] = doc.splitlines()[0].rstrip() |
|
385 | 404 | cmds[f] = c.lstrip("^") |
|
386 | 405 | |
|
387 | 406 | rst = [] |
|
388 | 407 | if not h: |
|
389 | 408 | if not ui.quiet: |
|
390 | 409 | rst.append(_('no commands defined\n')) |
|
391 | 410 | return rst |
|
392 | 411 | |
|
393 | 412 | if not ui.quiet: |
|
394 | 413 | rst.append(header) |
|
395 | 414 | fns = sorted(h) |
|
396 | 415 | for f in fns: |
|
397 | 416 | if ui.verbose: |
|
398 | 417 | commacmds = cmds[f].replace("|",", ") |
|
399 | 418 | rst.append(" :%s: %s\n" % (commacmds, h[f])) |
|
400 | 419 | else: |
|
401 | 420 | rst.append(' :%s: %s\n' % (f, h[f])) |
|
402 | 421 | |
|
403 | 422 | ex = opts.get |
|
404 | 423 | anyopts = (ex('keyword') or not (ex('command') or ex('extension'))) |
|
405 | 424 | if not name and anyopts: |
|
406 | 425 | exts = listexts(_('enabled extensions:'), extensions.enabled()) |
|
407 | 426 | if exts: |
|
408 | 427 | rst.append('\n') |
|
409 | 428 | rst.extend(exts) |
|
410 | 429 | |
|
411 | 430 | rst.append(_("\nadditional help topics:\n\n")) |
|
412 | 431 | topics = [] |
|
413 | 432 | for names, header, doc in helptable: |
|
414 | 433 | topics.append((names[0], header)) |
|
415 | 434 | for t, desc in topics: |
|
416 | 435 | rst.append(" :%s: %s\n" % (t, desc)) |
|
417 | 436 | |
|
418 | 437 | if ui.quiet: |
|
419 | 438 | pass |
|
420 | 439 | elif ui.verbose: |
|
421 | 440 | rst.append('\n%s\n' % optrst(_("global options"), |
|
422 | 441 | commands.globalopts, ui.verbose)) |
|
423 | 442 | if name == 'shortlist': |
|
424 | 443 | rst.append(_('\n(use "hg help" for the full list ' |
|
425 | 444 | 'of commands)\n')) |
|
426 | 445 | else: |
|
427 | 446 | if name == 'shortlist': |
|
428 | 447 | rst.append(_('\n(use "hg help" for the full list of commands ' |
|
429 | 448 | 'or "hg -v" for details)\n')) |
|
430 | 449 | elif name and not full: |
|
431 | 450 | rst.append(_('\n(use "hg help %s" to show the full help ' |
|
432 | 451 | 'text)\n') % name) |
|
433 | 452 | elif name and cmds and name in cmds.keys(): |
|
434 | 453 | rst.append(_('\n(use "hg help -v -e %s" to show built-in ' |
|
435 | 454 | 'aliases and global options)\n') % name) |
|
436 | 455 | else: |
|
437 | 456 | rst.append(_('\n(use "hg help -v%s" to show built-in aliases ' |
|
438 | 457 | 'and global options)\n') |
|
439 | 458 | % (name and " " + name or "")) |
|
440 | 459 | return rst |
|
441 | 460 | |
|
442 | 461 | def helptopic(name, subtopic=None): |
|
443 | 462 | # Look for sub-topic entry first. |
|
444 | 463 | header, doc = None, None |
|
445 | 464 | if subtopic and name in subtopics: |
|
446 | 465 | for names, header, doc in subtopics[name]: |
|
447 | 466 | if subtopic in names: |
|
448 | 467 | break |
|
449 | 468 | |
|
450 | 469 | if not header: |
|
451 | 470 | for names, header, doc in helptable: |
|
452 | 471 | if name in names: |
|
453 | 472 | break |
|
454 | 473 | else: |
|
455 | 474 | raise error.UnknownCommand(name) |
|
456 | 475 | |
|
457 | 476 | rst = [minirst.section(header)] |
|
458 | 477 | |
|
459 | 478 | # description |
|
460 | 479 | if not doc: |
|
461 | 480 | rst.append(" %s\n" % _("(no help text available)")) |
|
462 | 481 | if callable(doc): |
|
463 | 482 | rst += [" %s\n" % l for l in doc(ui).splitlines()] |
|
464 | 483 | |
|
465 | 484 | if not ui.verbose: |
|
466 | 485 | omitted = _('(some details hidden, use --verbose' |
|
467 | 486 | ' to show complete help)') |
|
468 | 487 | indicateomitted(rst, omitted) |
|
469 | 488 | |
|
470 | 489 | try: |
|
471 | 490 | cmdutil.findcmd(name, commands.table) |
|
472 | 491 | rst.append(_('\nuse "hg help -c %s" to see help for ' |
|
473 | 492 | 'the %s command\n') % (name, name)) |
|
474 | 493 | except error.UnknownCommand: |
|
475 | 494 | pass |
|
476 | 495 | return rst |
|
477 | 496 | |
|
478 | 497 | def helpext(name, subtopic=None): |
|
479 | 498 | try: |
|
480 | 499 | mod = extensions.find(name) |
|
481 | 500 | doc = gettext(mod.__doc__) or _('no help text available') |
|
482 | 501 | except KeyError: |
|
483 | 502 | mod = None |
|
484 | 503 | doc = extensions.disabledext(name) |
|
485 | 504 | if not doc: |
|
486 | 505 | raise error.UnknownCommand(name) |
|
487 | 506 | |
|
488 | 507 | if '\n' not in doc: |
|
489 | 508 | head, tail = doc, "" |
|
490 | 509 | else: |
|
491 | 510 | head, tail = doc.split('\n', 1) |
|
492 | 511 | rst = [_('%s extension - %s\n\n') % (name.rpartition('.')[-1], head)] |
|
493 | 512 | if tail: |
|
494 | 513 | rst.extend(tail.splitlines(True)) |
|
495 | 514 | rst.append('\n') |
|
496 | 515 | |
|
497 | 516 | if not ui.verbose: |
|
498 | 517 | omitted = _('(some details hidden, use --verbose' |
|
499 | 518 | ' to show complete help)') |
|
500 | 519 | indicateomitted(rst, omitted) |
|
501 | 520 | |
|
502 | 521 | if mod: |
|
503 | 522 | try: |
|
504 | 523 | ct = mod.cmdtable |
|
505 | 524 | except AttributeError: |
|
506 | 525 | ct = {} |
|
507 | 526 | modcmds = set([c.partition('|')[0] for c in ct]) |
|
508 | 527 | rst.extend(helplist(modcmds.__contains__)) |
|
509 | 528 | else: |
|
510 | 529 | rst.append(_('(use "hg help extensions" for information on enabling' |
|
511 | 530 | ' extensions)\n')) |
|
512 | 531 | return rst |
|
513 | 532 | |
|
514 | 533 | def helpextcmd(name, subtopic=None): |
|
515 | 534 | cmd, ext, mod = extensions.disabledcmd(ui, name, |
|
516 | 535 | ui.configbool('ui', 'strict')) |
|
517 | 536 | doc = gettext(mod.__doc__).splitlines()[0] |
|
518 | 537 | |
|
519 | 538 | rst = listexts(_("'%s' is provided by the following " |
|
520 | 539 | "extension:") % cmd, {ext: doc}, indent=4, |
|
521 | 540 | showdeprecated=True) |
|
522 | 541 | rst.append('\n') |
|
523 | 542 | rst.append(_('(use "hg help extensions" for information on enabling ' |
|
524 | 543 | 'extensions)\n')) |
|
525 | 544 | return rst |
|
526 | 545 | |
|
527 | 546 | |
|
528 | 547 | rst = [] |
|
529 | 548 | kw = opts.get('keyword') |
|
530 | 549 | if kw or name is None and any(opts[o] for o in opts): |
|
531 | 550 | matches = topicmatch(ui, name or '') |
|
532 | 551 | helpareas = [] |
|
533 | 552 | if opts.get('extension'): |
|
534 | 553 | helpareas += [('extensions', _('Extensions'))] |
|
535 | 554 | if opts.get('command'): |
|
536 | 555 | helpareas += [('commands', _('Commands'))] |
|
537 | 556 | if not helpareas: |
|
538 | 557 | helpareas = [('topics', _('Topics')), |
|
539 | 558 | ('commands', _('Commands')), |
|
540 | 559 | ('extensions', _('Extensions')), |
|
541 | 560 | ('extensioncommands', _('Extension Commands'))] |
|
542 | 561 | for t, title in helpareas: |
|
543 | 562 | if matches[t]: |
|
544 | 563 | rst.append('%s:\n\n' % title) |
|
545 | 564 | rst.extend(minirst.maketable(sorted(matches[t]), 1)) |
|
546 | 565 | rst.append('\n') |
|
547 | 566 | if not rst: |
|
548 | 567 | msg = _('no matches') |
|
549 | 568 | hint = _('try "hg help" for a list of topics') |
|
550 | 569 | raise error.Abort(msg, hint=hint) |
|
551 | 570 | elif name and name != 'shortlist': |
|
552 | 571 | queries = [] |
|
553 | 572 | if unknowncmd: |
|
554 | 573 | queries += [helpextcmd] |
|
555 | 574 | if opts.get('extension'): |
|
556 | 575 | queries += [helpext] |
|
557 | 576 | if opts.get('command'): |
|
558 | 577 | queries += [helpcmd] |
|
559 | 578 | if not queries: |
|
560 | 579 | queries = (helptopic, helpcmd, helpext, helpextcmd) |
|
561 | 580 | for f in queries: |
|
562 | 581 | try: |
|
563 | 582 | rst = f(name, subtopic) |
|
564 | 583 | break |
|
565 | 584 | except error.UnknownCommand: |
|
566 | 585 | pass |
|
567 | 586 | else: |
|
568 | 587 | if unknowncmd: |
|
569 | 588 | raise error.UnknownCommand(name) |
|
570 | 589 | else: |
|
571 | 590 | msg = _('no such help topic: %s') % name |
|
572 | 591 | hint = _('try "hg help --keyword %s"') % name |
|
573 | 592 | raise error.Abort(msg, hint=hint) |
|
574 | 593 | else: |
|
575 | 594 | # program name |
|
576 | 595 | if not ui.quiet: |
|
577 | 596 | rst = [_("Mercurial Distributed SCM\n"), '\n'] |
|
578 | 597 | rst.extend(helplist(None, **opts)) |
|
579 | 598 | |
|
580 | 599 | return ''.join(rst) |
@@ -1,207 +1,206 b'' | |||
|
1 | 1 | #require test-repo |
|
2 | 2 | |
|
3 | 3 | $ cd "$TESTDIR"/.. |
|
4 | 4 | |
|
5 | 5 | $ hg files 'set:(**.py)' | sed 's|\\|/|g' | xargs python contrib/check-py3-compat.py |
|
6 | 6 | contrib/casesmash.py not using absolute_import |
|
7 | 7 | contrib/check-code.py not using absolute_import |
|
8 | 8 | contrib/check-code.py requires print_function |
|
9 | 9 | contrib/check-config.py not using absolute_import |
|
10 | 10 | contrib/check-config.py requires print_function |
|
11 | 11 | contrib/debugcmdserver.py not using absolute_import |
|
12 | 12 | contrib/debugcmdserver.py requires print_function |
|
13 | 13 | contrib/debugshell.py not using absolute_import |
|
14 | 14 | contrib/fixpax.py not using absolute_import |
|
15 | 15 | contrib/fixpax.py requires print_function |
|
16 | 16 | contrib/hgclient.py not using absolute_import |
|
17 | 17 | contrib/hgclient.py requires print_function |
|
18 | 18 | contrib/hgfixes/fix_bytes.py not using absolute_import |
|
19 | 19 | contrib/hgfixes/fix_bytesmod.py not using absolute_import |
|
20 | 20 | contrib/hgfixes/fix_leftover_imports.py not using absolute_import |
|
21 | 21 | contrib/import-checker.py not using absolute_import |
|
22 | 22 | contrib/import-checker.py requires print_function |
|
23 | 23 | contrib/memory.py not using absolute_import |
|
24 | 24 | contrib/perf.py not using absolute_import |
|
25 | 25 | contrib/python-hook-examples.py not using absolute_import |
|
26 | 26 | contrib/revsetbenchmarks.py not using absolute_import |
|
27 | 27 | contrib/revsetbenchmarks.py requires print_function |
|
28 | 28 | contrib/showstack.py not using absolute_import |
|
29 | 29 | contrib/synthrepo.py not using absolute_import |
|
30 | 30 | contrib/win32/hgwebdir_wsgi.py not using absolute_import |
|
31 | 31 | doc/check-seclevel.py not using absolute_import |
|
32 | 32 | doc/gendoc.py not using absolute_import |
|
33 | 33 | doc/hgmanpage.py not using absolute_import |
|
34 | 34 | hgext/__init__.py not using absolute_import |
|
35 | 35 | hgext/acl.py not using absolute_import |
|
36 | 36 | hgext/blackbox.py not using absolute_import |
|
37 | 37 | hgext/bugzilla.py not using absolute_import |
|
38 | 38 | hgext/censor.py not using absolute_import |
|
39 | 39 | hgext/children.py not using absolute_import |
|
40 | 40 | hgext/churn.py not using absolute_import |
|
41 | 41 | hgext/clonebundles.py not using absolute_import |
|
42 | 42 | hgext/color.py not using absolute_import |
|
43 | 43 | hgext/convert/__init__.py not using absolute_import |
|
44 | 44 | hgext/convert/bzr.py not using absolute_import |
|
45 | 45 | hgext/convert/common.py not using absolute_import |
|
46 | 46 | hgext/convert/convcmd.py not using absolute_import |
|
47 | 47 | hgext/convert/cvs.py not using absolute_import |
|
48 | 48 | hgext/convert/cvsps.py not using absolute_import |
|
49 | 49 | hgext/convert/darcs.py not using absolute_import |
|
50 | 50 | hgext/convert/filemap.py not using absolute_import |
|
51 | 51 | hgext/convert/git.py not using absolute_import |
|
52 | 52 | hgext/convert/gnuarch.py not using absolute_import |
|
53 | 53 | hgext/convert/hg.py not using absolute_import |
|
54 | 54 | hgext/convert/monotone.py not using absolute_import |
|
55 | 55 | hgext/convert/p4.py not using absolute_import |
|
56 | 56 | hgext/convert/subversion.py not using absolute_import |
|
57 | 57 | hgext/convert/transport.py not using absolute_import |
|
58 | 58 | hgext/eol.py not using absolute_import |
|
59 | 59 | hgext/extdiff.py not using absolute_import |
|
60 | 60 | hgext/factotum.py not using absolute_import |
|
61 | 61 | hgext/fetch.py not using absolute_import |
|
62 | 62 | hgext/gpg.py not using absolute_import |
|
63 | 63 | hgext/graphlog.py not using absolute_import |
|
64 | 64 | hgext/hgcia.py not using absolute_import |
|
65 | 65 | hgext/hgk.py not using absolute_import |
|
66 | 66 | hgext/highlight/__init__.py not using absolute_import |
|
67 | 67 | hgext/highlight/highlight.py not using absolute_import |
|
68 | 68 | hgext/histedit.py not using absolute_import |
|
69 | 69 | hgext/keyword.py not using absolute_import |
|
70 | 70 | hgext/largefiles/__init__.py not using absolute_import |
|
71 | 71 | hgext/largefiles/basestore.py not using absolute_import |
|
72 | 72 | hgext/largefiles/lfcommands.py not using absolute_import |
|
73 | 73 | hgext/largefiles/lfutil.py not using absolute_import |
|
74 | 74 | hgext/largefiles/localstore.py not using absolute_import |
|
75 | 75 | hgext/largefiles/overrides.py not using absolute_import |
|
76 | 76 | hgext/largefiles/proto.py not using absolute_import |
|
77 | 77 | hgext/largefiles/remotestore.py not using absolute_import |
|
78 | 78 | hgext/largefiles/reposetup.py not using absolute_import |
|
79 | 79 | hgext/largefiles/uisetup.py not using absolute_import |
|
80 | 80 | hgext/largefiles/wirestore.py not using absolute_import |
|
81 | 81 | hgext/mq.py not using absolute_import |
|
82 | 82 | hgext/notify.py not using absolute_import |
|
83 | 83 | hgext/pager.py not using absolute_import |
|
84 | 84 | hgext/patchbomb.py not using absolute_import |
|
85 | 85 | hgext/purge.py not using absolute_import |
|
86 | 86 | hgext/rebase.py not using absolute_import |
|
87 | 87 | hgext/record.py not using absolute_import |
|
88 | 88 | hgext/relink.py not using absolute_import |
|
89 | 89 | hgext/schemes.py not using absolute_import |
|
90 | 90 | hgext/share.py not using absolute_import |
|
91 | 91 | hgext/shelve.py not using absolute_import |
|
92 | 92 | hgext/strip.py not using absolute_import |
|
93 | 93 | hgext/transplant.py not using absolute_import |
|
94 | 94 | hgext/win32mbcs.py not using absolute_import |
|
95 | 95 | hgext/win32text.py not using absolute_import |
|
96 | 96 | hgext/zeroconf/Zeroconf.py not using absolute_import |
|
97 | 97 | hgext/zeroconf/Zeroconf.py requires print_function |
|
98 | 98 | hgext/zeroconf/__init__.py not using absolute_import |
|
99 | 99 | i18n/check-translation.py not using absolute_import |
|
100 | 100 | i18n/polib.py not using absolute_import |
|
101 | 101 | mercurial/byterange.py not using absolute_import |
|
102 | 102 | mercurial/cmdutil.py not using absolute_import |
|
103 | 103 | mercurial/commands.py not using absolute_import |
|
104 | 104 | mercurial/context.py not using absolute_import |
|
105 | 105 | mercurial/dirstate.py not using absolute_import |
|
106 | 106 | mercurial/dispatch.py requires print_function |
|
107 | 107 | mercurial/exchange.py not using absolute_import |
|
108 | mercurial/help.py not using absolute_import | |
|
109 | 108 | mercurial/httpclient/__init__.py not using absolute_import |
|
110 | 109 | mercurial/httpclient/_readers.py not using absolute_import |
|
111 | 110 | mercurial/httpclient/socketutil.py not using absolute_import |
|
112 | 111 | mercurial/httpconnection.py not using absolute_import |
|
113 | 112 | mercurial/keepalive.py not using absolute_import |
|
114 | 113 | mercurial/keepalive.py requires print_function |
|
115 | 114 | mercurial/localrepo.py not using absolute_import |
|
116 | 115 | mercurial/lsprof.py requires print_function |
|
117 | 116 | mercurial/lsprofcalltree.py not using absolute_import |
|
118 | 117 | mercurial/lsprofcalltree.py requires print_function |
|
119 | 118 | mercurial/mail.py requires print_function |
|
120 | 119 | mercurial/manifest.py not using absolute_import |
|
121 | 120 | mercurial/mdiff.py not using absolute_import |
|
122 | 121 | mercurial/patch.py not using absolute_import |
|
123 | 122 | mercurial/pvec.py not using absolute_import |
|
124 | 123 | mercurial/py3kcompat.py not using absolute_import |
|
125 | 124 | mercurial/scmposix.py not using absolute_import |
|
126 | 125 | mercurial/scmutil.py not using absolute_import |
|
127 | 126 | mercurial/scmwindows.py not using absolute_import |
|
128 | 127 | mercurial/store.py not using absolute_import |
|
129 | 128 | setup.py not using absolute_import |
|
130 | 129 | tests/filterpyflakes.py requires print_function |
|
131 | 130 | tests/generate-working-copy-states.py requires print_function |
|
132 | 131 | tests/get-with-headers.py requires print_function |
|
133 | 132 | tests/heredoctest.py requires print_function |
|
134 | 133 | tests/hypothesishelpers.py not using absolute_import |
|
135 | 134 | tests/hypothesishelpers.py requires print_function |
|
136 | 135 | tests/killdaemons.py not using absolute_import |
|
137 | 136 | tests/md5sum.py not using absolute_import |
|
138 | 137 | tests/mockblackbox.py not using absolute_import |
|
139 | 138 | tests/printenv.py not using absolute_import |
|
140 | 139 | tests/readlink.py not using absolute_import |
|
141 | 140 | tests/readlink.py requires print_function |
|
142 | 141 | tests/revlog-formatv0.py not using absolute_import |
|
143 | 142 | tests/run-tests.py not using absolute_import |
|
144 | 143 | tests/seq.py not using absolute_import |
|
145 | 144 | tests/seq.py requires print_function |
|
146 | 145 | tests/silenttestrunner.py not using absolute_import |
|
147 | 146 | tests/silenttestrunner.py requires print_function |
|
148 | 147 | tests/sitecustomize.py not using absolute_import |
|
149 | 148 | tests/svn-safe-append.py not using absolute_import |
|
150 | 149 | tests/svnxml.py not using absolute_import |
|
151 | 150 | tests/test-ancestor.py requires print_function |
|
152 | 151 | tests/test-atomictempfile.py not using absolute_import |
|
153 | 152 | tests/test-batching.py not using absolute_import |
|
154 | 153 | tests/test-batching.py requires print_function |
|
155 | 154 | tests/test-bdiff.py not using absolute_import |
|
156 | 155 | tests/test-bdiff.py requires print_function |
|
157 | 156 | tests/test-context.py not using absolute_import |
|
158 | 157 | tests/test-context.py requires print_function |
|
159 | 158 | tests/test-demandimport.py not using absolute_import |
|
160 | 159 | tests/test-demandimport.py requires print_function |
|
161 | 160 | tests/test-dispatch.py not using absolute_import |
|
162 | 161 | tests/test-dispatch.py requires print_function |
|
163 | 162 | tests/test-doctest.py not using absolute_import |
|
164 | 163 | tests/test-duplicateoptions.py not using absolute_import |
|
165 | 164 | tests/test-duplicateoptions.py requires print_function |
|
166 | 165 | tests/test-filecache.py not using absolute_import |
|
167 | 166 | tests/test-filecache.py requires print_function |
|
168 | 167 | tests/test-filelog.py not using absolute_import |
|
169 | 168 | tests/test-filelog.py requires print_function |
|
170 | 169 | tests/test-hg-parseurl.py not using absolute_import |
|
171 | 170 | tests/test-hg-parseurl.py requires print_function |
|
172 | 171 | tests/test-hgweb-auth.py not using absolute_import |
|
173 | 172 | tests/test-hgweb-auth.py requires print_function |
|
174 | 173 | tests/test-hgwebdir-paths.py not using absolute_import |
|
175 | 174 | tests/test-hybridencode.py not using absolute_import |
|
176 | 175 | tests/test-hybridencode.py requires print_function |
|
177 | 176 | tests/test-lrucachedict.py not using absolute_import |
|
178 | 177 | tests/test-lrucachedict.py requires print_function |
|
179 | 178 | tests/test-manifest.py not using absolute_import |
|
180 | 179 | tests/test-minirst.py not using absolute_import |
|
181 | 180 | tests/test-minirst.py requires print_function |
|
182 | 181 | tests/test-parseindex2.py not using absolute_import |
|
183 | 182 | tests/test-parseindex2.py requires print_function |
|
184 | 183 | tests/test-pathencode.py not using absolute_import |
|
185 | 184 | tests/test-pathencode.py requires print_function |
|
186 | 185 | tests/test-propertycache.py not using absolute_import |
|
187 | 186 | tests/test-propertycache.py requires print_function |
|
188 | 187 | tests/test-revlog-ancestry.py not using absolute_import |
|
189 | 188 | tests/test-revlog-ancestry.py requires print_function |
|
190 | 189 | tests/test-run-tests.py not using absolute_import |
|
191 | 190 | tests/test-simplemerge.py not using absolute_import |
|
192 | 191 | tests/test-status-inprocess.py not using absolute_import |
|
193 | 192 | tests/test-status-inprocess.py requires print_function |
|
194 | 193 | tests/test-symlink-os-yes-fs-no.py not using absolute_import |
|
195 | 194 | tests/test-trusted.py not using absolute_import |
|
196 | 195 | tests/test-trusted.py requires print_function |
|
197 | 196 | tests/test-ui-color.py not using absolute_import |
|
198 | 197 | tests/test-ui-color.py requires print_function |
|
199 | 198 | tests/test-ui-config.py not using absolute_import |
|
200 | 199 | tests/test-ui-config.py requires print_function |
|
201 | 200 | tests/test-ui-verbosity.py not using absolute_import |
|
202 | 201 | tests/test-ui-verbosity.py requires print_function |
|
203 | 202 | tests/test-url.py not using absolute_import |
|
204 | 203 | tests/test-url.py requires print_function |
|
205 | 204 | tests/test-walkrepo.py requires print_function |
|
206 | 205 | tests/test-wireproto.py requires print_function |
|
207 | 206 | tests/tinyproxy.py requires print_function |
General Comments 0
You need to be logged in to leave comments.
Login now