It can be hard to keep track of the versions of the files, when working
on a project involving many
files that evolve over long period of time, especially if several people
are making updates. Source
code and documentation files change frequently as the bugs are fixed,
programs are enhanced, and
new versions of the software are released. It becomes more complex
when there is more than one
active version of each file. Frequently, people are using one version
of a file while a newer version
is being modified. You can easily lose track of the versions and accidentally
undo changes that were
already made or duplicate earlier work.
To help avoid these kinds of problems, the UNIX
system includes utilities for managing and
tracking changes to files. These utilities comprise two separate source
code management systems:
SCCS, the Source Code Control System and RCS, the Revision
Control System.
Both systems can control who is allowed to update
the files. For each update, they record who
made the changes including the notes about why the changes are made.
Introduction to an SCCS File
When you change an SCCS file and record the changes, the set of changes
is referred to as a delta.
Each delta has an associated version number, or SCCS Identification
String (called SID), consisting
of either 2 or 4 components. The first 2, which are always used, are
the release and level numbers.
When an SCCS file is initially created, by default SCCS assigns a release
number of 1 and a level
number of 1, which corresponds to Version 1.1 (or delta 1.1). Also
by default, SCCS assigns subsequent
version numbers of 1.2, 1.3 and so on. But user has control over the
version numbers. User is allowed
to skip level numbers or change the release number.Usually, files undergo
a sequential development, where
each delta includes all previous deltas..
Creating an SCCS File
The admin utility is one of the most important SCCS utilities-you
can use it to create SCCS files as well
as to change characteristics of existing SCCS files. If you have a
Bourne Shell script called blitz, you can
use admin to create an SCCS encoded version.
The admin command in the figure 2 creates
the initial version of the SCCS encoded file s.blitz. This file
includes the contents of the file blitz as well as the control
information SCCS adds. The statement admin
presents, No id keywords(cm 7), is a warning massage.
$ cat blitz
:
#A script that noisily but cautiously empties the
working directory
echo "The working directory is `pwd`"
echo "Delete all files in `pwd`? \c"
read answer
case $answer in
y|Y|[yY]es)
echo "removing all files........"
rm *
; ;
*
echo "Files remain untouched..."
; ;
esac
$admin -blitz s.blitz
No id keywords (cm7)
Figure 1
If you give the command help followed by the code, the help
utility
will produce and explanation
of the message.
$help cm7
cm7:
`No id keywords`
No SCCS identification keywords were substituted
for.
You may not have any keywords in the file, in which
case
you can ignore this warning message.
As the help utility explains, the massage in Figure 1 indicates that
there are no SCCS keywords
in the encoded file. Keywords are SCCS codes user can use to insert
information about the SCCS
file into the text retrieved from the encoded file. For example you
can user can use keywords to
identify the SCCS filename, version number, and the date and time the
text was retrieved from
the encoded file.
User can call the admin utility with many other arguments in
the form:
$admin -iname filename
The name is the name of the file SCCS will encode. The filename
is the name of the SCCS encoded
file, and it must start with an s. prefix.
Retrieving an SCCS File
You should not edit an SCCS file such as s.blitz - editing the file
would defeat the purpose of using
SCCS. Use the get utility with the -e option to create
an encoded, writable version of the file. The
-e option indicates to SCCS that you plan to make changes and
record the changes in SCCS
$get -e s.blitz
1.1
new delta 1.2
16 lines
The get command displays the version number
of the retrieved delta, the version number that will
be applied when the new changes are recorded in SCCS, and the number
of lines in the file. By default,
the get command retrieves the most recent delta to the file.
But you can also use get with the -r option,
to retrieve a specific delta or to change number of the new delta.
$get -e -r2 s.blitz
1.2
new delta 1.2.1.1
16 lines
Recording Changes to an SCCS File
After you have edited the retrieved file and are ready to record the
changes in SCCS, use the delta utility
to record your changes. The delta utility prompts prompts the
user for comments.
$delta s.blitz
comments?
The rmdel utility can be used to remove the latest version, or the latest version on a branch.
$rmdel -r1.2 s.blitz
Obtaining the History of an SCCS File
The prs utility prints information about the history of an SCCS
file. prs utility can be called with a
variety of arguments that specify what information it reports and the
format of the report but when
it is called without any arguments, prs prints the summary about
all the deltas.
Restricting Access to SCCS Files
The admin utility can be used to establish a list of users who
are allowed to make deltas to an SCCS file.
By default, the list of users who can make changes to a file is empty,
which means that anyone can make
a delta. For example, the following command gives permission to bob
and jane and implicitly denies permission
to everyone else.
$admin -abob -ajane s.blitz
The -e (erase) option removes a user from the list. The following command removes jane from the list.
$admin -ejane s.blitz
SCCS also allows user to lock releases of a file so that no one
can change them. The following command
uses the -f option to set the l flag to lock Release
1 of s.blitz
$admin -fl1 s.blitz
The Revision Control System (RCS)
The Revision Control System (RCS) has many of the same features as SCCS.
Like SCCS, each RCS file can
have 4 components to its version number(release, level, branch, sequence).
For the most case, RCS was
designed to be simpler to use than SCCS. SCCS and RCS also differ in
the method they use to reconstruct
a file when a user requests a particular version: SCCS starts with
the original (version 1.1) file and applies
all the changes leading up to the version a user has requested. RCS
starts the latest version; if the user
requested an earlier version, RCS works backward.
Each RCS encoded file ends with 2-character suffix ,v.
Creating an RCS File
To create an RCS file, use the ci (check in) command. The
following example says that the user is creating
the file RCS/blitz,v from the input file blitz and prompts the user
to enter a description of the file. Finally,
the ci reports the applicable revision number and confirms that
is has finished running.
$ci blitz
RCS/blitz,v <-- blitz
enter description, terminated with a single '.'
or end of file:
<description here>
Retrieving and Recording Changes to an RCS File
To retrieve an RCS file, use the co (check out) command. If you
plan to edit the file, you need to request a lock
so that no one else will retrieve the same file for editing. The following
command puts a writable copy of the
file blitz in the user directory.
$co -l blitz
RCS/blitz,v --> junk
revision 1.1 (locked)
done
To create a new version level of a file, use ci with the -r option.
$ci -r2 blitz
RCS/blitz,v <-- blitz
new revision: 2.1; previous revision: 1.1
enter log message, terminated with single '.' or end of file:
To remove a change to the file, use the -o option with the rcs
command. The command below removes
revision 2.2 from the file blitz.
$rcs -o2.2 blitz
RCS file: RCS/blitz,v
deleting revision 2.2
done
Obtaining the History of an RCS File
You can use rlog command to display the history of an RCS file.
Without additional options, rlog prints
information about all the deltas that have been made to the file.
$rlog blitz
RCS file: RCS/blitz,v
Working file: blitz
head: 1.2
branch:
locks: strict
access list:
symbolic names:
comment leader: "#"
Restricting Access to RCS Files
The rcs command is used for adding and removing users form the list
that allows them to make deltas.
By the default anyone can check in a delta. The following command gives
permission
only to bob and jane.
$rcs -abob, jane blitz
The -e option removes a user from the list.
$rcs -ejane blitz