How good is my method of embedding version numbers into my application using Mercurial hooks?
Posted
by ArtB
on Stack Overflow
See other posts from Stack Overflow
or by ArtB
Published on 2010-04-01T06:29:34Z
Indexed on
2010/04/01
6:33 UTC
Read the original article
Hit count: 296
This is not quite a specifc question, and more me like for a criticism of my current approach.
I would like to include the program version number in the program I am developing. This is not a commercial product, but a research application so it is important to know which version generated the results.
My method works as follows:
- There is a "pre-commit" hook in my .hg/hgrc file link to .hg/version_gen.sh
- version_gen.sh consists solely of:
hg parent --template "r{rev}_{date|shortdate}" > version.num
- In the makefile, the line
version="%__VERSION__%
in the main script is replaced with the content of the version.num file.
Are there better ways of doing this? The only real short coming I can see is that if you only commit a specfic file, version.num will be updated, but it won't be commited, and if I tried to add always committing that file, that would result in an infite loop (unless I created some temp file to indicate I was already in a commit, but that seems ugly...).
© Stack Overflow or respective owner