Reputation: 17282
I have application I want to print out (in "about" box) its revision/version from mercurial. Suppose it is revision deadbeef
so it will know that. In old times in CVS could use something like $Revision$
to substitute automatically.
What is best practice with Mercurial for this?
Upvotes: 3
Views: 98
Reputation: 8543
Mercurial's Keyword Extension is probably what you want. It supports the $Revision$
format pretty much exactly.
Upvotes: 1
Reputation: 156278
The best approach is probably to use precommit hook to replace a designated file with the output of hg log -r tip
, possibly with a --template
arg to format it in a particular way.
Unfortunately, there's a bit of a chicken and egg problem. The revision is a checksum of the commited data, but the checksum is not available until after the commit has taken place. One option might be to actually hook on commit instead of precommit, and commit the version info in a seperate changeset.
Upvotes: 5
Reputation: 9132
You can use this to get the current revision in mercurial:
hg id -i
Upvotes: 2