将subversion版本库号转换为代码 [英] Getting the subversion repository number into code

查看:135
本文介绍了将subversion版本库号转换为代码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想实现一种在代码中记录项目版本的方法,以便在测试时可以使用它来帮助跟踪错误。
似乎最好使用的版本号只是Subversion当前的版本号。有没有一个简单的方法来将这个数字挂起(C ++在我的情况下)头文件或某些东西,我可以在代码中得到?我想这是一个提交提交钩子或什么东西?

I'd like to implement a way of recording the version of a project within code, so that it can be used when testing and to help track bugs. It seems the best version number to use would just be the current revision number from Subversion. Is there an easy way to hook this number into a (C++ in my case) header file or something, which I can then get at in code? I guess this is a post commit hook or something?

有没有人有任何实现这个经验(有代码分享,请?),或者可以建议一个更好的选择?
谢谢。

Does anyone have any experience of implementing this (with code to share, please?), or can suggest a better alternative? Thanks.

推荐答案

虽然漂亮,修订关键字技巧只能在该修订版本中更改文件 - if您不会更改文件,那么它将继续反映旧版本。

While nifty, the revision keyword trick only updates the file when it's changed in that revision - if you don't change the file, then it will continue to reflect the old revision.

如果您希望软件始终反映整体版本号,那么您将必须深入了解相关的SVN条目文件,并将其解压缩,这是太难了(这是一个XML文件)。

If you want the software to always reflect the overall revision number, then you'll have to delve into the relevant SVN entries file and extract it, which isn't too difficult (it's an XML file).

维基百科在他们的版本页面来表示正在运行的软件的修订; 代码在这里 - 寻找 getSvnRevision()方法。

Wikipedia does this on their version page to indicate the revision of the software that's running live; the code is here - look for the getSvnRevision() method.

这篇关于将subversion版本库号转换为代码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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