mercurial/extensions.py
changeset 21795 711498bb4ff5
parent 21229 54d7657d7d1e
child 21848 ecdbbb6e5d06
equal deleted inserted replaced
21794:753af9ee7c81 21795:711498bb4ff5
   136       wrapper(orig, *args, **kwargs)
   136       wrapper(orig, *args, **kwargs)
   137 
   137 
   138     where orig is the original (wrapped) function, and *args, **kwargs
   138     where orig is the original (wrapped) function, and *args, **kwargs
   139     are the arguments passed to it.
   139     are the arguments passed to it.
   140     '''
   140     '''
   141     assert util.safehasattr(wrapper, '__call__')
   141     assert callable(wrapper)
   142     aliases, entry = cmdutil.findcmd(command, table)
   142     aliases, entry = cmdutil.findcmd(command, table)
   143     for alias, e in table.iteritems():
   143     for alias, e in table.iteritems():
   144         if e is entry:
   144         if e is entry:
   145             key = alias
   145             key = alias
   146             break
   146             break
   189     In general, combining wrapfunction() with subclassing does not
   189     In general, combining wrapfunction() with subclassing does not
   190     work. Since you cannot control what other extensions are loaded by
   190     work. Since you cannot control what other extensions are loaded by
   191     your end users, you should play nicely with others by using the
   191     your end users, you should play nicely with others by using the
   192     subclass trick.
   192     subclass trick.
   193     '''
   193     '''
   194     assert util.safehasattr(wrapper, '__call__')
   194     assert callable(wrapper)
   195     def wrap(*args, **kwargs):
   195     def wrap(*args, **kwargs):
   196         return wrapper(origfn, *args, **kwargs)
   196         return wrapper(origfn, *args, **kwargs)
   197 
   197 
   198     origfn = getattr(container, funcname)
   198     origfn = getattr(container, funcname)
   199     assert util.safehasattr(origfn, '__call__')
   199     assert callable(origfn)
   200     setattr(container, funcname, wrap)
   200     setattr(container, funcname, wrap)
   201     return origfn
   201     return origfn
   202 
   202 
   203 def _disabledpaths(strip_init=False):
   203 def _disabledpaths(strip_init=False):
   204     '''find paths of disabled extensions. returns a dict of {name: path}
   204     '''find paths of disabled extensions. returns a dict of {name: path}