.\" Copyright (c) 1980 Regents of the University of California.
.\" All rights reserved. The Berkeley software License Agreement
.\" specifies the terms and conditions for redistribution.
.\" @(#)sccs.me 6.3 (Berkeley) 5/30/86
.eh '\fRPS1:14-%\fP''\fRAn Introduction to the Source Code Control System\fP'
.oh '\fRAn Introduction to the Source Code Control System\fP''\fRPS1:14-%\fP'
.\".he '\*S Introduction''%'
Source Code Control System
.i "University of California at Berkeley"
This is version 1.21 of this document.
It was last modified on 12/5/80.
This document gives a quick introduction
to using the Source Code Control System
The presentation is geared to programmers
who are more concerned with
rather than how it works;
for this reason some of the examples
For details of what the magic options do,
.q "Further Information" .
This is a working document.
Please send any comments or suggestions
\*S is a source management system.
Such a system maintains a record of versions of a system;
a record is kept with each set of changes
and who made them and when.
Old versions can be recovered,
and different versions can be maintained simultaneously.
In projects with more than one person,
\*S will insure that two people are not
editing the same file at the same time.
All versions of your program,
plus the log and other information,
is kept in a file called the
There are three major operations
that can be performed on the s-file:
Get a file for compilation (not for editing).
This operation retrieves a version of the file
By default, the latest version is retrieved.
This file is intended for compilation, printing, or whatever;
it is specifically NOT intended to be edited
any changes made to a file retrieved
in this way will probably be lost.
This operation also retrieves a version of the file
but this file is intended to be edited and then
incorporated back into the s-file.
Only one person may be editing a file at one time.
Merge a file back into the s-file.
This is the companion operation to (2).
A new version number is assigned,
and comments are saved explaining why this change was made.
.sh 1 "Learning the Lingo"
There are a number of terms that are worth learning
before we go any farther.
is a single file that holds all the different versions
only the differences between versions are stored,
rather than the entire text of the new version.
and allows selective changes to be removed later.
Also included in the s-file
is some header information for each version,
including the comments given by the person who
created the version explaining why the changes were made.
Each set of changes to the s-file
(which is approximately [but not exactly!] equivalent
to a version of the file)
Although technically a delta only includes the
each delta to be made with respect to
all the deltas that have occurred before\**.
\**This matches normal usage, where the previous changes are not saved
so all changes are automatically based on all other changes
that have happened through history.
it is possible to get a version of the file
that has selected deltas removed out of the middle
of the list of changes \*-
equivalent to removing your changes later.
.sh 2 "\*I's (or, version numbers)"
is a number that represents a delta.
This is normally a two-part number
Normally the release number stays the same,
it is possible to move into a new release
if some major change is being made.
Since all past deltas are normally applied,
the \*I of the final delta applied
can be used to represent a version number of the file
When you get a version of a file
with intent to compile and install it
something other than edit it),
some special keywords are expanded inline
can be used to include the current version number
or other information into the file.
All id keywords are of the form
is the \*I of the latest delta applied,
includes the module name,
and a mark that makes it findable by a program,
is the date of the latest delta applied.
most of which are of dubious usefulness.
When you get a file for editing,
the id keywords are not expanded;
this is so that after you put them back in to the s-file,
they will be expanded automatically on each new version.
But notice: if you were to get them
then your file would appear to be the same version
which would of course defeat the purpose.
if you should install a version of the program
without expanding the id keywords,
it will be impossible to tell what version it is
(since all it will have is
.sh 1 "Creating \*S Files"
format, run the following shell script from csh:
This will put the named files
The files will be removed from the current directory
and hidden away in the directory
so the next thing you will probably want to do
When you are convinced that
\*S has correctly created the s-files,
you should remove the directory
If you want to have id keywords in the files,
it is best to put them in before you create the s-files.
.q "No Id Keywords (cm7)" ,
which is a warning message only.
.sh 1 "Getting Files for Compilation"
To get a copy of the latest version
meaning that version 1.1 was retrieved\**
the \*I of the final delta applied was 1.1.
and that it has 87 lines.
in the current directory.
The file will be read-only
to remind you that you are not
they will be lost the next time
.sh 1 "Changing Files (or, Creating Deltas)"
.sh 2 "Getting a copy to edit"
requesting permission to edit it\**:
command is equivalent to using the \-e
Keep this in mind when reading other documentation.
The response will be the same as with
except that it will also say:
using a standard text editor:
.sh 2 "Merging the changes back into the s-file"
When the desired changes are made,
you can put your changes into the
Delta will prompt you for
before it merges the changes in.
At this prompt you should type a one-line description
(more lines can be entered by ending each line
except the last with a backslash\**).
\**Yes, this is a stupid default.
saying that delta 1.2 was created,
and it inserted five lines,
and left 84 lines unchanged\**.
\**Changes to a line are counted as a line deleted
.sh 2 "When to make deltas"
It is probably unwise to make a delta
before every recompilation or test;
you tend to get a lot of deltas with comments like
.q "fixed compilation problem in previous delta"
.q "fixed botch in 1.3" .
it is very important to delta everything
before installing a module for general use.
A good technique is to edit the files you need,
make all necessary changes and tests,
compiling and editing as often as necessary
When you are satisfied that you have a working version,
delta everything being edited,
and recompile everything.
.sh 2 "What's going on: the info command"
To find out what files where being edited,
to print out all the files being edited
and other information such as the name of the user
is nearly equivalent to the
except that it is silent if nothing is being edited,
and returns non-zero exit status if anything is being edited;
if anything has not been properly deltaed.
If you know that everything being edited should be deltaed,
except that only the names of files being edited
All of these commands take a
(alternate versions, described later)
flag to only give files being edited by you.
giving only files being edited by that user.
gives a listing of files being edited by john.
Id keywords can be inserted into your file
that will be expanded automatically by
static char SccsId[] = "%\&W\&%\et%\&G\&%";
will be replaced with something like:
static char SccsId[] = "@\&(#)prog.c 1.2 08/29/80";
and the time the delta was created.
which signals the beginning
To find out what version of a program
sccs what prog.c /usr/bin/prog
which will print all strings
This works on all types of files,
including binaries and libraries.
For example, the above command will output something like:
that the source that I have in prog.c
will not compile into the same version
as the binary in /usr/bin/prog.
.sh 3 "Where to put id keywords"
ID keywords can be inserted anywhere,
Id Keywords that are compiled into the object module
since it lets you find out what version of
data space is used up to store
and on small address space machines
When you put id keywords into header files,
it is important that you assign them to different variables.
For example, you might use:
static char AccessSid[] = "%\&W\&% %\&G\&%";
static char OpsysSid[] = "%\&W\&% %\&G\&%";
you will get compilation errors because
The problem with this is that if the header file
is included by many modules that are loaded together,
the version number of that header file is included
in the object module many times;
you may find it more to your taste
to put id keywords in header files
.sh 2 "Keeping \*I's consistent across files"
it is possible to keep the \*I's consistent
The trick here is to always
The changes can then be made
to whatever files are necessary
This can be done fairly easily
by just specifying the name of the directory
that the \*S files are in:
all files in that directory.
You will be prompted for comments only once.
.sh 2 "Creating new releases"
When you want to create a new release
you can specify the release number you want to create
will cause the next delta to be in release two
it will be numbered 2.1).
Future deltas will automatically be in release two.
To change the release number
.sh 1 "Restoring Old Versions"
.sh 2 "Reverting to old versions"
Suppose that after delta 1.2
you made and released a delta 1.3.
But this introduced a bug,
so you made a delta 1.4 to correct it.
and you decided you wanted to go back
by choosing the \*I in a get:
This will produce a version of
that can be reinstalled so that work can proceed.
In some cases you don't know
what the \*I of the delta you want is.
you can revert to the version of the program
that was running as of a certain date
sccs get \-c800722120000 prog.c
will retrieve whatever version was current
Trailing components can be stripped off
(defaulting to their highest legal value),
and punctuation can be inserted in the obvious
the above line could be equivalently stated:
sccs get \-c"80/07/22 12:00:00" prog.c
.sh 2 "Selectively deleting old deltas"
Suppose that you later decided
that you liked the changes in delta 1.4,
but that delta 1.3 should be removed.
it will include the changes made
but will exclude the changes made
You can exclude a range of deltas
if you want to get rid of 1.3 and 1.4
sccs edit \-x1.3\-1.4 prog.c
which will exclude all deltas from 1.3 to 1.4.
sccs edit \-x1.3\-1 prog.c
will exclude a range of deltas
from 1.3 to the current highest delta in release 1.
In certain cases when using
for example, it may be necessary
to both include and delete
\*S always prints out a message
telling the range of lines effected;
these lines should then be examined very carefully
to see if the version \*S got
that this makes it most useful
to put each semantically distinct change
When you created a delta,
you presumably gave a reason for the delta
To print out these comments later,
time and date of creation,
user who created the delta,
number of lines inserted, deleted, and unchanged,
and the comments associated with the delta.
For example, the output of the above command might be:
D 1.2 80/08/29 12:35:31 bill 2 1 00005/00003/00084
D 1.1 79/02/05 00:19:31 eric 1 0 00087/00000/00000
date and time created 80/06/10 00:19:31 by eric
.sh 2 "Finding why lines were inserted"
you can get a copy of the file
preceded by the \*I that created it:
by printing the comments using
To find out what lines are associated with a particular delta
sccs get \-m \-p prog.c \(bv grep \'^1.3\'
flag causes \*S to output the generated source
to the standard output rather than to a file.
.sh 2 "Finding what changes you have made"
When you are editing a file,
you can find out what changes you have made using:
Most of the ``diff'' flags can be used.
To compare two versions that are in deltas,
sccs sccsdiff -r1.3 -r1.6 prog.c
to see the differences between delta 1.3 and delta 1.6.
.sh 1 "Shorthand Notations"
There are several sequences of commands that get
tries to make it easy to do these.
A frequent requirement is to make a delta of some file
This can be done by using:
which is entirely equivalent to using:
Frequently, there are small bugs
e.g., compilation errors,
for which there is no reason to maintain an audit trail.
This will get a copy of delta 1.4 of prog.c for you to edit
and then delete delta 1.4 from the \*S file.
When you do a delta of prog.c,
it will be delta 1.4 again.
The \-r flag must be specified,
and the delta that is specified must be a leaf delta,
i.e., no other deltas may have been made subsequent
to the creation of that delta.
If you found you edited a file
that you did not want to edit,
you can back out by using:
If you are working on a project
where the \*S code is in a directory somewhere,
you may be able to simplify things
alias syssccs sccs \-d/usr/src
will allow you to issue commands such as:
which will look for the file
.q "/usr/src/cmd/SCCS/who.c" .
will always be created in your current directory
regardless of the value of the \-d flag.
.sh 1 "Using \*S on a Project"
Working on a project with several people
has its own set of special problems.
The main problem occurs when two people
modify a file at the same time.
\*S prevents this by locking an s-file
while it is being edited.
files should not be reserved for editing
unless they are actually being edited at the time,
since this will prevent other people on the project
from making necessary changes.
a good scenario for working might be:
# do testing of the (experimental) version
# should respond "Nothing being edited"
all source files should be deltaed
before installing the program for general use.
This will insure that it is possible
to restore any version in use at any time.
.sh 2 "Recovering a munged edit file"
that you have destroyed or trashed
a file that you were trying to edit\**.
\**Or given up and decided to start over.
that someone is trying to edit it,
so it won't let you do it again.
Neither can you just get it using
since that would expand the Id keywords.
This will not expand the Id keywords,
so it is safe to do a delta
.sh 2 "Restoring the s-file"
In particularly bad circumstances,
The most common way this happens
Since \*S keeps a checksum,
you will get errors every time you read the file.
To fix this checksum, use:
.sh 1 "Using the Admin Command"
There are a number of parameters that can be set
The most interesting of these are flags.
Flags can be added by using the
This flag can be deleted by using:
The most useful flags are:
Allow branches to be made using the
Default \*I to be used on a
If this is just a release number
to a particular release only.
if there are no Id Keywords in a file.
This is useful to guarantee that a version of the
file does not get merged into the s-file
that has the Id Keywords inserted as constants
instead of internal forms.
the value of this flag is unused by \*S
except that it replaces the
to store descriptive text
This descriptive text might be the documentation
or a design and implementation document.
flag insures that if the \*S file is sent,
the documentation will be sent also.
the descriptive text is deleted.
To see the descriptive text,
command can be used safely
any number of times on files.
A file need not be gotten
.sh 1 "Maintaining Different Versions (Branches)"
Sometimes it is convenient
to maintain an experimental version of a program
while normal maintenance continues
on the version in production.
Normally deltas continue in a straight line,
each depending on the delta before.
a version of the program.
The ability to create branches
must be enabled in advance using:
flag can be specified when the
\*S file is first created.
.sh 2 "Creating a branch"
This will create a branch
with (for example) \*I 1.5.1.1.
The deltas for this version
.sh 2 "Getting from a branch"
Deltas in a branch are normally not included
.sh 2 "Merging a branch back into the main trunk"
At some point you will have finished the experiment,
you will want to incorporate it into the release version.
someone may have created a delta 1.6
that you don't want to lose.
sccs edit \-i1.5.1.1\-1.5.1 prog.c
will merge all of your changes
If some of the changes conflict,
should be carefully examined
before the delta is made.
.sh 2 "A more detailed example"
The following technique might be used
to maintain a different version of a program.
create a directory to contain the new version:
Edit a copy of the program
sccs \-d../xyz edit prog.c
When using the old version,
flag to info, check, tell, and clean
If you want to save a copy of the program
sccs -d../xyz deledit prog.c
which will do a delta on the branch
When the experiment is complete, merge it back into the s-file
sccs -d../xyz delta prog.c
At this point you must decide whether this version
should be merged back into the trunk
which may have undergone changes.
If so, it can be merged using the
Branches should be kept to a minimum.
After the first branch from the trunk,
\*I's are assigned rather haphazardly,
and the structure gets complex fast.
.sh 1 "Using \*S with Make"
\*S and make can be made to work together
for common applications are shown.
There are a few basic entries that every makefile
(or whatever the makefile generates.)
This entry regenerates whatever this makefile is
If the makefile regenerates many things,
have dependencies on everything
the makefile can generate.
Moves the objects to the final
Creates all the source files from \*S files.
Removes all files from the current directory
that can be regenerated from \*S files.
Prints the contents of the directory.
The examples shown below are only partial examples,
and may omit some of these entries
when they are deemed to be obvious.
entry should not remove files that can be
regenerated from the \*S files.
It is sufficiently important to have the
source files around at all times
that the only time they should be removed
is when the directory is being mothballed.
This will remove all files for which an s-file
but which is not being edited.
.sh 2 "To maintain single programs"
Frequently there are directories with several
largely unrelated programs
(such as simple commands).
These can be put into a single makefile:
$(CC) $(LDFLAGS) \-o prog prog.o
$(CC) $(LDFLAGS) \-o example example.o
is that the .DEFAULT rule
and no other rule exists to make it.
The explicit dependency of the
Another way of doing the same thing is:
SRCS= prog.c prog.h example.c
$(CC) $(LDFLAGS) \-o prog prog.o
$(CC) $(LDFLAGS) \-o example example.o
There are a couple of advantages to this approach:
(1) the explicit dependencies of the .o on the .c files are
(2) there is an entry called "sources" so if you want to get
all the sources you can just say
(3) the makefile is less likely to do confusing things
things that do not exist.
.sh 2 "To maintain a library"
Libraries that are largely static
are best updated using explicit commands,
doesn't know about updating them properly.
libraries that are in the process of being developed
can be handled quite adequately.
The problem is that the .o files
have to be kept out of the library
as well as in the library.
# configuration information
SRCS= a.c b.c c.c d.s x.h y.h z.h
can be used to get old versions
This guarantees that all the s-files
nothing is being edited),
if this condition is not met.
.sh 2 "To maintain a large program"
SRCS= a.c b.c c.y d.s x.h y.h z.h
$(CC) $(LDFLAGS) $(OBJS) $(LIBS)
entries are identical to the previous case.)
This makefile requires copies of the source and object files
to be kept during development.
It is probably also wise to include lines of the form:
so that modules will be recompiled
does not do transitive closure on dependencies,
you may find in some makefiles lines like:
This would be used in cases where file z.h
in order to bring the mod date of z.h in line
with the mod date of x.h.
When you have a makefile such as above,
command can be removed completely;
the equivalent effect will be achieved
.sh 1 "Further Information"
.i "SCCS/PWB User's Manual"
gives a deeper description
are the numbering of branches,
which gives a description of what deltas were used on a get,
and certain other \*S commands.
These should be read by software managers
and by people who want to know
everything about everything.
Both of these documents were written without the
so most of the examples are slightly different from those
The following commands should all be preceded with
This list is not exhaustive;
.i "Further Information" .
Gets files for compilation (not for editing).
Id keywords are expanded.
Send to standard output rather than to the actual file.
Don't expand id keywords.
List of deltas to include.
List of deltas to exclude.
Precede each line with \*I of creating delta.
Don't apply any deltas created after
Id keywords are not expanded.
specifies a release that does not yet exist,
the highest numbered delta is retrieved
and the new delta is numbered with
Merge a file gotten using
Collect comments about why this delta was made.
Remove a file that has been edited previously
without merging the changes into the s-file.
Produce a report of changes.
Print the descriptive text.
Print (nearly) everything.
Give a list of all files being edited.
Ignore files not being edited by
except that nothing is printed if nothing is being edited
and exit status is returned.
except that one line is produced per file being edited containing
Remove all files that can be regenerated from the
Find and print id keywords.
Create or set parameters on s-files.
Rebuild the checksum in case
the file has been trashed.
Replace the descriptive text
in the s-file with the contents of
Useful for storing documentation
.q "design & implementation"
documents to insure they get distributed with the
Allow branches to be made using the \-b flag to
to be a fatal error rather than a warning.
the value of this flag replaces the
Remove a delta and reedit it.
.q "%\&Z\&%%\&M\&% <tab> %\&I\&%" .
The current release number,
the first component of the
Replaced by the value of the