I'm trying to create a Mercurial repository with a changegroup or pretxnchangegroup hook that inspects the commit, possibly makes some changes to it, then commits the changes. My hook does something similar to this:
#!/bin/sh if ! grep -q foobar foobar; then echo foobar >> foobar hg add foobar hg commit -m 'added foobar to foobar' fi
But when I push to the remote repository which has the hook it hangs waiting on a lock and I have to kill it:
$ hg push pushing to /tmp/a searching for changes adding changesets adding manifests adding file changes added 1 changesets with 1 changes to 1 files foobar already tracked! waiting for lock on repository /tmp/a held by 'duck:18140' ^Ctransaction abort! rollback completed interrupted! interrupted!
This makes sense because I understand that the changegroup must hold a write lock on the repository, and so must the commit that is inside of the hook. But how can I work around this problem?
I can think of two methods that might work, but don't know if they are possible:
- If there was a hook that runs after the changegroup is complete and the locks are released, I could run the commit there.
- Append a changeset to the incoming changegroup.