diff options
Diffstat (limited to 'mercurial/extensions.py')
-rw-r--r-- | mercurial/extensions.py | 38 |
1 files changed, 15 insertions, 23 deletions
diff --git a/mercurial/extensions.py b/mercurial/extensions.py index 3f74d4e..ee9fd32 100644 --- a/mercurial/extensions.py +++ b/mercurial/extensions.py @@ -42,12 +42,7 @@ def loadpath(path, module_name): fd, fpath, desc = imp.find_module(f, [d]) return imp.load_module(module_name, fd, fpath, desc) else: - try: - return imp.load_source(module_name, path) - except IOError, exc: - if not exc.filename: - exc.filename = path # python does not fill this - raise + return imp.load_source(module_name, path) def load(ui, name, path): # unused ui argument kept for backwards compatibility @@ -74,9 +69,7 @@ def load(ui, name, path): return mod try: mod = importh("hgext.%s" % name) - except ImportError, err: - ui.debug('could not import hgext.%s (%s): trying %s\n' - % (name, err, name)) + except ImportError: mod = importh(name) _extensions[shortname] = mod _order.append(shortname) @@ -131,7 +124,7 @@ def wrapcommand(table, command, wrapper): where orig is the original (wrapped) function, and *args, **kwargs are the arguments passed to it. ''' - assert util.safehasattr(wrapper, '__call__') + assert hasattr(wrapper, '__call__') aliases, entry = cmdutil.findcmd(command, table) for alias, e in table.iteritems(): if e is entry: @@ -184,12 +177,12 @@ def wrapfunction(container, funcname, wrapper): your end users, you should play nicely with others by using the subclass trick. ''' - assert util.safehasattr(wrapper, '__call__') + assert hasattr(wrapper, '__call__') def wrap(*args, **kwargs): return wrapper(origfn, *args, **kwargs) origfn = getattr(container, funcname) - assert util.safehasattr(origfn, '__call__') + assert hasattr(origfn, '__call__') setattr(container, funcname, wrap) return origfn @@ -279,7 +272,7 @@ def disabled(): paths = _disabledpaths() if not paths: - return {} + return None exts = {} for name, path in paths.iteritems(): @@ -306,7 +299,7 @@ def disabledext(name): def disabledcmd(ui, cmd, strict=False): '''import disabled extensions until cmd is found. - returns (cmdname, extname, module)''' + returns (cmdname, extname, doc)''' paths = _disabledpaths(strip_init=True) if not paths: @@ -334,19 +327,18 @@ def disabledcmd(ui, cmd, strict=False): cmd = aliases[0] return (cmd, name, mod) - ext = None # first, search for an extension with the same name as the command path = paths.pop(cmd, None) if path: ext = findcmd(cmd, cmd, path) - if not ext: - # otherwise, interrogate each extension until there's a match - for name, path in paths.iteritems(): - ext = findcmd(cmd, name, path) - if ext: - break - if ext and 'DEPRECATED' not in ext.__doc__: - return ext + if ext: + return ext + + # otherwise, interrogate each extension until there's a match + for name, path in paths.iteritems(): + ext = findcmd(cmd, name, path) + if ext: + return ext raise error.UnknownCommand(cmd) |