# HG changeset patch # User Yuya Nishihara # Date 1452336310 -32400 # Node ID 01dc11e7191f6abc1f392f4349e061a2b730320c # Parent 7c22b5bb3a035361ab740e180d4a645e856f74e7 extensions: extract function that copies function attributes to wrapper wrapfunction() will be changed to copy these attributes. See the next patch for details. diff -r 7c22b5bb3a03 -r 01dc11e7191f mercurial/extensions.py --- a/mercurial/extensions.py Mon Feb 29 23:28:32 2016 +0000 +++ b/mercurial/extensions.py Sat Jan 09 19:45:10 2016 +0900 @@ -195,6 +195,11 @@ return func(*(args + a), **kw) return closure +def _updatewrapper(wrap, origfn): + '''Copy attributes to wrapper function''' + wrap.__module__ = getattr(origfn, '__module__') + wrap.__doc__ = getattr(origfn, '__doc__') + def wrapcommand(table, command, wrapper, synopsis=None, docstring=None): '''Wrap the command named `command' in table @@ -233,13 +238,9 @@ origfn = entry[0] wrap = bind(util.checksignature(wrapper), util.checksignature(origfn)) - - wrap.__module__ = getattr(origfn, '__module__') - - doc = getattr(origfn, '__doc__') + _updatewrapper(wrap, origfn) if docstring is not None: - doc += docstring - wrap.__doc__ = doc + wrap.__doc__ += docstring newentry = list(entry) newentry[0] = wrap