Patchwork [2,of,4] extensions: copy attributes to wrapper by wrapfunction()

login
register
mail settings
Submitter Yuya Nishihara
Date Feb. 28, 2016, 6:55 a.m.
Message ID <a1c6174f988efe8b3dfa.1456642541@mimosa>
Download mbox | patch
Permalink /patch/13451/
State Accepted
Headers show

Comments

Yuya Nishihara - Feb. 28, 2016, 6:55 a.m.
# HG changeset patch
# User Yuya Nishihara <yuya@tcha.org>
# Date 1452336775 -32400
#      Sat Jan 09 19:52:55 2016 +0900
# Node ID a1c6174f988efe8b3dfa200fbbe6a5a7de51268a
# Parent  f2cbcdf4d88896db8a36282f3254173afe9e0059
extensions: copy attributes to wrapper by wrapfunction()

Before this patch, new partial function "wrap" had no useful docstring. It
makes sense to copy __doc__ and __module__ as we do for wrapcommand().

Patch

diff --git a/mercurial/extensions.py b/mercurial/extensions.py
--- a/mercurial/extensions.py
+++ b/mercurial/extensions.py
@@ -286,7 +286,9 @@  def wrapfunction(container, funcname, wr
 
     origfn = getattr(container, funcname)
     assert callable(origfn)
-    setattr(container, funcname, bind(wrapper, origfn))
+    wrap = bind(wrapper, origfn)
+    _updatewrapper(wrap, origfn)
+    setattr(container, funcname, wrap)
     return origfn
 
 def _disabledpaths(strip_init=False):