-->
Previous Table of Contents Next


Retrieving Version Information from an RCS File

Instead of querying the contents of an RCS file based on keywords, you might be interested in obtaining summary information about the version attributes using the rlog command with the -t option. On the finest.c RCS file, the output from


$ rlog -t finest.c

produces output formatted like this:


RCS file:      finest.c,v;  Working file:  finest.c

head:          3.2

locks:         pete: 2.1; strict

access list: rick tim

symbolic names:

comment leader:  “ * “

total revisions: 10;

description:

You know…programming at its finest…

=========================================================

headrefers to the version number of the highest revision in the entire stream. locks describes which users have versions checked out and the type of lock (strict or implicit for the RCS file owner). access list is a list of users who are authorized to make deltas on this RCS file. The next section illustrates how user-access privileges for an RCS file can be changed.

Administering Access

One of the most important functions of RCS is to mediate the access of users to a set of files. For each file, RCS maintain a list of users who have permission to create deltas on that file. This list is empty to begin with, so that all users have permission to make deltas. The rcs command is used to assign usernames or group names with delta privileges. The command


$ rcs -arick,tim finest.c

enables the users Rick and Tim to make deltas on finest.c and simultaneously restricts all other users (except the owner) from that privilege.

Perhaps you change your mind and decide that the user Rick is not worthy of making deltas on your wonderful finest.c program. You can deny him that privilege using the -e option:


& rcs -erick finest.c

Suddenly, in a fit of paranoia, you trust no one to make deltas on finest.c. Like a software Mussolini, you place a global lock (which applies to everyone, including the owner) on release 2 of finest.c using the -e and -L options


$ rcs -e -L2 finest.c

so that no one can make changes on any delta in the release 2 stream. Only the file owner can make changes, but this person still has to explicitly put a lock on the file for every check-out and check-in operation.

Comparing and Merging Revisions

Revisions can be compared to each other to discover what, if any, differences lie between them. This can be used as a means of safely merging together edits of a single source file by different developers. The rcsdiff command is used to show differences between revisions existing in an RCS file or between a checked-out version and the most current revision in the RCS file. To compare the finest.c 1.2 version to the 1.5 version, enter


$ rcsdiff -r1.2 -r1.5 finest.c

The output is something like


RCS file: finest.c,v

retrieving revision 1.1

rdiff -r1.2 -r1.5 finest.c

6a7,8

>

> /* …but what good is this? */

This output indicates that the only difference between the files is that two new lines have been added after the original line six. To just compare your current checked-out version with that of the “head” version in the RCS file, simply enter


$ rcsdiff finest.c

Once you have determined if there are any conflicts between your edits and others, you may decide to merge revisions. You can do this with the rcsmerge command. The format of this command is to take one or two filenames representing the version to be merged and a third filename indicating the working file (in the following example, this is finest.c).

The command


$ rcsmerge -r1.3 -r1.6 finest.c

produces output like this:


RCS file: finest.c,v

retrieving revision 1.3

retrieving revision 1.6

Merging differences between 1.3 and 1.6 into finest.c

If any lines between the two files overlap, rcsmerge indicates the lines that originate from a particular merged file in the working copy. You have to resolve these overlaps by explicitly editing the working copy to remove any conflicts before checking the working copy back into RCS.


Note:  
There is an implied order in which the files to be merged are placed in the rcsmerge command. If you are placing a higher version before a lower one at the -r options, this is essentially undoing the edits that have transpired from the older (lower) version to the newer (higher) version.


Previous Table of Contents Next