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

只愿长相守 提交于 2019-12-10 07:25:56

问题


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


回答1:


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.




回答2:


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$>


来源:https://stackoverflow.com/questions/13232469/how-to-get-revision-number-from-mercurial-repository-and-paste-it-to-netbeans-re

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!