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 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...).