Adding custom data to commit msg

Gavin Barrett Gavin.Barrett at cgu.com.au
Tue Nov 2 22:32:24 UTC 2010


_______________________________________________________________________________________

Note: This e-mail is subject to the disclaimer contained at the bottom of this message.
_______________________________________________________________________________________


Another option is to write a pretxncommit hook that checks the format of the commit message
to see if the requirement id has been prepended to the message and fail the transaction
if it hasn't.  If you're developers are using TortoiseHg, then something worth looking
at is the "issue tracking" feature that allows you to put in a simple regular expression
to each developers desktop that checks that their commit message starts with a specified
format.  If  you set the "mandatory issue reference" to true, then their transaction is
cancelled if it doesn't meet the specified format".  From the commit dialog click
"Tools->Settings->Issue Tracking".

-----Original Message-----
From: mercurial-bounces at selenic.com [mailto:mercurial-bounces at selenic.com] On Behalf Of Greg Ward
Sent: Tuesday, 2 November 2010 1:41 PM
To: quarterlife
Cc: mercurial
Subject: Re: Adding custom data to commit msg

[inapproprate question for mercurial-devel, so I'm redirecting to
mercurial list]

On Mon, Nov 1, 2010 at 10:09 PM, quarterlife <chaim.ackerman at gmail.com> wrote:
> Our developers work in private repos that contain the requirement_id in its
> name.
> I can ask them to always add the requirement_id in their commit messages,
> but it's error prone.
> I'd like to have it automatically prepended into their commit messages, so
> that the requirement can be tracked as it's changesets are pushed to various
> repos.  Is there a way to add a hook to the commit (e.g. pretxncommit) to
> automatically prepend it?  Or is there another approach that will accomplish
> the same thing.

Alas, no: by the time a pretxncommit hook runs, the changeset ID has
been computed, and that's the SHA-1 hash of various data including the
commit message.  All you can do in pretxncommit is accept or reject
the commit.

If you try to do it earlier, in precommit, that runs too early: hg
doesn't necessarily even have the commit message yet.  (If it's going
to run the user's editor, it has not done so.)

AFAIK the only solution here is to write an extension.  The good news
is that extensions give you awesome power over a huge range of
Mercurial's internals; the bad news is that those internals can change
from release to release, forcing you to keep your extension
up-to-date.

Greg
_______________________________________________
Mercurial mailing list
Mercurial at selenic.com
http://selenic.com/mailman/listinfo/mercurial
_______________________________________________________________________________________

The information transmitted in this message and its attachments (if any) is intended 
only for the person or entity to which it is addressed.
The message may contain confidential and/or privileged material. Any review, 
retransmission, dissemination or other use of, or taking of any action in reliance 
upon this information, by persons or entities other than the intended recipient is 
prohibited.

If you have received this in error, please contact the sender and delete this e-mail 
and associated material from any computer.

The intended recipient of this e-mail may only use, reproduce, disclose or distribute 
the information contained in this e-mail and any attached files, with the permission 
of the sender.

This message has been scanned for viruses.
_______________________________________________________________________________________



More information about the Mercurial mailing list