D472: extensions: make wrapfunction() return a context manager

quark (Jun Wu) phabricator at mercurial-scm.org
Wed Aug 23 11:44:40 EDT 2017


quark added inline comments.

INLINE COMMENTS

> mjpieters wrote in extensions.py:408-412
> 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

The point is `wrapfunction` is also intended to work with non-context case:

  wrapfunction(x, y, z) # works and should have immediate side effect

REPOSITORY
  rHG Mercurial

REVISION DETAIL
  https://phab.mercurial-scm.org/D472

To: martinvonz, #hg-reviewers, quark, mjpieters
Cc: quark, mjpieters, mercurial-devel


More information about the Mercurial-devel mailing list