Several extensions exist that temporarily want to wrap a function (at
least narrowhg, any many of the extensions in hg-experimental). That's
why we have the unwrapfunction() that was introduced in 19578bb84731
(extensions: add unwrapfunction to undo wrapfunction, 2016-08-10).
This patch adds a simple wrappedfunction() that returns a context
manager.
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