Show More
@@ -655,6 +655,28 b' def disabledext(name):' | |||||
655 | if name in paths: |
|
655 | if name in paths: | |
656 | return _disabledhelp(paths[name]) |
|
656 | return _disabledhelp(paths[name]) | |
657 |
|
657 | |||
|
658 | def _finddisabledcmd(ui, cmd, name, path, strict): | |||
|
659 | try: | |||
|
660 | mod = loadpath(path, 'hgext.%s' % name) | |||
|
661 | except Exception: | |||
|
662 | return | |||
|
663 | try: | |||
|
664 | aliases, entry = cmdutil.findcmd(cmd, | |||
|
665 | getattr(mod, 'cmdtable', {}), strict) | |||
|
666 | except (error.AmbiguousCommand, error.UnknownCommand): | |||
|
667 | return | |||
|
668 | except Exception: | |||
|
669 | ui.warn(_('warning: error finding commands in %s\n') % path) | |||
|
670 | ui.traceback() | |||
|
671 | return | |||
|
672 | for c in aliases: | |||
|
673 | if c.startswith(cmd): | |||
|
674 | cmd = c | |||
|
675 | break | |||
|
676 | else: | |||
|
677 | cmd = aliases[0] | |||
|
678 | return (cmd, name, mod) | |||
|
679 | ||||
658 | def disabledcmd(ui, cmd, strict=False): |
|
680 | def disabledcmd(ui, cmd, strict=False): | |
659 | '''import disabled extensions until cmd is found. |
|
681 | '''import disabled extensions until cmd is found. | |
660 | returns (cmdname, extname, module)''' |
|
682 | returns (cmdname, extname, module)''' | |
@@ -663,37 +685,15 b' def disabledcmd(ui, cmd, strict=False):' | |||||
663 | if not paths: |
|
685 | if not paths: | |
664 | raise error.UnknownCommand(cmd) |
|
686 | raise error.UnknownCommand(cmd) | |
665 |
|
687 | |||
666 | def findcmd(cmd, name, path): |
|
|||
667 | try: |
|
|||
668 | mod = loadpath(path, 'hgext.%s' % name) |
|
|||
669 | except Exception: |
|
|||
670 | return |
|
|||
671 | try: |
|
|||
672 | aliases, entry = cmdutil.findcmd(cmd, |
|
|||
673 | getattr(mod, 'cmdtable', {}), strict) |
|
|||
674 | except (error.AmbiguousCommand, error.UnknownCommand): |
|
|||
675 | return |
|
|||
676 | except Exception: |
|
|||
677 | ui.warn(_('warning: error finding commands in %s\n') % path) |
|
|||
678 | ui.traceback() |
|
|||
679 | return |
|
|||
680 | for c in aliases: |
|
|||
681 | if c.startswith(cmd): |
|
|||
682 | cmd = c |
|
|||
683 | break |
|
|||
684 | else: |
|
|||
685 | cmd = aliases[0] |
|
|||
686 | return (cmd, name, mod) |
|
|||
687 |
|
||||
688 | ext = None |
|
688 | ext = None | |
689 | # first, search for an extension with the same name as the command |
|
689 | # first, search for an extension with the same name as the command | |
690 | path = paths.pop(cmd, None) |
|
690 | path = paths.pop(cmd, None) | |
691 | if path: |
|
691 | if path: | |
692 | ext = findcmd(cmd, cmd, path) |
|
692 | ext = _finddisabledcmd(ui, cmd, cmd, path, strict=strict) | |
693 | if not ext: |
|
693 | if not ext: | |
694 | # otherwise, interrogate each extension until there's a match |
|
694 | # otherwise, interrogate each extension until there's a match | |
695 | for name, path in paths.iteritems(): |
|
695 | for name, path in paths.iteritems(): | |
696 | ext = findcmd(cmd, name, path) |
|
696 | ext = _finddisabledcmd(ui, cmd, name, path, strict=strict) | |
697 | if ext: |
|
697 | if ext: | |
698 | break |
|
698 | break | |
699 | if ext: |
|
699 | if ext: |
General Comments 0
You need to be logged in to leave comments.
Login now