3

我在 CVS 中有一个文件,一个*.h文件。

我在那里有一个定义:

#define MY_BUILD_TAG       "$Name:   $"

我签入文件,用自定义标签 ( cvs tag) 对其进行标记。

cvs checkout从头开始文件所属的模块(-r <my tag>当然)

cvs status确实在文件上正确显示了新的粘性标签。但是,当我的文件被签出时, 的值"$Name: $"不会改变。我希望它能够反映我的粘性标签。

我究竟做错了什么?我尝试使用 和 之间的空间:$使其成为 2、3、4、1 位无济于事。

4

1 回答 1

2

看起来 CVS 不会仅仅因为$Name扩展更改而更新文件。如果它必须创建文件,它会更新它。

我有一个 CVS 存储库/home/kst/CVS_smov,其中有一个名为name-test. 此脚本演示了该行为。更改前两个命令以使用不同的配置进行演示。

#!/bin/bash

export CVSROOT=/home/kst/CVS_smov
cd ~/cvs-smov/name-test

echo '$Id:$'   >  name.txt
echo '$Name:$' >> name.txt

cvs add name.txt
cvs commit -m 'First checkin' name.txt
echo "name.txt:"
cat name.txt

echo ''

cvs tag tag-name name.txt
cd ..
cvs checkout -r tag-name name-test
cd name-test
echo "After cvs checkout -r:"
cat name.txt

echo ''

cd ..
rm -r name-test
cvs checkout -r tag-name name-test
cd name-test
echo "After rm -r and cvs checkout -r:"
cat name.txt

这是我使用 CVS 1.12.13 得到的输出:

cvs add: scheduling file `name.txt' for addition
cvs add: use `cvs commit' to add this file permanently
/home/kst/CVS_smov/name-test/name.txt,v  <--  name.txt
initial revision: 1.1
name.txt:
$Id: name.txt,v 1.1 2013/06/17 15:56:50 kst Exp $
$Name:  $

T name.txt
cvs checkout: Updating name-test
After cvs checkout -r:
$Id: name.txt,v 1.1 2013/06/17 15:56:50 kst Exp $
$Name:  $

cvs checkout: Updating name-test
U name-test/name.txt
After rm -r and cvs checkout -r:
$Id: name.txt,v 1.1 2013/06/17 15:56:50 kst Exp $
$Name: tag-name $

摘要:
我在创建并签入文件后显示文件的内容(不$Name,因为没有标签),在创建标签并签出模块后($Name仍未更新),然后在对目录进行核对并签出后再次(现在$Name填写)。

这可能是 CVS 中的一个错误,但坦率地说,我没有使用 CVS 标签来确定它应该如何运行。

更新 :

Name查看 CVS 源代码,我看到一些评论表达了对关键字的一些不确定性。

src/rcs.c, 函数RCS_gettag:

        /* We have found a numeric revision for the revision tag.
           To support expanding the RCS keyword Name, if
           SIMPLE_TAG is not NULL, tell the the caller that this
           is a simple tag which co will recognize.  FIXME: Are
           there other cases in which we should set this?  In
           particular, what if we expand RCS keywords internally
           without calling co?  */

src/rcscmds.c, 函数RCS_exec_rcsdiff:

/* Historically, `cvs diff' has expanded the $Name keyword to the
   empty string when checking out revisions.  This is an accident,
   but no one has considered the issue thoroughly enough to determine
   what the best behavior is.  Passing NULL for the `nametag' argument
   preserves the existing behavior. */

src/update.c, 函数中patch_file

/* FIXME - Passing vers_ts->tag here is wrong in the least number
 * of cases.  Since we don't know whether vn_user was checked out
 * using a tag, we pass vers_ts->tag, which, assuming the user did
 * not specify a new TAG to -r, will be the branch we are on.
 *
 * The only thing it is used for is to substitute in for the Name
 * RCS keyword, so in the error case, the patch fails to apply on
 * the client end and we end up resending the whole file.
 *
 * At least, if we are keeping track of the tag vn_user came from,
 * I don't know where yet. -DRP
 */

最后一个让我印象深刻的是观察到的行为最可能的原因。

于 2013-06-17T16:03:31.300 回答