precommit hook that changes commit list?

Nicholas Tung ntung at ntung.com
Wed Sep 24 12:49:52 CDT 2008


On Sat, Sep 6, 2008 at 6:23 PM, Nicholas Tung <ntung at ntung.com> wrote:

> On Sat, Sep 6, 2008 at 5:45 PM, Giorgos Keramidas <
> keramida at ceid.upatras.gr> wrote:
>
>> On Sat, 6 Sep 2008 16:33:18 -0700, "Nicholas Tung" <ntung at ntung.com>
>> wrote:
>> >On Sat, Sep 6, 2008 at 6:25 AM, Giorgos Keramidas wrote:
>> >>On Sat, 6 Sep 2008 01:32:56 -0700, Nicholas Tung wrote:
>> >>> Hello,
>> >>> I have a precommit hook script that will compile a LaTeX file before
>> >>> committing. I know some people feel storing generated files is messy,
>> >>> but with the web server, it's just too convenient. Is there a way to
>> >>> make Mercurial rescan the commit list to see that this generated file
>> >>> has changed before it commits?
>> >>
>> >> Not really.  Even if there was `changing' a commit on the fly is not
>> >> possible without modifying the changeset hashes and altering the repo
>> >> history.
>> >
>> > I take it the changeset hashes only has file names, not content?
>> > Because if the file is modified and will be committed, then it can be
>> > changed by the pre-commit hook.
>>
>> No the hash includes much more details (including file contents).
>
>
> But it's still okay for the pre-commit hook to modify it? I did and didn't
> run into problems.
>
>>
>>
>> >> Why don't you build the files right _after_ commits?  If you have a
>> >> build script called `mybuild.sh' then something like this would work:
>> >>
>> >>    [hooks]
>> >>    changegroup = /home/keramida/tools/mybuild.sh
>> >>    commit = /home/keramida/tools/mybuild.sh
>> >>    # To rebuild after every "hg update" too, add:
>> >>    # update = /home/keramida/tools/mybuild.sh
>> >
>> > The point is not for users downloading the repository to get an
>> > updated generated file, but for the version on the web interface to be
>> > current (i.e.  what's in the repository).
>>
>> I got that.  You can install hooks in *remote* repositories too.  When
>> you push a change over the wire, the hooks will still trigger.
>
>
> Okay, neat, thanks. If I ever set up something larger, this would
> definitely be useful. However, this time, I just wanted one local repo,
> which I'm using hg serve -d with.
>

I think I actually found a solution to my problem: use "pre-commit" instead
of "precommit". This will run completely before the command, so any updated
files will get reflected in the "list" of changed files.

cheers,
Nicholas
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://selenic.com/pipermail/mercurial/attachments/20080924/c91fbee7/attachment.htm 


More information about the Mercurial mailing list