D472: extensions: make wrapfunction() return a context manager
mjpieters (Martijn Pieters)
phabricator at mercurial-scm.org
Wed Aug 23 13:32:29 UTC 2017
mjpieters added inline comments.
INLINE COMMENTS
> extensions.py:408-412
> + origfn = getattr(container, funcname)
> + assert callable(origfn)
> + wrap = bind(wrapper, origfn)
> + _updatewrapper(wrap, origfn, wrapper)
> + setattr(container, funcname, wrap)
Move this to `__enter__`. You want to be able to create the context manager separately from actually entering the context:
cmwrapper = wrapfunction(cont, 'name', wrapper)
# do other things, `cont.name` is *not* wrapped
with cmwrapper:
# `cont.name` is wrapped
REPOSITORY
rHG Mercurial
REVISION DETAIL
https://phab.mercurial-scm.org/D472
To: martinvonz, #hg-reviewers, quark
Cc: quark, mjpieters, mercurial-devel
More information about the Mercurial-devel
mailing list