diff --git a/hgext/logtoprocess.py b/hgext/logtoprocess.py --- a/hgext/logtoprocess.py +++ b/hgext/logtoprocess.py @@ -40,6 +40,9 @@ import sys from mercurial import ( + dispatch, + encoding, + extensions, pycompat, ) @@ -53,6 +56,19 @@ # leave the attribute unspecified. testedwith = 'ships-with-hg-core' +def extsetup(): + # this is to get the canonical name of the command: "commit", not "ci" + def wrapdispatch(orig, *args, **kwargs): + encoding.environ.pop("LTP_COMMAND", None) + return orig(*args, **kwargs) + + def wrapruncommand(orig, *args, **kwargs): + encoding.environ["LTP_COMMAND"] = args[2] + return orig(*args, **kwargs) + + extensions.wrapfunction(dispatch,'dispatch',wrapdispatch) + extensions.wrapfunction(dispatch,'runcommand',wrapruncommand) + def uisetup(ui): if pycompat.iswindows: # no fork on Windows, but we can create a detached process