Search code examples
mercurialhooktortoisehgmercurial-hook

How to get TortoiseHG to perform a pre-diff action


I have a pre-diff hook in my hg setup but it is not being executed when I try to commit my changes.

What I'm trying to do is generate the database schema file before commit so that it will appear in the list of changes.

I also have an update hook which works fine. Is TortoiseHG not performing an hg diff command? Which hook could I use instead?


Solution

  • TortoiseHg (as of v2.1.4) performs diffs in at least 3 ways, none of which use a raw hg diff command:

    1. In the "Revision Details" window of the Workbench, there is a file-level unified diff shown. This diff is obtained through mdiff.unidiff method in mdiff.py. This method bypasses the hook mechanism.
    2. If a changeset (or range of changesets) is selected in the revision graph, the user can ask for a "Visual Diff". This method copies the files from the selected revisions to a temporary directory and then compares them with an external visual diff tool. This method also bypasses the hook mechanism.
    3. In the "Manifest" view, you can select a file, right-click and "Compare file revisions". This uses a custom visual diff utility which also bypasses the hook mechanism.

    As far as I know, TortoiseHg does not expose any hooks for its diff mechanism.