如何在我的代码中获得更新的$ Revision $

时间:2022-07-23 15:08:46

I have a project into which I'd like to embed the revision number automagically.

我有一个项目,我想自动嵌入修订号。

In this case, it's a multi-file perl script. In the main file, I have a line that looks like this:

在这种情况下,它是一个多文件perl脚本。在主文件中,我有一行如下所示:

my $revision = '$Revision: 24 $';

我的$ revision ='$ Revision:24 $';

When I make a release, I checkout the project to my release dir.

当我发布时,我将项目签出到我的发布目录。

The revision number does change whenever I check-in a change to THAT FILE. The $Revision$ attribute is updated on check-in, but not check-out.

每当我签入对该文件的更改时,修订号都会发生变化。 $ Revision $属性在办理登机手续时更新,但不会退房。

The thing is, the main file doesn't change that often, so even though the other files in the project are now at 27, the main still has 24.

问题是,主文件经常不会改变,因此即使项目中的其他文件现在为27,主要文件仍然有24个。

Is there a way that I can get the main file to reflect the latest rev number? The one that svn prints out at the end of the checkout, ie "Checked out revision 27."

有没有办法可以让主文件反映最新的转速? svn在结账时打印出来的那个,即“Checked out revision 27.”

2 个解决方案

#1


It is similar to CVS, you can use $Revision$ you just have to set the keyword property for that file for SVN to know it is supposed to do a keyword replace.

它类似于CVS,您可以使用$ Revision $,您只需要为该文件设置关键字属性,以便SVN知道它应该执行关键字替换。

From the manual:

从手册:

"With no svn:keywords property set on that file, Subversion will do nothing special. Now, let's enable substitution of the LastChangedDate keyword. $ svn propset svn:keywords "Date Author" weather.txt property 'svn:keywords' set on 'weather.txt' $ "

“在该文件上没有设置svn:keywords属性,Subversion将不会做任何特别的事情。现在,让我们启用LastChangedDate关键字的替换。$ svn propset svn:keywords”Date Author“weather.txt property'svn:keywords'set on' weather.txt'$“

http://svnbook.red-bean.com/en/1.5/svn-book.pdf

#2


if (! -e '.version')
{
    open VERSION, '>.version';
    print VERSION `svnversion -n | cut -f1 -d:`;
    close VERSION;
}

my $revision = '$Revision: ' . `cat .version` . ' $';

(Note: a puppy will die if you use this code as-is)

(注意:如果按原样使用此代码,小狗将会死亡)

#1


It is similar to CVS, you can use $Revision$ you just have to set the keyword property for that file for SVN to know it is supposed to do a keyword replace.

它类似于CVS,您可以使用$ Revision $,您只需要为该文件设置关键字属性,以便SVN知道它应该执行关键字替换。

From the manual:

从手册:

"With no svn:keywords property set on that file, Subversion will do nothing special. Now, let's enable substitution of the LastChangedDate keyword. $ svn propset svn:keywords "Date Author" weather.txt property 'svn:keywords' set on 'weather.txt' $ "

“在该文件上没有设置svn:keywords属性,Subversion将不会做任何特别的事情。现在,让我们启用LastChangedDate关键字的替换。$ svn propset svn:keywords”Date Author“weather.txt property'svn:keywords'set on' weather.txt'$“

http://svnbook.red-bean.com/en/1.5/svn-book.pdf

#2


if (! -e '.version')
{
    open VERSION, '>.version';
    print VERSION `svnversion -n | cut -f1 -d:`;
    close VERSION;
}

my $revision = '$Revision: ' . `cat .version` . ' $';

(Note: a puppy will die if you use this code as-is)

(注意:如果按原样使用此代码,小狗将会死亡)