提交后如何将新的 SVN 修订号存储在源代码中? (乌龟SVN)

发布于 2024-08-22 14:46:13 字数 202 浏览 5 评论 0原文

是否可以通过 TortoiseSVN 知道您在提交之前将要获得的 SVN 版本号,以便我可以将该版本号放入源代码注释部分?

也许有一个特殊的键名/变量,我可以将其放入我的文件中,TortoiseSVN 会自动将其替换为要提交的 rev#?

其背后的动机是我可以通过查看源代码来获取最新的版本并查看它由哪些 SVN rev 组成。它还给管理层带来温暖的模糊感。

Is it possible, via TortoiseSVN, to know the SVN rev number you are about to get prior to a commit so that I can put that rev# into the source code comment section?

Perhaps there is a special keyname/variable that I can put into my file that TortoiseSVN will automatically replace with the rev# it's about to commit to?

The motivation behind this is that I can take the latest build and see what SVN rev's it was comprised of by just looking at the source code. It also gives management warm fuzzies.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(5

满栀 2024-08-29 14:46:14

Subversion 确实支持关键字扩展,但是您可能需要在选择实施之前阅读此处

出于多种原因,避免使用 SVN 中已有的内容修改提交的文件通常是一个好主意。上面的第二个链接提供了更多关于为什么这可能是一个坏主意的细节。但基本上,差异和补丁可能会成为问题。

您也不需要复制 Subversion 捕获的信息,因为可以通过 log 命令轻松获取这些信息。

Subversion does support keyword expansion, but you may want to read here before choosing to implementing it.

There are a number of reasons why it's generally a good idea to avoid modifying your committed files with content that is already in SVN. The second link above provides more detail on why this can be a bad idea. But basically, diffs and patches can become problematic.

You also don't need to duplicate the information that Subversion captures because this can be easily obtained via the log command.

甜是你 2024-08-29 14:46:14

SVN 特殊关键字 - 特别是:“ $修订$”

SVN Special keywords - specifically: "$Revision$"

星星的轨迹 2024-08-29 14:46:14

如果您使用某种构建工具(例如 Ant)来打包代码,则可以在构建过程中包含 SVN 属性查询。

因为我只有在 Ant 中执行此操作的经验,所以它是这样的:

<svn svnkit="true" javahl="false">
    <status path="." lastChangedRevisionProperty="svn.lastRev"/>
</svn>

设置 svn.lastRev 属性后,您可以将其注入到代码注释中 - 也许通过令牌替换。我不确定这是否正是您正在寻找的。不过我同意,很高兴看看你的代码并知道 SVN rev 是什么。它来自。

If you're using some sort of build tool to package your code, like Ant, you could include an SVN property query in the build process.

Since I only have experience doing this in Ant, it goes like this:

<svn svnkit="true" javahl="false">
    <status path="." lastChangedRevisionProperty="svn.lastRev"/>
</svn>

Once the svn.lastRev property is set, you can inject it into your code comments - maybe via token replacement. I'm not sure if this is exactly what you're looking for. I agree though, it's nice to look at your code and know what SVN rev. it came from.

べ繥欢鉨o。 2024-08-29 14:46:14

在项目的每个源文件中存储 SVN 修订号并不重要。

例如,可以将文件“svn.c”添加到其项目中,并让 SVN 在每次提交时写入以下行:

size_t svn_revision = n;        /* n is the revision number written by SVN */

之后,可以 printf() 输出 svn_revision 例如,启动时的变量。

It's not important to store the SVN revision number in each source file of the project.

One can add, for example, file "svn.c" to its project and have SVN write the following line at each commit:

size_t svn_revision = n;        /* n is the revision number written by SVN */

After that, one can printf() the svn_revision variable at boot, for example.

心作怪 2024-08-29 14:46:14

您还可以使用 SVN 的关键字替换功能。

示例:

在 C 源文件中添加以下注释:

/* SVN 修订号 = $Revision */

$Revision 将被实际提交修订号替换:

/* SVN 修订号 = 123 */

看一下这里:
http://svnbook.red-bean。 com/en/1.7/svn.advanced.props.special.keywords.html

再见,
恩里科·米廖雷

you might also use the keyword substitution feature of SVN.

Example:

Add the following comment in your C source file:

/* SVN revision number = $Revision */

$Revision will be replaced by the actual commit revision number:

/* SVN revision number = 123 */

Take a look here:
http://svnbook.red-bean.com/en/1.7/svn.advanced.props.special.keywords.html

Ciao,
Enrico Migliore

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文