将 svnversion 与 svn:keywords 一起使用 [英] Using svnversion with svn:keywords

查看:21
本文介绍了将 svnversion 与 svn:keywords 一起使用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在 Windows Box 上使用 Visual SVN.

I'm using Visual SVN on my Windows Box.

我有 Repository Application,它有 Framework 作为 svn:external.一切顺利.

I have Repository Application, which has Framework as an svn:external. All well and good.

当我结帐 Application 时,我希望将 ApplicationFramework 的版本包含在页脚文件中.这样我就可以有类似的东西:

When I make a checkout of Application, I'd like to have the version of Application and Framework for inclusion in a footer file. This way I could have something like:

Application Version $ApplicationVersion$, Framework Version $FrameworkVersion$

通常,我知道我可以使用 svn:keywords 并添加修订版 - 但据我所知,svn:keywords 是针对每个文件应用的.一些网站建议使用 svnversion 为每个变量生成输出,但我不完全确定如何进行.

Ordinarily, I understand I could use svn:keywords and add the revision - but as I understand it, svn:keywords apply on a per-file basis. A few sites have suggested using svnversion to produce the output for each variable, but I'm not entirely sure how to go about this.

再一次,在 Windows Box 上,使用 VisualSVN.我也会使用 Versions.app 在 Mac 上开发,如果它提供了一个更熟悉的界面供人们回答:)

Once again, on a Windows Box, using VisualSVN. I also develop on a Mac using Versions.app if it provides a more familiar interface for people to answer :)

编辑 - 我的应用程序是一个 PHP 网络应用程序.因此,没有编译.

Edit - my application is a PHP web application. As such, there is no compiling.

谢谢!

推荐答案

要使用 svnversion,您需要将其集成到构建过程中.如果你在 subversion checkout 上运行它,它会输出一个类似 73597:73598 的字符串,表明你的树有什么版本(注意不同的文件可能有不同的版本,加上文件也可能有本地修改).你把类似的东西

To use svnversion, you need to integrate it into the build process. If you run it on a subversion checkout, it will output a string like 73597:73598, indicating what version your tree has (notice that different files may have different versions, plus files may have also local modifications). You put something like

CFLAGS+=-DSVNVERSION="\"`svnversion`\""  

进入你的Makefile,然后放入

into your Makefile, and then put

#define VERSION_STRING "Application version" SVNVERSION ", Framework version" FRAMEWORK_VERSION

进入代码.如果您不使用 Make,或者不能轻易地让您的构建过程运行输出生成编译器命令行选项的命令,那么您还可以使用 TortoiseSVN 附带的 subwcrev 实用程序.您将其用作预构建步骤,并将某些带有占位符的文件转换为该文件的副本,其中占位符替换为实际版本;然后您的编译将编译并链接新文件.

into the code. If you don't use Make, or cannot readily have your build process run a command whose output produces a compiler command line option, then you can also use the subwcrev utility that comes with TortoiseSVN. You use that as a pre-build step, and have it transform some file with placeholders into a copy of the file with the placeholders replaced with the actual version; then your compilation will compile and link the new file.

编辑:对于 PHP 案例,不可能在检出或更新时将修订自动写入文件.相反,您可以在每次 PHP 访问时运行 svnversion,将其输出放入 HTML 响应中.如果这太昂贵了,您可以将 svnversion 结果缓存在一个文件中,并且仅在文件超过一小时(例如)时才重新生成该文件,让用户记住在更新后删除该文件以使其重新计算立即缓存.

Edit: For the PHP case, it is not possible to have the revision written automatically into a file on checkout or update. Instead, you could run svnversion on every PHP access, putting its output into the HTML response. If that gets too expensive, you can cache the svnversion result in a file and only regenerate the file if it is older than one hour (say), leaving it up to the user to remember to delete the file after an update to make it recompute the cache right away.

这篇关于将 svnversion 与 svn:keywords 一起使用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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