views:

115

answers:

1

I want a mercurial hook that will run JSLint/PyChecker/etc on all files that are modified. However, I do not have control over all hg clients, and want this to run on push to the master repository (which I have control), so a pretxnchangegroup hook on the master seems best.

How can I get a list of all changesets that are in the changegroup that is going to be committed?

I have seem other solutions that use a precommit hook, but these will not work for me because the clients may already have a commit that fails JSLint. In this case, they should be able to fix the errors in a new commit, and be able to push (both the bad and new commits) to the server successfully. The server just needs to check the most recent changeset on each branch, of every file that was modified in the changegroup.

+1  A: 

You're right that you want a pretxnchangegroup hook, but you don't want to check all the new revisions -- because people will fix the errors you reject in subsequent changesets but if you're checking all changesets their work will never be accepted!

Instead either just check all files in all the heads, or use the hg status --rev x:y syntax to get a list of the changed files between the revision you already have and the tip revision you're receiving, and check only those files only in the tip revision.

If you really want the list of all revisions you'd use a revset ( hg help revsets ) new in version 1.6, but you really only want to check the results, not all the revisions that get you there.

Ry4an
Right- I only want to check the heads, but I want to check the head of each file that was modified in the changeset, because a file may have been modified, but not in the head.Using `hg status --rev x:y`, how do I find `x` and `y`? the hook only seems to tell me `y`. Also, this seems to output every change between those dates? This includes commits by other people, not just the commits in the changegroup
Knio
X would be the last change set you do already had in that branch (be it named branch or anonymous branch). You could get that from a local clone created pre-changegroup and the union operator on the revsets feature.Honestly, though you should do what everyone does and just check all the .py files in each `hg heads` on changegreoup. It's not too inefficient. Either code the code the heads is good or bad, and code in the interstitial changesets is either still present in a head for checking or was removed/fixed and is thus no concern.
Ry4an
We have about 1000 js/py files and running the script on every file for every head would be way too slow
Knio