Question

I have a file in CVS, a *.h file.

I have a definition there:

#define MY_BUILD_TAG       "$Name:   $"

I check the file in, tag it with a custom TAG (cvs tag).

I cvs checkout the module the file belongs to from scratch (with -r <my tag> of course)

cvs status does show the new sticky tag correctly on the file. however, the value of "$Name: $" doesn't change as my files is checked out. I expected it to reflect my sticky tag.

What am I doing wrong? I tried playing with the space between the : and the $, making it 2, 3, 4, 1 places to no avail.

Was it helpful?

Solution

It looks like CVS doesn't update a file just because the $Name expansion changed. If it has to create the file, it does update it.

I have a CVS repository at /home/kst/CVS_smov, with a module called name-test. This script demonstrates the behavior. Change the first two commands to demonstrate with a different configuration.

#!/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

Here's the output I get with 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 $

Summary:
I show the contents of the file after creating it and checking it in (no $Name because there's no tag), after creating the tag and checking out the module ($Name still isn't updated), then after nuking the directory and checking it out again (now $Name is filled in).

This is probably a bug in CVS, though frankly I haven't use CVS tags enough to be sure how it should behave.

UPDATE :

Looking through the CVS sources, I see some comment that express some uncertainty about the Name keyword.

In src/rcs.c, function 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?  */

In src/rcscmds.c, function 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. */

And in src/update.c, function 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
 */

This last strikes me as the most likely cause of the observed behavior.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top