I'm in the process of writing a mercurial changegroup hook. I don't have everything figured out yet, but the process of trial and error is made more painful by the fact that I have to keep committing and pushing just to test my work in progress.
Is there any way to 'fake' a trigger to execute my changegroup hook with the current status of the repository to be used for it's parameters?
Any help to streamline this process would be very much appreciated. Thanks Nick
I'm afraid there's no built-in debugging capabilities for this. What I do when writing a hook is to setup two local repositories:
$ hg init repo
$ hg clone repo clone
and then configure the changegroup
hook in repo
. Now go into clone
and do
$ echo a > a
$ hg add a
$ hg commit -m 'a file'
to setup clone
. Every time I want to check the hook, I run
$ hg push; hg -R ../repo rollback
inside clone
. I keep that in my command line history so that I can just press ↑ + Return to execute it again and again. The hg rollback
is the key: is effectively cancels the hg push
so that I can repeat it again and again.
You will of course need to adjust this as needed for your hook. If the hook checks the committer name, then use hg commit -u someone
to set this as needed. If the hook needs more than one changeset in the changegroup, then make two or more commits before pushing — rollback will take care of removing all the pushed changesets. If the hook is run by hgweb
, then run
$ hg serve --config 'web.push_ssl=no' --config 'web.allow_push=*'
in one terminal to serve repo
while you push to it in another terminal.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With