我在CVS中有一个*.h
文件。
我有一个定义:
#define MY_BUILD_TAG "$Name: $"
我检查文件,用自定义标签(cvs tag
)标记。
我cvs checkout
文件从头开始所属的模块(当然是-r <my tag>
)
cvs status
会在文件上正确显示新的粘性标记。但是,"$Name: $"
的值不会随着我的文件签出而改变。我希望它反映我的粘性标签。
我做错了什么?我尝试使用:
和$
之间的空格进行游戏,使得2,3,4,1个位置无效。
答案 0 :(得分:2)
看起来CVS不会因为$Name
扩展更改而更新文件。如果必须创建文件,它会更新它。
我在/home/kst/CVS_smov
有一个CVS存储库,其中有一个名为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标签来确定它应该的行为。
更新:
通过CVS来源,我看到一些评论表明Name
关键字存在一些不确定性。
在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
*/
这最后让我觉得这是观察到的行为的最可能原因。