gpt4 book ai didi

CVS 关键字对我不起作用

转载 作者:行者123 更新时间:2023-12-02 02:01:34 25 4
gpt4 key购买 nike

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

我有一个定义:

#define MY_BUILD_TAG       "$Name:   $"

我 checkin 文件,用自定义 TAG ( cvs tag) 标记它。

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

cvs status确实在文件上正确显示了新的粘性标签。但是,"$Name: $" 的值不会因为我的文件被 check out 而改变。我希望它能反射(reflect)我的粘性标签。

我做错了什么?我试着玩弄 : 之间的空间和 $ , 使它成为 2, 3, 4, 1 地方无济于事。

最佳答案

看起来 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 $

总结:
我在创建文件并 checkin 后显示文件的内容(没有 $Name 因为没有标签),在创建标签并 checkout 模块后($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
*/

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

关于CVS 关键字对我不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16996508/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com