mercurial/extensions.py
changeset 28310 01dc11e7191f
parent 28155 7f430b2ac7fd
child 28311 1b0ef07ba783
--- 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