Search code examples
netbeansmercurialversioningresourcebundle

How to get revision number from Mercurial repository and paste it to NetBeans resource bundle?


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? :)


Solution

  • 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}'
    

    Lazy Badger comments:

    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 before version.num is used to set the version parameter.