有多好是我的嵌入版本号为使用水银钩我的应用程序的方法是什么? [英] How good is my method of embedding version numbers into my application using Mercurial hooks?

查看:121
本文介绍了有多好是我的嵌入版本号为使用水银钩我的应用程序的方法是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是不是相当specifc问题,我更喜欢我目前的做法的批评。

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:


  1. 有一个在我的.hg / hgrc文件链接一个pre-承诺钩version_gen.sh

  2. version_gen.sh只包括:
    汞父--templateR {}转_ {日期| shortdate}> version.num

  3. 在生成文件中,该行版本=%__ __版本%在主脚本被替换为version.num文件的内容。

  1. There is a "pre-commit" hook in my .hg/hgrc file link to version_gen.sh
  2. version_gen.sh consists solely of: hg parent --template "r{rev}_{date|shortdate}" > version.num
  3. In the makefile, the line version="%__VERSION__% in the main script is replaced with the content of the version.num file.

是否有这样做的更好的方法?唯一真正的未来很短的我可以看到的是,如果你只犯了specfic文件,version.num将被更新,但它不会被COMMITED,如果我试图随时添加提交该文件,这将导致infite循环(除非我创建了一些临时文件,以表明我已经在提交,但似乎丑陋的...)。

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

推荐答案

你所试图做的是所谓的关键字扩展,这不是的在水银核心支持。

What you are trying to do is called Keyword Expansion, which is not supported in Mercurial core.

您可以集成到使文件,或(简单)的 关键字扩展

You can integrate that expansion in make file, or (simpler) with the Keyword extension.

这个扩展可以让RCS / CVS样,并通过水银跟踪文本文件的用户定义键的扩​​张。结果
  扩张发生在工作目录,或/和创建使用分布时,汞存档

This extension allows the expansion of RCS/CVS-like and user defined keys in text files tracked by Mercurial.
Expansion takes place in the working directory or/and when creating a distribution using "hg archive"

这篇关于有多好是我的嵌入版本号为使用水银钩我的应用程序的方法是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆