Show More
@@ -534,14 +534,22 b' def show_version(ui):' | |||||
534 | "not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\n" |
|
534 | "not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\n" | |
535 | )) |
|
535 | )) | |
536 |
|
536 | |||
537 |
def help_(ui, |
|
537 | def help_(ui, name=None, with_version=False): | |
538 |
"""show help for a |
|
538 | """show help for a command, extension, or list of commands | |
|
539 | ||||
|
540 | With no arguments, print a list of commands and short help. | |||
|
541 | ||||
|
542 | Given a command name, print help for that command. | |||
|
543 | ||||
|
544 | Given an extension name, print help for that extension, and the | |||
|
545 | commands it provides.""" | |||
539 | option_lists = [] |
|
546 | option_lists = [] | |
540 | if cmd and cmd != 'shortlist': |
|
547 | ||
|
548 | def helpcmd(name): | |||
541 | if with_version: |
|
549 | if with_version: | |
542 | show_version(ui) |
|
550 | show_version(ui) | |
543 | ui.write('\n') |
|
551 | ui.write('\n') | |
544 |
aliases, i = find( |
|
552 | aliases, i = findcmd(name) | |
545 | # synopsis |
|
553 | # synopsis | |
546 | ui.write("%s\n\n" % i[2]) |
|
554 | ui.write("%s\n\n" % i[2]) | |
547 |
|
555 | |||
@@ -561,30 +569,15 b' def help_(ui, cmd=None, with_version=Fal' | |||||
561 | # options |
|
569 | # options | |
562 | if i[1]: |
|
570 | if i[1]: | |
563 | option_lists.append(("options", i[1])) |
|
571 | option_lists.append(("options", i[1])) | |
564 |
|
572 | |||
565 | else: |
|
573 | def helplist(select=None): | |
566 | # program name |
|
|||
567 | if ui.verbose or with_version: |
|
|||
568 | show_version(ui) |
|
|||
569 | else: |
|
|||
570 | ui.status(_("Mercurial Distributed SCM\n")) |
|
|||
571 | ui.status('\n') |
|
|||
572 |
|
||||
573 | # list of commands |
|
|||
574 | if cmd == "shortlist": |
|
|||
575 | ui.status(_('basic commands (use "hg help" ' |
|
|||
576 | 'for the full list or option "-v" for details):\n\n')) |
|
|||
577 | elif ui.verbose: |
|
|||
578 | ui.status(_('list of commands:\n\n')) |
|
|||
579 | else: |
|
|||
580 | ui.status(_('list of commands (use "hg help -v" ' |
|
|||
581 | 'to show aliases and global options):\n\n')) |
|
|||
582 |
|
||||
583 | h = {} |
|
574 | h = {} | |
584 | cmds = {} |
|
575 | cmds = {} | |
585 | for c, e in table.items(): |
|
576 | for c, e in table.items(): | |
586 | f = c.split("|")[0] |
|
577 | f = c.split("|", 1)[0] | |
587 | if cmd == "shortlist" and not f.startswith("^"): |
|
578 | if select and not select(f): | |
|
579 | continue | |||
|
580 | if name == "shortlist" and not f.startswith("^"): | |||
588 | continue |
|
581 | continue | |
589 | f = f.lstrip("^") |
|
582 | f = f.lstrip("^") | |
590 | if not ui.debugflag and f.startswith("debug"): |
|
583 | if not ui.debugflag and f.startswith("debug"): | |
@@ -605,6 +598,53 b' def help_(ui, cmd=None, with_version=Fal' | |||||
605 | else: |
|
598 | else: | |
606 | ui.write(' %-*s %s\n' % (m, f, h[f])) |
|
599 | ui.write(' %-*s %s\n' % (m, f, h[f])) | |
607 |
|
600 | |||
|
601 | def helpext(name): | |||
|
602 | try: | |||
|
603 | mod = findext(name) | |||
|
604 | except KeyError: | |||
|
605 | raise UnknownCommand(name) | |||
|
606 | ||||
|
607 | doc = (mod.__doc__ or _('No help text available')).splitlines(0) | |||
|
608 | ui.write(_('%s extension - %s\n') % (name.split('.')[-1], doc[0])) | |||
|
609 | for d in doc[1:]: | |||
|
610 | ui.write(d, '\n') | |||
|
611 | ||||
|
612 | ui.status('\n') | |||
|
613 | if ui.verbose: | |||
|
614 | ui.status(_('list of commands:\n\n')) | |||
|
615 | else: | |||
|
616 | ui.status(_('list of commands (use "hg help -v %s" ' | |||
|
617 | 'to show aliases and global options):\n\n') % name) | |||
|
618 | ||||
|
619 | modcmds = dict.fromkeys([c.split('|', 1)[0] for c in mod.cmdtable]) | |||
|
620 | helplist(modcmds.has_key) | |||
|
621 | ||||
|
622 | if name and name != 'shortlist': | |||
|
623 | try: | |||
|
624 | helpcmd(name) | |||
|
625 | except UnknownCommand: | |||
|
626 | helpext(name) | |||
|
627 | ||||
|
628 | else: | |||
|
629 | # program name | |||
|
630 | if ui.verbose or with_version: | |||
|
631 | show_version(ui) | |||
|
632 | else: | |||
|
633 | ui.status(_("Mercurial Distributed SCM\n")) | |||
|
634 | ui.status('\n') | |||
|
635 | ||||
|
636 | # list of commands | |||
|
637 | if name == "shortlist": | |||
|
638 | ui.status(_('basic commands (use "hg help" ' | |||
|
639 | 'for the full list or option "-v" for details):\n\n')) | |||
|
640 | elif ui.verbose: | |||
|
641 | ui.status(_('list of commands:\n\n')) | |||
|
642 | else: | |||
|
643 | ui.status(_('list of commands (use "hg help -v" ' | |||
|
644 | 'to show aliases and global options):\n\n')) | |||
|
645 | ||||
|
646 | helplist() | |||
|
647 | ||||
608 | # global options |
|
648 | # global options | |
609 | if ui.verbose: |
|
649 | if ui.verbose: | |
610 | option_lists.append(("global options", globalopts)) |
|
650 | option_lists.append(("global options", globalopts)) | |
@@ -1254,7 +1294,7 b" def debugcomplete(ui, cmd='', **opts):" | |||||
1254 | options = [] |
|
1294 | options = [] | |
1255 | otables = [globalopts] |
|
1295 | otables = [globalopts] | |
1256 | if cmd: |
|
1296 | if cmd: | |
1257 | aliases, entry = find(cmd) |
|
1297 | aliases, entry = findcmd(cmd) | |
1258 | otables.append(entry[1]) |
|
1298 | otables.append(entry[1]) | |
1259 | for t in otables: |
|
1299 | for t in otables: | |
1260 | for o in t: |
|
1300 | for o in t: | |
@@ -3274,7 +3314,7 b' def findpossible(cmd):' | |||||
3274 |
|
3314 | |||
3275 | return choice |
|
3315 | return choice | |
3276 |
|
3316 | |||
3277 | def find(cmd): |
|
3317 | def findcmd(cmd): | |
3278 | """Return (aliases, command table entry) for command string.""" |
|
3318 | """Return (aliases, command table entry) for command string.""" | |
3279 | choice = findpossible(cmd) |
|
3319 | choice = findpossible(cmd) | |
3280 |
|
3320 | |||
@@ -3311,7 +3351,7 b' def parse(ui, args):' | |||||
3311 |
|
3351 | |||
3312 | if args: |
|
3352 | if args: | |
3313 | cmd, args = args[0], args[1:] |
|
3353 | cmd, args = args[0], args[1:] | |
3314 | aliases, i = find(cmd) |
|
3354 | aliases, i = findcmd(cmd) | |
3315 | cmd = aliases[0] |
|
3355 | cmd = aliases[0] | |
3316 | defaults = ui.config("defaults", cmd) |
|
3356 | defaults = ui.config("defaults", cmd) | |
3317 | if defaults: |
|
3357 | if defaults: | |
@@ -3338,6 +3378,19 b' def parse(ui, args):' | |||||
3338 |
|
3378 | |||
3339 | return (cmd, cmd and i[0] or None, args, options, cmdoptions) |
|
3379 | return (cmd, cmd and i[0] or None, args, options, cmdoptions) | |
3340 |
|
3380 | |||
|
3381 | external = {} | |||
|
3382 | ||||
|
3383 | def findext(name): | |||
|
3384 | '''return module with given extension name''' | |||
|
3385 | try: | |||
|
3386 | return external[name] | |||
|
3387 | except KeyError: | |||
|
3388 | dotname = '.' + name | |||
|
3389 | for k, v in external.iteritems(): | |||
|
3390 | if k.endswith('.' + name) or v.__name__ == name: | |||
|
3391 | return v | |||
|
3392 | raise KeyError(name) | |||
|
3393 | ||||
3341 | def dispatch(args): |
|
3394 | def dispatch(args): | |
3342 | for name in 'SIGBREAK', 'SIGHUP', 'SIGTERM': |
|
3395 | for name in 'SIGBREAK', 'SIGHUP', 'SIGTERM': | |
3343 | num = getattr(signal, name, None) |
|
3396 | num = getattr(signal, name, None) | |
@@ -3349,7 +3402,6 b' def dispatch(args):' | |||||
3349 | sys.stderr.write(_("abort: %s\n") % inst) |
|
3402 | sys.stderr.write(_("abort: %s\n") % inst) | |
3350 | return -1 |
|
3403 | return -1 | |
3351 |
|
3404 | |||
3352 | external = [] |
|
|||
3353 | for x in u.extensions(): |
|
3405 | for x in u.extensions(): | |
3354 | try: |
|
3406 | try: | |
3355 | if x[1]: |
|
3407 | if x[1]: | |
@@ -3366,10 +3418,12 b' def dispatch(args):' | |||||
3366 | mod = getattr(mod, comp) |
|
3418 | mod = getattr(mod, comp) | |
3367 | return mod |
|
3419 | return mod | |
3368 | try: |
|
3420 | try: | |
3369 |
|
|
3421 | name = 'hgext.' + x[0] | |
|
3422 | mod = importh(name) | |||
3370 | except ImportError: |
|
3423 | except ImportError: | |
3371 |
|
|
3424 | name = x[0] | |
3372 | external.append(mod) |
|
3425 | mod = importh(name) | |
|
3426 | external[name] = mod | |||
3373 | except (util.SignalInterrupt, KeyboardInterrupt): |
|
3427 | except (util.SignalInterrupt, KeyboardInterrupt): | |
3374 | raise |
|
3428 | raise | |
3375 | except Exception, inst: |
|
3429 | except Exception, inst: | |
@@ -3377,7 +3431,7 b' def dispatch(args):' | |||||
3377 | if u.print_exc(): |
|
3431 | if u.print_exc(): | |
3378 | return 1 |
|
3432 | return 1 | |
3379 |
|
3433 | |||
3380 | for x in external: |
|
3434 | for x in external.itervalues(): | |
3381 | uisetup = getattr(x, 'uisetup', None) |
|
3435 | uisetup = getattr(x, 'uisetup', None) | |
3382 | if uisetup: |
|
3436 | if uisetup: | |
3383 | uisetup(u) |
|
3437 | uisetup(u) | |
@@ -3433,7 +3487,7 b' def dispatch(args):' | |||||
3433 | if not repo: |
|
3487 | if not repo: | |
3434 | repo = hg.repository(u, path=path) |
|
3488 | repo = hg.repository(u, path=path) | |
3435 | u = repo.ui |
|
3489 | u = repo.ui | |
3436 | for x in external: |
|
3490 | for x in external.itervalues(): | |
3437 | if hasattr(x, 'reposetup'): |
|
3491 | if hasattr(x, 'reposetup'): | |
3438 | x.reposetup(u, repo) |
|
3492 | x.reposetup(u, repo) | |
3439 | except hg.RepoError: |
|
3493 | except hg.RepoError: |
@@ -127,7 +127,7 b' list of commands (use "hg help -v" to sh' | |||||
127 | export dump the header and diffs for one or more changesets |
|
127 | export dump the header and diffs for one or more changesets | |
128 | grep search for a pattern in specified files and revisions |
|
128 | grep search for a pattern in specified files and revisions | |
129 | heads show current repository heads |
|
129 | heads show current repository heads | |
130 |
help show help for a |
|
130 | help show help for a command, extension, or list of commands | |
131 | identify print information about the working copy |
|
131 | identify print information about the working copy | |
132 | import import an ordered set of patches |
|
132 | import import an ordered set of patches | |
133 | incoming show new changesets found in source |
|
133 | incoming show new changesets found in source | |
@@ -173,7 +173,7 b' list of commands (use "hg help -v" to sh' | |||||
173 | export dump the header and diffs for one or more changesets |
|
173 | export dump the header and diffs for one or more changesets | |
174 | grep search for a pattern in specified files and revisions |
|
174 | grep search for a pattern in specified files and revisions | |
175 | heads show current repository heads |
|
175 | heads show current repository heads | |
176 |
help show help for a |
|
176 | help show help for a command, extension, or list of commands | |
177 | identify print information about the working copy |
|
177 | identify print information about the working copy | |
178 | import import an ordered set of patches |
|
178 | import import an ordered set of patches | |
179 | incoming show new changesets found in source |
|
179 | incoming show new changesets found in source |
@@ -51,7 +51,7 b' list of commands (use "hg help -v" to sh' | |||||
51 | export dump the header and diffs for one or more changesets |
|
51 | export dump the header and diffs for one or more changesets | |
52 | grep search for a pattern in specified files and revisions |
|
52 | grep search for a pattern in specified files and revisions | |
53 | heads show current repository heads |
|
53 | heads show current repository heads | |
54 |
help show help for a |
|
54 | help show help for a command, extension, or list of commands | |
55 | identify print information about the working copy |
|
55 | identify print information about the working copy | |
56 | import import an ordered set of patches |
|
56 | import import an ordered set of patches | |
57 | incoming show new changesets found in source |
|
57 | incoming show new changesets found in source | |
@@ -93,7 +93,7 b' list of commands (use "hg help -v" to sh' | |||||
93 | export dump the header and diffs for one or more changesets |
|
93 | export dump the header and diffs for one or more changesets | |
94 | grep search for a pattern in specified files and revisions |
|
94 | grep search for a pattern in specified files and revisions | |
95 | heads show current repository heads |
|
95 | heads show current repository heads | |
96 |
help show help for a |
|
96 | help show help for a command, extension, or list of commands | |
97 | identify print information about the working copy |
|
97 | identify print information about the working copy | |
98 | import import an ordered set of patches |
|
98 | import import an ordered set of patches | |
99 | incoming show new changesets found in source |
|
99 | incoming show new changesets found in source |
General Comments 0
You need to be logged in to leave comments.
Login now