Programming Utilities Guide

The sccs Command

The Source Code Control System is composed of the sccs(1) command, which is a front end for the utility programs in the /usr/ccs/bin directory. The SCCS utility programs are listed in Table 5-2.

The sccs create Command

The sccs create command places your file under SCCS control. It creates a new history file, and uses the complete text of your source file as the initial version. By default, the history file resides in the SCCS subdirectory.

$ sccs create program.c 
program.c: 
1.1 
87 lines

The output from SCCS tells you the name of the created file, its version number (1.1), and the count of lines.

To prevent the accidental loss or damage to an original, sccs create makes a second link to it, prefixing the new filename with a comma (referred to as the comma-file.) When the history file has been initialized successfully, SCCS retrieves a new, read-only version. After you have verified the version against its comma-file, you can remove that file.

$ cmp ,program.c program.c 
(no output means that the files match exactly
$ rm ,program.c 

Do not try to edit the read-only version that SCCS retrieves. Before you can edit the file, you must check it out using the sccs edit command described below.

To distinguish the history file from a current version, SCCS uses the `s.' prefix. Owing to this prefix, the history file is often referred to as the s.file (s-dot-file). For historical reasons, it may also be referred to as the SCCS-file.

The format of an SCCS history file is described in sccsfile(4).

Basic sccs Subcommands

The following sccs subcommands perform the basic version-control functions. They are summarized here, and, except for create, are described in detail under "sccs Subcommands ".

create

Initialize the history file and first version, as described above.

edit

Check out a writable version (for editing). SCCS retrieves a writable copy with you as the owner, and places a lock on the history file so that no one else can check in changes.

delta

Check in your changes. This is the complement to the sccs edit operation. Before recording your changes, SCCS prompts for a comment, which it then stores in the history file version log.

get

Retrieve a read-only copy of the file from the s.file. By default, this is the most recent version. While the retrieved version can be used as a source file for compilation, formatting, or display, it is not intended to be edited or changed in any way. (Attempting to bend the rules by changing permissions of a read-only version can result in your changes being lost.)

If you give a directory as a filename argument, sccs attempts to perform the subcommand on each s.file in that directory. Thus, the command:

sccs get SCCS

retrieves a read-only version for every s.file in the SCCS subdirectory.

prt

Display the version log, including comments associated with each version.

Deltas and Versions

When you check in a version, SCCS records only the line-by-line differences between the text you check in and the previous version. This set of differences is known as a delta. The version that is retrieved by an edit or get is constructed from the accumulated deltas checked in so far.

The terms "delta" and "version" are often used synonymously. However, their meanings aren't exactly the same; it is possible to retrieve a version that omits selected deltas (see "Excluding Deltas from a Retrieved Version ").

SIDs

An SCCS delta ID, or SID, is the number used to represent a specific delta. This is a two-part number, with the parts separated by a dot ( . ). The SID of the initial delta is 1.1 by default. The first part of the SID is referred to as the release number, and the second, the level number. When you check in a delta, the level number is incremented automatically. The release number can be incremented as needed. SCCS also recognizes two additional fields for branch deltas (described under "Branches ").

Strictly speaking, an SID refers directly to a delta. However, it is often used to indicate the version constructed from a delta and its predecessors.

ID Keywords

SCCS recognizes and expands certain keywords in a source file, which you can use to include version-dependent information (such as the SID) into the text of the checked-in version. When the file is checked out for editing, ID keywords take the following form:

%C%

where C is a capital letter. When you check in the file, SCCS replaces the keywords with the information they stand for. For example, %I% expands to the SID of the current version.

You would typically include ID keywords either in a comment or in a string definition. If you do not include at least one ID keyword in your source file, SCCS issues the diagnostic:

No Id Keywords (cm7)

For more information about ID keywords, refer to "Incorporating Version-Dependent Information by Using ID Keywords ".