我使用 Mercurial 钩子将版本号嵌入到我的应用程序中的方法有多好? [英] How good is my method of embedding version numbers into my application using Mercurial hooks?

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

问题描述

这不是一个很具体的问题,我更喜欢批评我目前的方法.

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.

我的方法如下:

  1. 我的 .hg/hgrc 文件链接到 version_gen.sh 中有一个预提交"钩子
  2. version_gen.sh 仅包含:hg parent --template "r{rev}_{date|shortdate}" >版本号
  3. 在 makefile 中,主脚本中的 version="%__VERSION__% 行替换为 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.

有没有更好的方法来做到这一点?我可以看到唯一真正的缺点是,如果你只提交一个特定的文件,version.num 将被更新,但它不会被提交,如果我试图添加总是提交该文件,这将导致无限循环(除非我创建了一些临时文件来表明我已经在提交中,但这看起来很难看......).

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

推荐答案

你要做的就是所谓的关键字扩展,而不是 Mercurial 核心支持.

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

您可以将该扩展集成到 make 文件,或者(更简单)与 关键字扩展.

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

此扩展允许在 Mercurial 跟踪的文本文件中扩展 RCS/CVS 类和用户定义的键.
扩展发生在工作目录中或/和使用hg archive"

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"

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

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