CVS命令获取文件的当前修订号 [英] CVS command to get the current revision number of file

查看:103
本文介绍了CVS命令获取文件的当前修订号的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要一种简单的方法来使用cvs获取文件的修订版本。我可以使用 CVS / Entries 文件获取它。这是不安全的,我认为必须有另一种方法。 cvs日志打印的内容超出了我的需要。如何使用cvs命令仅获取某些文件的修订号。

I need a simple way to get the revision of file using cvs. I can get it using the CVS/Entries file. It is not safe and I think there must be another way. cvs log prints too much than I need. How can I get only the revision number of some file using cvs commands.

推荐答案

cvs log -h 仅显示标题信息。要仅获取版本,可以很容易地通过sed,awk或Perl对其进行过滤。

cvs log -h shows just the header information. To get just the version, it's easy enough to filter that through sed, awk, or Perl.

这将为您提供版本库中的版本。如果要使用已检出文件的版本,则可以使用 ident (RCS的一部分),但前提是文件中包含正确的关键字。 (这对于二进制文件来说效果不佳。)

This gives you the version in the repository. If you want the version of the checked-out file, you can use ident (part of RCS) -- but only if you've included the proper keywords in the file. (This doesn't work well for binaries.)

例如,如果在检入文件之前在文件中添加了以下内容:

For example, if you add something like the following to your file before checking it in:

# $Id:$
# $Source:$

然后 ident foo.txt 将显示以下内容:

foo.txt:
     $Id: foo.txt,v 1.3 2011/10/17 22:49:45 kst Exp $
     $Source: /path/to/repo/sandbox/foo.txt,v $

您可以使用许多其他关键字。有关详细信息,请参见CVS手册的关键字替换部分。

There are a number of other keywords you can use. See the Keyword substitution section of the CVS manual for details.

这可能会以各种方式出现错误;例如,如果您在签出文件后对其进行编辑,则扩展的关键字不一定会反映出有意义的内容。您可以使用 cvs diff 来确定文件在签出后是否已被修改。

This can go wrong in various ways; for example, if you edit the file after checking it out, the expanded keywords won't necessarily reflect anything meaningful. You can use cvs diff to determine whether a file has been modified after checkout.

如前所述,如果您尝试使用二进制文件执行此操作,它可能会损坏文件(这就是为什么如果您告诉CVS文件是二进制文件,则不会进行关键字替换)。

As I mentioned, if you try to do this with a binary file, it can corrupt the file (which is why if you tell CVS that a file is binary, it won't do keyword substitution).

ident 命令是RCS的一部分,而不是CVS的一部分,因此,如果尚未安装RCS,则必须在系统上安装它。 (使用 cvs ident 命令会很有意义;我不确定为什么它不存在。)

The ident command is part of RCS, not CVS, so you'll have to install RCS on your system if it's not already there. (It would have made sense to have a cvs ident command; I'm not sure why it's not there.)

更多现代源代码控制系统往往不提供此功能。

More "modern" source control systems tend not to provide this facility.

这篇关于CVS命令获取文件的当前修订号的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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