I have a java project in NetBeans and im using Mercurial for version controlling. I want to see my project version number in about box and i want it to be updated according to Mercurial revision number. Any ideas how to do it? :)
Asked
Active
Viewed 4,192 times
2 Answers
5
Following 'Version numbering for auto builds with Mercurial', you can record in a VERSION.TXT file (that you about dialog would display) the result of:
hg log -r . --template '{latesttag}-{latesttagdistance}-{node|short}'
log will be a lot better (and correct) with:
hg log -r tip --template "{latesttag}.{latesttagdistance}"
You have more options in "How good is my method of embedding version numbers into my application using Mercurial hooks?"
version_gen.sh
with:
hg parent --template "r{node|short}_{date|shortdate}" > version.num
In the makefile, make sure
version_gen.sh
is run beforeversion.num
is used to set the version parameter.
-
Example of a `version_gen.sh` script: https://bitbucket.org/artbugorski/postmed/src/tip/util/version_gen.sh – VonC Nov 05 '12 at 13:06
-
log will be a lot better (and correct) with `hg log -r tip --template "{latesttag}.{latesttagdistance}"` – Lazy Badger Nov 05 '12 at 13:51
-
@LazyBadger ok, I have included it in the answer for more visibility. – VonC Nov 05 '12 at 13:54
-
1I have a need to get this (programmatically) from a given branch, so I used `hg log -l 1 -b
--template "{node}\n"` – Dav Clark Jul 12 '14 at 19:19
0
If Windows, MercurialRev ("SubWCRev for Mercurial") may be useful also
Replaces revision information in a tagged text file.
MercurialRev <SourceFile> <DestinationFile> <RepositoryPath>
Tags:
<$HG:REV_NUM$>
<$HG:REV_LMOD_N$>
<$HG:REV_LMOD_P$>
<$HG:REV_ID$>
<$HG:BRANCH$>
<$HG:TAG$>

Lazy Badger
- 94,711
- 9
- 78
- 110