D4820: logtoprocess: sends the canonical command name to the subprocess

yuja (Yuya Nishihara) phabricator at mercurial-scm.org
Wed Oct 3 13:04:14 UTC 2018


yuja added a comment.


  > +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)
  
  It's scary to update the environment variables globally and pass
  `LTP_COMMAND` in to any child processes.
  
  Can you add a proper way to teach the command name to the logtoprocess
  extension, by `ui.log()` for example?
  
  Also, the word `LTP` isn't used anywhere. It'll need a better name, and
  should be documented.

REPOSITORY
  rHG Mercurial

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

To: lothiraldan, #hg-reviewers
Cc: yuja, mercurial-devel


More information about the Mercurial-devel mailing list