Mercurial > hg
changeset 28312:24f1d3c70c41
extensions: copy extra __dict__ of original function
Future patches will make @command decorator set properties such as "norepo" to
a function object. This patch makes sure these properties never be lost by
wrapcommand() or wrapfunction().
This change won't be crazy as the standard functools.wraps() copies __dict__.
author | Yuya Nishihara <yuya@tcha.org> |
---|---|
date | Sat, 09 Jan 2016 20:04:03 +0900 |
parents | 1b0ef07ba783 |
children | aa73d6a5d9ea |
files | mercurial/extensions.py |
diffstat | 1 files changed, 1 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/mercurial/extensions.py Sat Jan 09 19:52:55 2016 +0900 +++ b/mercurial/extensions.py Sat Jan 09 20:04:03 2016 +0900 @@ -199,6 +199,7 @@ '''Copy attributes to wrapper function''' wrap.__module__ = getattr(origfn, '__module__') wrap.__doc__ = getattr(origfn, '__doc__') + wrap.__dict__.update(getattr(origfn, '__dict__', {})) def wrapcommand(table, command, wrapper, synopsis=None, docstring=None): '''Wrap the command named `command' in table