(extensions) Is it possible to add hook dynamically under TortoiseHg?

Marcin Kasperski Marcin.Kasperski at mekk.waw.pl
Thu Apr 21 23:04:11 UTC 2016


I am trying to get mercurial_update_version working under TortoiseHg.
The extension works by adding pre-tag hook and, as suggested by wiki
docs, it does it from ui.setup. Nothing special:

    def uisetup(ui):
        ui.setconfig("hooks", "pre-tag.update_version", pre_tag_hook)

Under „normal Mercurial” it works nicely.
Under TortoiseHg - it does not.

uisetup is being called, but seems to have no impact (hook is not enabled)

I tried looking around the code, and noted two things:

a) ui given to uisetup is in fact „lui” variable, which is effectively 
   thrown away afterwards (see hgqt/run.py:runcommand:
 https://bitbucket.org/tortoisehg/thg/src/32ea32c53b34663e8497e57d982d948249794ba1/tortoisehg/hgqt/run.py?at=default&fileviewer=file-view-default#run.py-312 
   and note that actual commands use ui passed to checkedfunc)

b) even if this was worked around somehow, actual command is spawned via
   cmdserver, in separate process.

Is it possible to work it around somehow? I suppose I could get my
effects via some brute monkeypatching (wrapping tag?), but would be
great to find less invasive way…



More information about the Mercurial mailing list