简体   繁体   English

cvs2svn更改源代码中的“日期”字符串

[英]cvs2svn changes 'date' string in source codes

I converted two of our group's CVS repositories and loaded them into SVN. 我转换了小组的两个CVS存储库,并将它们加载到SVN中。 But I found some files are changed !!! 但是我发现有些文件被改变了!

for example, static char rcsid[] = "$Revision: 1.1.1.1 $$Date: 2007/06/25 16:56:59 $"; 例如,static char rcsid [] =“ $ Revision:1.1.1.1 $$ Date:2007/06/25 16:56:59 $”;

was changed to static char rcsid[] = "$Revision: 1.1.1.1 $$Date: 2007-06-25 16:56:59 $"; 已更改为static char rcsid [] =“ $ Revision:1.1.1.1 $$ Date:2007-06-25 16:56:59 $”;

These are actual strings, not comments. 这些是实际的字符串,而不是注释。 (some other changed strings are in comments, which is OK). (一些其他更改的字符串在注释中,可以)。 So why would cvs2svn would do that? 那么,为什么cvs2svn会这样做呢? and how to prevent from cvs2svn from doing it??? 以及如何防止cvs2svn这样做??? I added --keywords-off options, but that didn't make a difference. 我添加了--keywords-off选项,但这没什么不同。

Thanks for any help! 谢谢你的帮助!

CVS expands keywords (like $Date$ ) to the right value when you check the file out, not (as you might guess) when you check the file in. Moreover, different versions of CVS expand dates in different styles. 当您检出文件时,CVS会将关键字(例如$Date$ )扩展为正确的值,而不是(当您签入时)将关键字扩展为正确的值。此外,不同版本的CVS会以不同的样式扩展日期。 Prior to CVS 1.12, dates were expanded using slashes, like 2007/06/25 . 在CVS 1.12之前,日期使用斜线扩展,例如2007/06/25 Starting with CVS 1.12, dates have been expanded with dashes, like 2007-06-25 . 从CVS 1.12开始,日期已用短划线扩展,例如2007-06-25

The date format that you are seeing when you check the file out of Subversion is the result of keyword expansion by Subversion. 将文件签出Subversion时看到的日期格式是Subversion扩展关键字的结果。 AFAIK Subversion always expands the dates in the new style, with dashes. AFAIK Subversion始终使用破折号以新样式扩展日期。 So the reason that the strings look different is that Subversion uses a different date expansion style, not because of anything that cvs2svn does. 因此,字符串看起来不同的原因是Subversion使用了不同的日期扩展样式,而不是因为cvs2svn所做的任何事情。

When you specify --keywords-off , then cvs2svn leaves the keywords expanded as they were in CVS, namely in the form they had when they were checked in . 当您指定--keywords-off ,然后cvs2svn离开,因为他们在CVS,即当他们进行了检查他们的形式展开关键词。 Usually that means that they are in the format they had when the previous time that the file was checked out , namely with the valued reflecting the previous revision of the file. 通常,这意味着它们采用的是上次签文件时的格式,即其值反映了文件的先前修订版。 This is rarely useful. 这很少有用。

The only way to get the date strings in the format that you expected would be to have cvs2svn expand the date strings itself and turn SVN keyword expansion off . 只有这样,才能获得你预期将有格式的日期字符串cvs2svn扩大日期字符串本身并打开SVN关键字扩展 Plus you would have to configure cvs2svn to expand using the "old date format" for the expansion, which can be set by calling _KeywordExpander.use_old_date_format() (or by editing the file cvs2svn_lib/keyword_expander.py ). 另外,您必须将cvs2svn配置为使用“旧日期格式”进行扩展,可以通过调用_KeywordExpander.use_old_date_format() (或通过编辑文件cvs2svn_lib/keyword_expander.py )进行设置。 But then, presumably, you would want to turn keyword expansion back on post-conversion, so that subsequent Subversion revisions have their keywords expanded, too. 但是,大概,您可能希望转换后重新启用关键字扩展,以便后续的Subversion修订版也对其关键字进行扩展。 So after the conversion, you would have to set the svn:keywords property on any file containing keywords, and you would also have to manually re-collapse the keywords (eg, edit $Date: 2007/06/25 16:56:59 $ back to $Date$ ) in those files. 因此,在转换之后,您将必须在任何包含关键字的文件上设置svn:keywords属性,并且还必须手动重新折叠关键字(例如,编辑$Date: 2007/06/25 16:56:59 $这些文件中的$Date: 2007/06/25 16:56:59 $返回到$Date$ )。 All in all, this would be quite tricky to configure and is probably not worth the effort. 总而言之,这在配置上会非常棘手,并且可能不值得付出努力。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM