Mercurial > hg
diff hgext/factotum.py @ 29765:19578bb84731
extensions: add unwrapfunction to undo wrapfunction
Before this patch, we don't have a safe way to undo a wrapfunction because
other extensions may wrap the same function and calling setattr will undo
them accidentally.
This patch adds an "unwrapfunction" to address the issue. It removes the
wrapper from the wrapper chain, and re-wraps everything, which is not the
most efficient but short and easy to understand. We can revisit the code
if we have perf issues with long chains.
The "undo" feature is useful in cases like wrapping a function just in a
scope. Like, having a "select" command to interactively (using arrow keys)
select content from some output (ex. smartlog). It could wrap "ui.label" to
extract interesting texts just in the "select" command.
author | Jun Wu <quark@fb.com> |
---|---|
date | Wed, 10 Aug 2016 16:27:33 +0100 |
parents | 2c019aac6b99 |
children | 21b568820a3c |