UNIX in a Nutshell: System V Edition

UNIX in a Nutshell: System V EditionSearch this book
Previous: 19.2 Basic OperationChapter 19
The Revision Control System
Next: 19.4 Conversion Guide for SCCS Users
 

19.3 General RCS Specifications

This section discusses:

19.3.1 Keyword Substitution

RCS lets you place keyword variables in your working files. These variables are later expanded into revision notes. You can then use the notes either as embedded comments in the input file or as text strings that appear when the output is printed. To create revision notes via keyword substitution, follow this procedure:

  1. In your working file, type any of the keywords listed below.

  2. Check the file in.

  3. Check the file out again. Upon checkout, the co command expands each keyword to include its value. That is, co replaces instances of:

    $keyword$

    with:

    $keyword:value $.

  4. Subsequent check-in and check-out of a file updates any existing keyword values. Unless otherwise noted below, existing values are replaced by new values.

Many commands have a -k option that provides considerable flexibility during keyword substitution.

19.3.2 Keywords

$Author$

Username of person who checked in the revision.

$Date$

Date and time of check-in.

$Header$

A title that includes the RCS file's full pathname, revision number, date, author, state, and (if locked) the person who locked the file.

$Id$

Same as $Header$, but exclude the full pathname of the RCS file.

$Locker$

Username of person who locked the revision. If the file isn't locked, this value is empty.

$Log$

The message that was typed during check-in to describe the file, preceded by the RCS filename, revision number, author, and date. Log messages accumulate rather than being overwritten.

RCS uses the "comment leader" of the $Log$ line for the log messages left in the file. The comment leader stored in the RCS file is useful only for exchanging files with older versions of RCS.

$Name$

The symbolic name used to check in the revision, if any.

$RCSfile$

The RCS filename, without its pathname.

$Revision$

The assigned revision number.

$Source$

The RCS filename, including its pathname.

$State$

The state assigned by the -s option of ci or rcs.

19.3.3 Example Values

Let's assume that the file /projects/new/chapter3 has been checked in and out by a user named daniel. Here's what keyword substitution produces for each keyword, for the second revision of the file:

$Author: daniel $

$Date: 1992/03/18 17:51:36 $

$Header: /projects/new/chapter3,v 1.2 92/03/18 17:51:36 daniel \
    Exp Locker: daniel $

$Id: chapter3,v 1.2 1992/03/18 17:51:35 daniel Exp Locker: daniel $

$Locker: daniel $

$Log:    chapter3,v $
# Revision 1.2  92/03/18  17:51:36  daniel
# Added section on error-handling
# 
# Revision 1.1  92/03/18  16:49:59  daniel
# Initial revision
# 

$Name: Alpha2 $

$RCSfile: chapter3,v $

$Revision: 1.2 $

$Source: /projects/new/chapter3,v $

$State: Exp $

19.3.4 Revision Numbering

Unless told otherwise, RCS commands typically operate on the latest revision. Some commands have an -r option that specifies a revision number. In addition, many options accept a revision number as an optional argument. (In the command summary, this argument is shown as [R].) Revision numbers consist of up to four fields: release, level, branch, and sequence; but most revisions consist of only the release and level. For example, you can check out revision 1.4 as follows:

co -l -r1.4 ch01

When you check it in again, the new revision will be marked as 1.5. Now suppose the edited copy needs to be checked in as the next release. You would type:

ci -r2 ch01

This creates revision 2.1. You can also create a branch from an earlier revision. The following command creates revision 1.4.1.1:

ci -r1.4.1 ch01

Numbers that begin with a period are considered to be relative to the default branch of the RCS file. Normally, this is the "trunk" of the revision tree.

Numbers are not the only way to specify revisions, though. You can assign a text label as a revision name, using the -n option of ci or rcs. You can also specify this name in any option that accepts a revision number for an argument. For example, you could check in each of your C files, using the same label regardless of the current revision number:

ci -u -nPrototype *.c

In addition, you may specify a $, which means the revision number extracted from the keywords of a working file. For example:

rcsdiff -r$ ch01

compares ch01 to the revision that is checked in. You can also combine names and symbols. The command:

rcs -nDraft:$ ch*

assigns a name to the revision numbers associated with several chapter files.

19.3.5 Specifying the Date

Revisions are timestamped by time and date of check-in. Several keyword strings include the date in their values. Dates can be supplied in options to ci, co, and rlog. RCS uses the following date format as its default:

2000/01/10 02:00:00	Year/month/day  time

The default time zone is Greenwich Mean Time (GMT), which is also referred to as Coordinated Universal Time (UTC). Dates can be supplied in free format. This lets you specify many different styles. Here are some of the more common ones, which show the same time as in the previous example:

6:00 pm lt		Assuming today is Jan. 10, 2000
2:00 AM, Jan. 10, 2000
Mon Jan 10 18:00:00 2000 LT	
Mon Jan 10 18:00:00 PST 2000

The uppercase or lowercase "lt" indicates local time (here, Pacific Standard Time). The third line shows ctime format (plus the "LT"); the fourth line is the date command format.

19.3.6 Specifying States

In some situations, particularly programming environments, you want to know the status of a set of revisions. RCS files are marked by a text string that describes their state. The default state is Exp (experimental). Other common choices include Stab (stable) or Rel (released). These words are user-defined and have no special internal meaning. Several keyword strings include the state in their values. In addition, states can be supplied in options to ci, co, rcs, and rlog.

19.3.7 Standard Options and Environment Variables

RCS defines an environment variable, RCSINIT, which sets up default options for RCS commands. If you set RCSINIT to a space-separated list of options, they will be prepended to the command-line options you supply to any RCS command.

Six options are useful to include in RCSINIT: -q, -V, -Vn, -T, -x, and -z. They can be thought of as standard options because most RCS commands accept them.

-q[R]

Quiet mode; don't show diagnostic output. R specifies a file revision.

-T

If the file with the new revision has a later modification time than that of the RCS file, update the RCS file's modification time. Otherwise, preserve the RCS file's modification time. This option should be used with care; see the discussion in the ci manpage for more detail.

-V

Print the RCS version number.

-Vn

Emulate version n of RCS; useful when trading files between systems that run different versions. n can be 3, 4, or 5.

-xsuffixes

Specify an alternate list of suffixes for RCS files. Each suffix is separated by a /. On Unix systems, RCS files normally end with the characters ,v. The -x option provides a workaround for systems that don't allow a comma character in filenames.

-ztimezone

timezone controls the output format for dates in keyword substitution. timezone should have one of the following values:

ValueEffect
empty

Default format: UTC with no time zone and slashes separating the parts of the date.

LT

The local time and date, in ISO-8601 format, with time-zone indication (YYYY-MM-DD HH:MM:SS-ZZ).

±hh:mm

With a numeric offset from UTC, the output is in IS0-8601 format.

For example, when depositing a working file into an RCS file, the command:

ci -x,v/ ch01	Second suffix is blank

searches in order for the RCS filenames:

RCS/ch01,v
ch01,v
RCS/ch01

RCS allows you to specify a location for temporary files. It checks the environment variables TMPDIR, TMP, and TEMP, in that order. If none of those exist, it uses a default location, such as /tmp.


Previous: 19.2 Basic OperationUNIX in a Nutshell: System V EditionNext: 19.4 Conversion Guide for SCCS Users
19.2 Basic OperationBook Index19.4 Conversion Guide for SCCS Users

The UNIX CD Bookshelf NavigationThe UNIX CD BookshelfUNIX Power ToolsUNIX in a NutshellLearning the vi Editorsed & awkLearning the Korn ShellLearning the UNIX Operating System