SCCS stands for Source Code Control System. SCCS provides a way to:
Keep track of the evolution of a source file—its change history
Prevent a source file from being simultaneously changed by other developers
Keep track of the version number by providing version stamps
The basic three operations of SCCS are:
Putting files under SCCS control
Checking out a file for editing
Checking in a file
This section shows you how to use SCCS to perform these tasks, using the previous program as an example. Only basic SCCS is described and only three SCCS commands are introduced: create, edit, and delget.
Putting files under SCCS control involves:
Making the SCCS directory
Inserting SCCS ID keywords into the files (this is optional)
Creating the SCCS files
To begin, you must create the SCCS subdirectory in the directory in which your program is being developed. Use this command:
demo% mkdir SCCS |
SCCS must be in uppercase.
Some developers put one or more SCCS ID keywords into each file, but that is optional. These keywords are later identified with a version number each time the files are checked in with an SCCS get or delget command. There are three likely places to put these strings:
Comment lines
Parameter statements
Initialized data
The advantage of using keywords is that the version information appears in the source listing and compiled object program. If preceded by the string @(#), the keywords in the object file can be printed using the what command.
Included header files that contain only parameter and data definition statements do not generate any initialized data, so the keywords for those files usually are put in comments or in parameter statements. In some files, like ASCII data files or makefiles, the SCCS information will appear in comments.
SCCS keywords appear in the form %keyword% and are expanded into their values by the SCCS get command. The most commonly used keywords are:
%Z% expands to the identifier string @(#) recognized by the what command.%M% expands to the name of the source file.%I% expands to the version number of this SCCS maintained file.%E% expands to the current date.
For example, you could identify the makefile with a make comment containing these keywords:
# %Z%%M% %I% %E% |
The source files, startupcore.f, computepts.f, and pattern.f, can be identified by initialized data of the form:
CHARACTER*50 SCCSID DATA SCCSID/"%Z%%M% %I% %E%\n"/ |
When this file is processed by SCCS, compiled, and the object file processed by the SCCS what command, the following is displayed:
demo% f95 -c pattern.f ... demo% what pattern pattern: pattern.f 1.2 96/06/10 |
You can also create a PARAMETER named CTIME that is automatically updated whenever the file is accessed with get.
CHARACTER*(*) CTIME PARAMETER ( CTIME="%E%") |
INCLUDE files can be annotated with a Fortran comment containing the SCCS stamp:
C %Z%%M% %I% %E% |
Use of single letter derived type component names in Fortran 95 source code files can conflict with SCCS keyword recognition. For example, the Fortran 95 structure component reference X%Y%Z when passed through SCCS will become XZ after an SCCS get. Care should be taken not to define structure components with single letters when using SCCS on Fortran 95 programs. For example, had the structure reference in the Fortran 95 program been to X%YY%Z, the %YY% would not have been interpreted by SCCS as a keyword reference. Alternatively, the SCCS get -k option will retrieve the file without expanding SCCS keyword IDs.
Now you can put these files under control of SCCS with the SCCS create command:
demo% sccs create makefile commonblock startupcore.f \ computepts.f pattern.f demo% |
Once your source code is under SCCS control, you use SCCS for two main tasks: to check out a file so that you can edit it, and to check in a file you have finished editing.
Check out a file with the sccs edit command. For example:
demo% sccs edit computepts.f |
SCCS then makes a writable copy of computepts.f in the current directory, and records your login name. Other users cannot check the file out while you have it checked out, but they can find out who has checked it out.
When you have completed your editing, check in the modified file with the sccs delget command. For example:
demo% sccs delget computepts.f |
This command causes the SCCS system to:
Make sure that you are the user who checked out the file by comparing login names
Prompt for a comment from you on the changes
Make a record of what was changed in this editing session
Delete the writable copy of computepts.f from the current directory
Replace it by a read-only copy with the SCCS keywords expanded
The sccs delget command is a composite of two simpler SCCS commands, delta and get. The delta command performs the first three tasks in the list above; the get command performs the last two tasks.