Chapter 6. RCS: Revision Control System

6.1. Using the FreeBSD Revision Control System Locally

The Revision Control System () manages multiple revisions of files. RCS automates the storing, retrieval, logging, identification, and merging of revisions. RCS is useful for text that is revised frequently, for example programs, documentation, graphics, papers, and form letters.

Typically, an identification string is put in the file to make the revision level readily apparent. For example, start with a file with just

$Id$
in it. Then use ci to check the file in:

% ci -u index_foo.html
  index_foo.html,v  <--  index_foo.html
  enter description, terminated with single '.' or end of file:
  NOTE: This is NOT the log message!
  >> RCS Document 
  >> ^D
  initial revision: 1.1
  done

If you now look at the file, the $Id$ will have changed to look something like this:

$Id: index_foo.html,v 1.1 2004/10/02 15:36:34 rpratt Exp $

Note that for any file such as index_foo.html, a correspondingly named control file is created. In this case it is called index_foo.html,v. It contains all the revisions, logs and other information stored by rcs. By default it gets put in the same directory as the file you're tracking, but if you have a subdirectory RCS, it'll get put there instead.

When you then want to update the file, you first need to check it out (the version you have is write-protected). Do this with:

% co -l index_foo.html

Make your changes; when you're done, check in again with ci:

% ci -u index_foo.html
  index_foo.html,v  <--  index_foo.html
  new revision: 1.2; previous revision: 1.1
  enter log message, terminated with single '.' or end of file:
  >> Added HTML tags 
  >> ^D
  done

The text after >> gets put into the revision log. You can look at it with rlog:

% rlog index_foo.html 

RCS file: RCS/index_foo.html,v
Working file: index_foo.html
head: 1.4
branch:
locks: strict
access list:
symbolic names:
keyword substitution: kv
total revisions: 4;     selected revisions: 4
description:
RCS Document
----------------------------
revision 1.4
date: 2004/10/02 16:20:06;  author: rpratt;  state: Exp;  lines: +73 -1
Added initial text
----------------------------
revision 1.3
date: 2004/10/02 16:01:46;  author: rpratt;  state: Exp;  lines: +3 -1
Added HTML comment tag for RCS Id string
----------------------------
revision 1.2
date: 2004/10/02 15:38:42;  author: rpratt;  state: Exp;  lines: +11 -1
Added HTML tags
----------------------------
revision 1.1
date: 2004/10/02 15:36:34;  author: rpratt;  state: Exp;
RCS Document
----------------------------
=============================================================================

You can also check out older versions and compare things.