extensions: add a few assertions to wrapfunction() and wrapcommand().
Specifically, assert that the given wrapper is callable in both
functions, and assert that the original was also callable in
wrapfunction().
--- a/mercurial/extensions.py Fri Jul 09 11:13:45 2010 +0200
+++ b/mercurial/extensions.py Fri Jul 09 11:04:00 2010 +0200
@@ -116,6 +116,7 @@
where orig is the original (wrapped) function, and *args, **kwargs
are the arguments passed to it.
'''
+ assert hasattr(wrapper, '__call__')
aliases, entry = cmdutil.findcmd(command, table)
for alias, e in table.iteritems():
if e is entry:
@@ -168,10 +169,12 @@
your end users, you should play nicely with others by using the
subclass trick.
'''
+ assert hasattr(wrapper, '__call__')
def wrap(*args, **kwargs):
return wrapper(origfn, *args, **kwargs)
origfn = getattr(container, funcname)
+ assert hasattr(origfn, '__call__')
setattr(container, funcname, wrap)
return origfn