【问题标题】:How to get revision number from Mercurial repository and paste it to NetBeans resource bundle?如何从 Mercurial 存储库获取修订号并将其粘贴到 NetBeans 资源包?
【发布时间】:2012-11-05 12:49:21
【问题描述】:

我在 NetBeans 中有一个 java 项目,我使用 Mercurial 进行版本控制。 我想在 about 框中查看我的项目版本号,并且我希望它根据 Mercurial 修订号进行更新。 任何想法如何做到这一点? :)

【问题讨论】:

    标签: netbeans mercurial versioning resourcebundle


    【解决方案1】:

    在“Version numbering for auto builds with Mercurial”之后,您可以在 VERSION.TXT 文件中记录以下结果:

    hg log -r . --template '{latesttag}-{latesttagdistance}-{node|short}'
    

    Lazy Badgercomments:

    日志会更好(和正确):

    hg log -r tip --template "{latesttag}.{latesttagdistance}"
    

    How good is my method of embedding version numbers into my application using Mercurial hooks?”中有更多选择

    version_gen.sh 与:

     hg parent --template "r{node|short}_{date|shortdate}" > version.num
    

    在makefile中,确保version_gen.shversion.num用于设置版本参数之前运行。

    【讨论】:

    • 使用hg log -r tip --template "{latesttag}.{latesttagdistance}"的日志会好很多(而且正确)
    • @LazyBadger 好的,我已将其包含在答案中以获得更多可见性。
    • 我需要从给定的分支中(以编程方式)获取它,所以我使用了hg log -l 1 -b <branchname> --template "{node}\n"
    【解决方案2】:

    如果是 Windows,MercurialRev(“SubWCRev for Mercurial”)也可能有用

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2010-10-12
      • 1970-01-01
      • 1970-01-01
      • 2011-12-03
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多