Issue #1347 resolved

Add support for pre-<command> and post-<command> hooks

Kyle Michel
created an issue

I have a couple of these types of hooks in an extension that I am working on and they don't fire from tortoise workbench. I assume this is because they are wired up uisetup and not reposetup in the extension. It would be an added bonus to not require my users to run certain commands (specifically revert) from the command line.

Comments (17)

  1. Steve Borho
    • changed status to open

    These hooks would fire correctly if wctxactions ran the revert and other commands through a proper thg command runner rather than calling commands.revert(). This has been on the TODO list since before 2.0, but hasn't been finished.

  2. Nathan Durnan

    I am having a nearly identical headache with the pre-/post- hooks and the Revert commands. And am trying to add Revert support into my TimestampMod extension and am hitting the same limitation. I have my hooks fully functional within Mercurial, just not the TortoiseHg workbench. I am using the uisetep method as follows:

    def uisetup(ui):
    	ui.setconfig("hooks", "post-revert.TimestampMod", Hook_Post_Revert)
    
    def Hook_Post_Revert(repo, **kwargs):
    	repo.ui.note("TimestampMod|Post-Revert Hook accessed!\n")
    	#...code goes here...
    

    I have the following settings in my Mercurial.ini file:

    [extensions]
    TimestampMod= C:\Program Files\TortoiseHg\Extensions\TimestampMod.py
    [hooks]
    post-revert.TimestampMod = python:C:\Program Files\TortoiseHg\Extensions\TimestampMod\TimestampMod.py:Hook_Post_Revert
    

    The '[hooks]" section is not needed for it to work with Mercurial, but it is an attempt to get it to play nice with TortoiseHg. And it ALMOST works. I can get the Post-Revert hook code to work from TortoiseHg from the Windows Explorer "TortoiseHg > Revert Files..." context menu item. However, it does not seem to trigger at all from any of the other "Revert Files..." or "Revert to Revision..." commands such as from the Revision Details, Commit, or Manifest widgets, the File History viewer, etc.

    I haven't been able to figure out the difference between how Revert is handled from them Windows Explorer menu vs. the TortoiseHg widgets, but whatever method the Windows Explorer context menu is using seems to be more correct. Hope that helps point the team in the right direction and speed up a resolution for this issue.

  3. Log in to comment