I'm using mercurial's pre-commit hook to write out some information to a file inside the repo.
If the commit fails/aborts (like when the user doesn't enter a commit message), I want the file to be removed.
I considered using the post-commit hook, but when I put the following code in the post-commit hook, it doesn't appear to run for an aborted commit:
post-commit = export | grep "export HG_"
Is there a better way to do this than to create a user alias (cmt)that checks the exit result of the hg commit and then use that instead of the commit command? The reason I ask is b/c I'm trying to write some triggers to help my coding team, but don't want to force them to use an alias in place of the standard commands (can't really enforce this easily; can't overload the commit either as an alias it seems or will be stuck in an infinite loop):
[hook]
pre-commit = echo "some info to a file" > info.out ;
[alias]
cmt = ! $HG commit "${HG_ARGS[@]:4}" ; if (($?)); then rm info.out ; fi