BSD 4_2 development
[unix-history] / usr / doc / sccs
CommitLineData
1c7bb577
C
1.ds S \s-1SCCS\s0
2.ds I \s-1SID\s0
3.nr bi 8n
4.ev 1 \" only for keeps
5.ss 16
6.ev
7.he '\*S Introduction''%'
8.+c
9.(l C
10.sz 14
11.b
12An Introduction to the
13Source Code Control System
14.sz
15.r
16.sp
17Eric Allman
18.i "Project Ingres"
19.i "University of California at Berkeley"
20.)l
21.sp 3
22.pp
23.(f
24This is version 1.21 of this document.
25It was last modified on 12/5/80.
26.)f
27This document gives a quick introduction
28to using the Source Code Control System
29(\*S).
30The presentation is geared to programmers
31who are more concerned with
32what
33to do to get a task done
34rather than how it works;
35for this reason some of the examples
36are not well explained.
37For details of what the magic options do,
38see the section on
39.q "Further Information" .
40.(l F
41This is a working document.
42Please send any comments or suggestions
43to csvax:eric.
44.)l
45.sh 1 "Introduction"
46.pp
47\*S is a source management system.
48Such a system maintains a record of versions of a system;
49a record is kept with each set of changes
50of what the changes are,
51why they were made,
52and who made them and when.
53Old versions can be recovered,
54and different versions can be maintained simultaneously.
55In projects with more than one person,
56\*S will insure that two people are not
57editing the same file at the same time.
58.pp
59All versions of your program,
60plus the log and other information,
61is kept in a file called the
62.q "s-file" .
63There are three major operations
64that can be performed on the s-file:
65.np
66Get a file for compilation (not for editing).
67This operation retrieves a version of the file
68from the s-file.
69By default, the latest version is retrieved.
70This file is intended for compilation, printing, or whatever;
71it is specifically NOT intended to be edited
72or changed in any way;
73any changes made to a file retrieved
74in this way will probably be lost.
75.np
76Get a file for editing.
77This operation also retrieves a version of the file
78from the s-file,
79but this file is intended to be edited and then
80incorporated back into the s-file.
81Only one person may be editing a file at one time.
82.np
83Merge a file back into the s-file.
84This is the companion operation to (2).
85A new version number is assigned,
86and comments are saved explaining why this change was made.
87.sh 1 "Learning the Lingo"
88.pp
89There are a number of terms that are worth learning
90before we go any farther.
91.sh 2 "S-file"
92.pp
93The s-file
94is a single file that holds all the different versions
95of your file.
96The s-file is stored in
97differential format;
98.i i.e. ,
99only the differences between versions are stored,
100rather than the entire text of the new version.
101This saves disk space
102and allows selective changes to be removed later.
103Also included in the s-file
104is some header information for each version,
105including the comments given by the person who
106created the version explaining why the changes were made.
107.sh 2 "Deltas"
108.pp
109Each set of changes to the s-file
110(which is approximately [but not exactly!] equivalent
111to a version of the file)
112is called a
113.i delta .
114Although technically a delta only includes the
115.i changes
116made,
117in practice
118it is usual for
119each delta to be made with respect to
120all the deltas that have occurred before\**.
121.(f
122\**This matches normal usage, where the previous changes are not saved
123at all,
124so all changes are automatically based on all other changes
125that have happened through history.
126.)f
127However,
128it is possible to get a version of the file
129that has selected deltas removed out of the middle
130of the list of changes \*-
131equivalent to removing your changes later.
132.sh 2 "\*I's (or, version numbers)"
133.pp
134A \*I
135(\*S Id)
136is a number that represents a delta.
137This is normally a two-part number
138consisting of a
139.q release
140number and a
141.q level
142number.
143Normally the release number stays the same,
144however,
145it is possible to move into a new release
146if some major change is being made.
147.pp
148Since all past deltas are normally applied,
149the \*I of the final delta applied
150can be used to represent a version number of the file
151as a whole.
152.sh 2 "Id keywords"
153.pp
154When you get a version of a file
155with intent to compile and install it
156(\c
157.i i.e. ,
158something other than edit it),
159some special keywords are expanded inline
160by \*S.
161These
162.i "Id Keywords"
163can be used to include the current version number
164or other information into the file.
165All id keywords are of the form
166.b % \c
167.i x \c
168.b % ,
169where
170.i x
171is an upper case letter.
172For example,
173.b %\&I\&%
174is the \*I of the latest delta applied,
175.b %\&W\&%
176includes the module name,
177\*I,
178and a mark that makes it findable by a program,
179and
180.b %\&G\&%
181is the date of the latest delta applied.
182There are many others,
183most of which are of dubious usefulness.
184.pp
185When you get a file for editing,
186the id keywords are not expanded;
187this is so that after you put them back in to the s-file,
188they will be expanded automatically on each new version.
189But notice: if you were to get them
190expanded accidently,
191then your file would appear to be the same version
192forever more,
193which would of course defeat the purpose.
194Also,
195if you should install a version of the program
196without expanding the id keywords,
197it will be impossible to tell what version it is
198(since all it will have is
199.q %\&W\&%
200or whatever).
201.sh 1 "Creating \*S Files"
202.pp
203To put source files
204into
205\*S
206format, run the following shell script from csh:
207.(b
208mkdir SCCS save
209foreach i (*.[ch])
210 sccs admin \-i$i $i
211 mv $i save/$i
212end
213.)b
214This will put the named files
215into s-files
216in the subdirectory
217.q SCCS
218The files will be removed from the current directory
219and hidden away in the directory
220.q save ,
221so the next thing you will probably want to do
222is to get all the files
223(described below).
224When you are convinced that
225\*S has correctly created the s-files,
226you should remove the directory
227.q save .
228.pp
229If you want to have id keywords in the files,
230it is best to put them in before you create the s-files.
231If you do not,
232.i admin
233will print
234.q "No Id Keywords (cm7)" ,
235which is a warning message only.
236.sh 1 "Getting Files for Compilation"
237.pp
238To get a copy of the latest version
239of a file,
240run
241.(b
242sccs get prog.c
243.)b
244\*S will respond:
245.(b
2461.1
24787 lines
248.)b
249meaning that version 1.1 was retrieved\**
250.(f
251\**Actually,
252the \*I of the final delta applied was 1.1.
253.)f
254and that it has 87 lines.
255The file
256.i prog.c
257will be created
258in the current directory.
259The file will be read-only
260to remind you that you are not
261supposed to change it.
262.pp
263This copy of the file
264should not be changed,
265since \*S is unable
266to merge the changes
267back into the s-file.
268If you do make changes,
269they will be lost the next time
270someone does a
271.i get .
272.sh 1 "Changing Files (or, Creating Deltas)"
273.sh 2 "Getting a copy to edit"
274.pp
275To edit a source file,
276you must first get it,
277requesting permission to edit it\**:
278.(f
279\**The
280.q "edit"
281command is equivalent to using the \-e
282flag to
283.i "get" ,
284as:
285.(l
286sccs get \-e prog.c
287.)l
288Keep this in mind when reading other documentation.
289.)f
290.(b
291sccs edit prog.c
292.)b
293The response will be the same as with
294.i get
295except that it will also say:
296.(b
297New delta 1.2
298.)b
299You then edit it,
300using a standard text editor:
301.(b
302vi prog.c
303.)b
304.sh 2 "Merging the changes back into the s-file"
305.pp
306When the desired changes are made,
307you can put your changes into the
308\*S
309file using the
310.i delta
311command:
312.(b
313sccs delta prog.c
314.)b
315.pp
316Delta will prompt you for
317.q "comments?"
318before it merges the changes in.
319At this prompt you should type a one-line description
320of what the changes mean
321(more lines can be entered by ending each line
322except the last with a backslash\**).
323.(f
324\**Yes, this is a stupid default.
325.)f
326.i Delta
327will then type:
328.(b
3291.2
3305 inserted
3313 deleted
33284 unchanged
333.)b
334saying that delta 1.2 was created,
335and it inserted five lines,
336removed three lines,
337and left 84 lines unchanged\**.
338.(f
339\**Changes to a line are counted as a line deleted
340and a line inserted.
341.)f
342The
343.i prog.c
344file will be removed;
345it can be retrieved
346using
347.i get .
348.sh 2 "When to make deltas"
349.pp
350It is probably unwise to make a delta
351before every recompilation or test;
352otherwise,
353you tend to get a lot of deltas with comments like
354.q "fixed compilation problem in previous delta"
355or
356.q "fixed botch in 1.3" .
357However,
358it is very important to delta everything
359before installing a module for general use.
360A good technique is to edit the files you need,
361make all necessary changes and tests,
362compiling and editing as often as necessary
363without making deltas.
364When you are satisfied that you have a working version,
365delta everything being edited,
366re-get them,
367and recompile everything.
368.sh 2 "What's going on: the info command"
369.pp
370To find out what files where being edited,
371you can use:
372.(b
373sccs info
374.)b
375to print out all the files being edited
376and other information such as the name of the user
377who did the edit.
378Also,
379the command:
380.(b
381sccs check
382.)b
383is nearly equivalent to the
384.i info
385command,
386except that it is silent if nothing is being edited,
387and returns non-zero exit status if anything is being edited;
388it can be used in an
389.q install
390entry in a makefile
391to abort the install
392if anything has not been properly deltaed.
393.pp
394If you know that everything being edited should be deltaed,
395you can use:
396.(b
397sccs delta \`sccs tell\`
398.)b
399The
400.i tell
401command is similar to
402.i info
403except that only the names of files being edited
404are output,
405one per line.
406.pp
407All of these commands take a
408.b \-b
409flag
410to ignore
411.q branches
412(alternate versions, described later)
413and the
414.b \-u
415flag to only give files being edited by you.
416The
417.b \-u
418flag takes an optional
419.i user
420argument,
421giving only files being edited by that user.
422For example,
423.(b
424sccs info \-ujohn
425.)b
426gives a listing of files being edited by john.
427.sh 2 "ID keywords"
428.pp
429Id keywords can be inserted into your file
430that will be expanded automatically by
431.i get .
432For example,
433a line such as:
434.(b
435static char SccsId[] = "%\&W\&%\et%\&G\&%";
436.)b
437will be replaced with something like:
438.(b
439static char SccsId[] = "@\&(#)prog.c 1.2 08/29/80";
440.)b
441This tells you
442the name and version
443of the source file
444and the time the delta was created.
445The string
446.q "@\&(#)"
447is a special string
448which signals the beginning
449of an
450\*S
451Id keyword.
452.sh 3 "The what command"
453.pp
454To find out what version of a program
455is being run,
456use:
457.(b
458sccs what prog.c /usr/bin/prog
459.)b
460which will print all strings
461it finds that
462begin with
463.q "@\&(#)" .
464This works on all types of files,
465including binaries and libraries.
466For example, the above command will output something like:
467.(b
468prog.c:
469 prog.c 1.2 08/29/80
470/usr/bin/prog:
471 prog.c 1.1 02/05/79
472.)b
473From this I can see
474that the source that I have in prog.c
475will not compile into the same version
476as the binary in /usr/bin/prog.
477.sh 3 "Where to put id keywords"
478.pp
479ID keywords can be inserted anywhere,
480including in comments,
481but
482Id Keywords that are compiled into the object module
483are especially useful,
484since it lets you find out what version of
485the object is being run,
486as well as the source.
487However,
488there is a cost:
489data space is used up to store
490the keywords,
491and on small address space machines
492this may be prohibitive.
493.pp
494When you put id keywords into header files,
495it is important that you assign them to different variables.
496For example, you might use:
497.(b
498static char AccessSid[] = "%\&W\&% %\&G\&%";
499.)b
500in the file
501.i access.h
502and:
503.(b
504static char OpsysSid[] = "%\&W\&% %\&G\&%";
505.)b
506in the file
507.i opsys.h .
508Otherwise,
509you will get compilation errors because
510.q SccsId
511is redefined.
512The problem with this is that if the header file
513is included by many modules that are loaded together,
514the version number of that header file is included
515in the object module many times;
516you may find it more to your taste
517to put id keywords in header files
518in comments.
519.sh 2 "Keeping \*I's consistent across files"
520.pp
521With some care,
522it is possible to keep the \*I's consistent
523in multi-file systems.
524The trick here is to always
525.i edit
526all files
527at once.
528The changes can then be made
529to whatever files are necessary
530and then all files
531(even those not changed)
532are redeltaed.
533This can be done fairly easily
534by just specifying the name of the directory
535that the \*S files are in:
536.(b
537sccs edit SCCS
538.)b
539which will
540.i edit
541all files in that directory.
542To make the delta, use:
543.(b
544sccs delta SCCS
545.)b
546You will be prompted for comments only once.
547.sh 2 "Creating new releases"
548.pp
549When you want to create a new release
550of a program,
551you can specify the release number you want to create
552on the
553.i edit
554command.
555For example:
556.(b
557sccs edit \-r2 prog.c
558.)b
559will cause the next delta to be in release two
560(that is,
561it will be numbered 2.1).
562Future deltas will automatically be in release two.
563To change the release number
564of an entire system,
565use:
566.(b
567sccs edit \-r2 SCCS
568.)b
569.sh 1 "Restoring Old Versions"
570.sh 2 "Reverting to old versions"
571.pp
572Suppose that after delta 1.2
573was stable
574you made and released a delta 1.3.
575But this introduced a bug,
576so you made a delta 1.4 to correct it.
577But 1.4 was still buggy,
578and you decided you wanted to go back
579to the old version.
580You could
581revert to delta 1.2
582by choosing the \*I in a get:
583.(b
584sccs get \-r1.2 prog.c
585.)b
586This will produce a version of
587.i prog.c
588that is delta 1.2
589that can be reinstalled so that work can proceed.
590.pp
591In some cases you don't know
592what the \*I of the delta you want is.
593However,
594you can revert to the version of the program
595that was running as of a certain date
596by using the
597.b \-c
598(cutoff) flag.
599For example,
600.(b
601sccs get \-c800722120000 prog.c
602.)b
603will retrieve whatever version was current
604as of July 22, 1980
605at 12:00 noon.
606Trailing components can be stripped off
607(defaulting to their highest legal value),
608and punctuation can be inserted in the obvious
609places;
610for example,
611the above line could be equivalently stated:
612.(b
613sccs get \-c"80/07/22 12:00:00" prog.c
614.)b
615.sh 2 "Selectively deleting old deltas"
616.pp
617Suppose that you later decided
618that you liked the changes in delta 1.4,
619but that delta 1.3 should be removed.
620You could do this by
621.i excluding
622delta 1.3:
623.(b
624sccs edit \-x1.3 prog.c
625.)b
626When delta 1.5 is made,
627it will include the changes made
628in delta 1.4,
629but will exclude the changes made
630in delta 1.3.
631You can exclude a range of deltas
632using a dash.
633For example,
634if you want to get rid of 1.3 and 1.4
635you can use:
636.(b
637sccs edit \-x1.3\-1.4 prog.c
638.)b
639which will exclude all deltas from 1.3 to 1.4.
640Alternatively,
641.(b
642sccs edit \-x1.3\-1 prog.c
643.)b
644will exclude a range of deltas
645from 1.3 to the current highest delta in release 1.
646.pp
647In certain cases when using
648.b \-x
649(or
650.b \-i ;
651see below)
652there will be conflicts
653between versions;
654for example, it may be necessary
655to both include and delete
656a particular line.
657If this happens,
658\*S always prints out a message
659telling the range of lines effected;
660these lines should then be examined very carefully
661to see if the version \*S got
662is ok.
663.pp
664Since each delta
665(in the sense of
666.q "a set of changes" )
667can be excluded at will,
668that this makes it most useful
669to put each semantically distinct change
670into its own delta.
671.sh 1 "Auditing Changes"
672.sh 2 "The prt command"
673.pp
674When you created a delta,
675you presumably gave a reason for the delta
676to the
677.q "comments?"
678prompt.
679To print out these comments later,
680use:
681.(b
682sccs prt prog.c
683.)b
684This will produce
685a report
686for each delta
687of the \*I,
688time and date of creation,
689user who created the delta,
690number of lines inserted, deleted, and unchanged,
691and the comments associated with the delta.
692For example, the output of the above command might be:
693.(b
694D 1.2 80/08/29 12:35:31 bill 2 1 00005/00003/00084
695removed "-q" option
696.sp \n(psu
697D 1.1 79/02/05 00:19:31 eric 1 0 00087/00000/00000
698date and time created 80/06/10 00:19:31 by eric
699.)b
700.sh 2 "Finding why lines were inserted"
701.pp
702To find out
703why you inserted lines,
704you can get a copy of the file
705with each line
706preceded by the \*I that created it:
707.(b
708sccs get \-m prog.c
709.)b
710You can then find out
711what this delta did
712by printing the comments using
713.i prt .
714.pp
715To find out what lines are associated with a particular delta
716(\c
717.i e.g. ,
7181.3),
719use:
720.(b
721sccs get \-m \-p prog.c \(bv grep \'^1.3\'
722.)b
723The
724.b \-p
725flag causes \*S to output the generated source
726to the standard output rather than to a file.
727.sh 2 "Finding what changes you have made"
728.pp
729When you are editing a file,
730you can find out what changes you have made using:
731.(b
732sccs diffs prog.c
733.)b
734Most of the ``diff'' flags can be used.
735To pass the
736.b \-c
737flag,
738use
739.b \-C .
740.pp
741To compare two versions that are in deltas,
742use:
743.(b
744sccs sccsdiff -r1.3 -r1.6 prog.c
745.)b
746to see the differences between delta 1.3 and delta 1.6.
747.sh 1 "Shorthand Notations"
748.pp
749There are several sequences of commands that get
750executed frequently.
751.i Sccs
752tries to make it easy to do these.
753.sh 2 "Delget"
754.pp
755A frequent requirement is to make a delta of some file
756and then get that file.
757This can be done by using:
758.(b
759sccs delget prog.c
760.)b
761which is entirely equivalent to using:
762.(b
763sccs delta prog.c
764sccs get prog.c
765.)b
766The
767.q deledit
768command is equivalent to
769.q delget
770except that the
771.q edit
772command is used
773instead of the
774.q get
775command.
776.sh 2 "Fix"
777.pp
778Frequently, there are small bugs
779in deltas,
780e.g., compilation errors,
781for which there is no reason to maintain an audit trail.
782To
783.i replace
784a delta, use:
785.(b
786sccs fix \-r1.4 prog.c
787.)b
788This will get a copy of delta 1.4 of prog.c for you to edit
789and then delete delta 1.4 from the \*S file.
790When you do a delta of prog.c,
791it will be delta 1.4 again.
792The \-r flag must be specified,
793and the delta that is specified must be a leaf delta,
794i.e., no other deltas may have been made subsequent
795to the creation of that delta.
796.sh 2 "Unedit"
797.pp
798If you found you edited a file
799that you did not want to edit,
800you can back out by using:
801.(b
802sccs unedit prog.c
803.)b
804.sh 2 "The \-d flag"
805.pp
806If you are working on a project
807where the \*S code is in a directory somewhere,
808you may be able to simplify things
809by using a shell alias.
810For example,
811the alias:
812.(b
813alias syssccs sccs \-d/usr/src
814.)b
815will allow you to issue commands such as:
816.(b
817syssccs edit cmd/who.c
818.)b
819which will look for the file
820.q "/usr/src/cmd/SCCS/who.c" .
821The file
822.q who.c
823will always be created in your current directory
824regardless of the value of the \-d flag.
825.sh 1 "Using \*S on a Project"
826.pp
827Working on a project with several people
828has its own set of special problems.
829The main problem occurs when two people
830modify a file at the same time.
831\*S prevents this by locking an s-file
832while it is being edited.
833.pp
834As a result,
835files should not be reserved for editing
836unless they are actually being edited at the time,
837since this will prevent other people on the project
838from making necessary changes.
839For example,
840a good scenario for working might be:
841.(b
842sccs edit a.c g.c t.c
843vi a.c g.c t.c
844# do testing of the (experimental) version
845sccs delget a.c g.c t.c
846sccs info
847# should respond "Nothing being edited"
848make install
849.)b
850.pp
851As a general rule,
852all source files should be deltaed
853before installing the program for general use.
854This will insure that it is possible
855to restore any version in use at any time.
856.sh 1 "Saving Yourself"
857.sh 2 "Recovering a munged edit file"
858.pp
859Sometimes you may find
860that you have destroyed or trashed
861a file that you were trying to edit\**.
862.(f
863\**Or given up and decided to start over.
864.)f
865Unfortunately,
866you can't just remove it
867and re-\c
868.i edit
869it;
870\*S keeps track
871of the fact
872that someone is trying to edit it,
873so it won't let you do it again.
874Neither can you just get it using
875.i get ,
876since that would expand the Id keywords.
877Instead,
878you can say:
879.(b
880sccs get \-k prog.c
881.)b
882This will not expand the Id keywords,
883so it is safe to do a delta
884with it.
885.pp
886Alternately,
887you can
888.i unedit
889and
890.i edit
891the file.
892.sh 2 "Restoring the s-file"
893.pp
894In particularly bad circumstances,
895the \*S file itself
896may get munged.
897The most common way this happens
898is that it gets edited.
899Since \*S keeps a checksum,
900you will get errors every time you read the file.
901To fix this checksum, use:
902.(b
903sccs admin \-z prog.c
904.)b
905.sh 1 "Using the Admin Command"
906.pp
907There are a number of parameters that can be set
908using the
909.i admin
910command.
911The most interesting of these are flags.
912Flags can be added by using the
913.b \-f
914flag.
915For example:
916.(b
917sccs admin \-fd1 prog.c
918.)b
919sets the
920.q d
921flag to the value
922.q 1 .
923This flag can be deleted by using:
924.(b
925sccs admin \-dd prog.c
926.)b
927The most useful flags are:
928.nr ii 7n
929.ip "b"
930Allow branches to be made using the
931\-b
932flag to
933.i edit .
934.ip "d\fISID\fP"
935Default \*I to be used on a
936.i get
937or
938.i edit .
939If this is just a release number
940it constrains the
941version
942to a particular release only.
943.ip "i"
944Give a fatal error
945if there are no Id Keywords in a file.
946This is useful to guarantee that a version of the
947file does not get merged into the s-file
948that has the Id Keywords inserted as constants
949instead of internal forms.
950.ip "y"
951The
952.q type
953of the module.
954Actually,
955the value of this flag is unused by \*S
956except that it replaces the
957.b %\&Y\&%
958keyword.
959.pp
960The
961.b \-t\fIfile\fR
962flag can be used
963to store descriptive text
964from
965.i file .
966This descriptive text might be the documentation
967or a design and implementation document.
968Using the
969.b \-t
970flag insures that if the \*S file is sent,
971the documentation will be sent also.
972If
973.i file
974is omitted,
975the descriptive text is deleted.
976To see the descriptive text,
977use
978.q "prt \-t" .
979.pp
980The
981.i admin
982command can be used safely
983any number of times on files.
984A file need not be gotten
985for
986.i admin
987to work.
988.sh 1 "Maintaining Different Versions (Branches)"
989.pp
990Sometimes it is convenient
991to maintain an experimental version of a program
992for an extended period
993while normal maintenance continues
994on the version in production.
995This can be done using a
996.q branch.
997Normally deltas continue in a straight line,
998each depending on the delta before.
999Creating a branch
1000.q "forks off"
1001a version of the program.
1002.pp
1003The ability to create branches
1004must be enabled in advance using:
1005.(b
1006sccs admin \-fb prog.c
1007.)b
1008The
1009.b \-fb
1010flag can be specified when the
1011\*S file is first created.
1012.sh 2 "Creating a branch"
1013.pp
1014To create a branch, use:
1015.(b
1016sccs edit \-b prog.c
1017.)b
1018This will create a branch
1019with (for example) \*I 1.5.1.1.
1020The deltas for this version
1021will be numbered
10221.5.1.\c
1023.i n .
1024.sh 2 "Getting from a branch"
1025.pp
1026Deltas in a branch are normally not included
1027when you do a get.
1028To get these versions,
1029you will have to say:
1030.(b
1031sccs get \-r1.5.1 prog.c
1032.)b
1033.sh 2 "Merging a branch back into the main trunk"
1034.pp
1035At some point you will have finished the experiment,
1036and if it was successful
1037you will want to incorporate it into the release version.
1038But in the meantime
1039someone may have created a delta 1.6
1040that you don't want to lose.
1041The commands:
1042.(b
1043sccs edit \-i1.5.1.1\-1.5.1 prog.c
1044sccs delta prog.c
1045.)b
1046will merge all of your changes
1047into the release system.
1048If some of the changes conflict,
1049get will print an error;
1050the generated result
1051should be carefully examined
1052before the delta is made.
1053.sh 2 "A more detailed example"
1054.pp
1055The following technique might be used
1056to maintain a different version of a program.
1057First,
1058create a directory to contain the new version:
1059.(b
1060mkdir ../newxyz
1061cd ../newxyz
1062.)b
1063Edit a copy of the program
1064on a branch:
1065.(b
1066sccs \-d../xyz edit prog.c
1067.)b
1068When using the old version,
1069be sure to use the
1070.b \-b
1071flag to info, check, tell, and clean
1072to avoid confusion.
1073For example, use:
1074.(b
1075sccs info \-b
1076.)b
1077when in the directory
1078.q xyz .
1079.pp
1080If you want to save a copy of the program
1081(still on the branch)
1082back in the s-file,
1083you can use:
1084.(b
1085sccs -d../xyz deledit prog.c
1086.)b
1087which will do a delta on the branch
1088and reedit it for you.
1089.pp
1090When the experiment is complete, merge it back into the s-file
1091using delta:
1092.(b
1093sccs -d../xyz delta prog.c
1094.)b
1095At this point you must decide whether this version
1096should be merged back into the trunk
1097(\c
1098.i i.e.
1099the default version),
1100which may have undergone changes.
1101If so, it can be merged using the
1102.b \-i
1103flag to
1104.i edit
1105as described above.
1106.sh 2 "A warning"
1107.pp
1108Branches should be kept to a minimum.
1109After the first branch from the trunk,
1110\*I's are assigned rather haphazardly,
1111and the structure gets complex fast.
1112.sh 1 "Using \*S with Make"
1113.pp
1114\*S and make can be made to work together
1115with a little care.
1116A few sample makefiles
1117for common applications are shown.
1118.pp
1119There are a few basic entries that every makefile
1120ought to have.
1121These are:
1122.nr ii 1i
1123.ip a.out
1124(or whatever the makefile generates.)
1125This entry regenerates whatever this makefile is
1126supposed to regenerate.
1127If the makefile regenerates many things,
1128this should be called
1129.q all
1130and should in turn
1131have dependencies on everything
1132the makefile can generate.
1133.ip install
1134Moves the objects to the final
1135resting place,
1136doing any special
1137.i chmod 's
1138or
1139.i ranlib 's
1140as appropriate.
1141.ip sources
1142Creates all the source files from \*S files.
1143.ip clean
1144Removes all cruft from the directory.
1145.ip print
1146Prints the contents of the directory.
1147.lp
1148The examples shown below are only partial examples,
1149and may omit some of these entries
1150when they are deemed to be obvious.
1151.pp
1152The
1153.i clean
1154entry should not remove files that can be
1155regenerated from the \*S files.
1156It is sufficiently important to have the
1157source files around at all times
1158that the only time they should be removed
1159is when the directory is being mothballed.
1160To do this, the command:
1161.(b
1162sccs clean
1163.)b
1164can be used.
1165This will remove all files for which an s-file
1166exists,
1167but which is not being edited.
1168.sh 2 "To maintain single programs"
1169.pp
1170Frequently there are directories with several
1171largely unrelated programs
1172(such as simple commands).
1173These can be put into a single makefile:
1174.(b
1175LDFLAGS= \-i \-s
1176.sp \n(psu
1177prog: prog.o
1178 $(CC) $(LDFLAGS) \-o prog prog.o
1179prog.o: prog.c prog.h
1180.sp \n(psu
1181example: example.o
1182 $(CC) $(LDFLAGS) \-o example example.o
1183example.o: example.c
1184.sp \n(psu
1185\&.DEFAULT:
1186 sccs get $<
1187.)b
1188The trick here
1189is that the .DEFAULT rule
1190is called every time
1191something is needed
1192that does not exist,
1193and no other rule exists to make it.
1194The explicit dependency of the
1195.b \&.o
1196file on the
1197.b \&.c
1198file is important.
1199Another way of doing the same thing is:
1200.(b
1201SRCS= prog.c prog.h example.c
1202.sp \n(psu
1203LDFLAGS= \-i \-s
1204.sp \n(psu
1205prog: prog.o
1206 $(CC) $(LDFLAGS) \-o prog prog.o
1207prog.o: prog.h
1208.sp \n(psu
1209example: example.o
1210 $(CC) $(LDFLAGS) \-o example example.o
1211.sp \n(psu
1212sources: $(SRCS)
1213$(SRCS):
1214 sccs get $@
1215.)b
1216There are a couple of advantages to this approach:
1217(1) the explicit dependencies of the .o on the .c files are
1218not needed,
1219(2) there is an entry called "sources" so if you want to get
1220all the sources you can just say
1221.q "make sources" ,
1222and
1223(3) the makefile is less likely to do confusing things
1224since it won't try to
1225.i get
1226things that do not exist.
1227.sh 2 "To maintain a library"
1228.pp
1229Libraries that are largely static
1230are best updated using explicit commands,
1231since
1232.i make
1233doesn't know about updating them properly.
1234However,
1235libraries that are in the process of being developed
1236can be handled quite adequately.
1237The problem is that the .o files
1238have to be kept out of the library
1239as well as in the library.
1240.(b
1241# configuration information
1242OBJS= a.o b.o c.o d.o
1243SRCS= a.c b.c c.c d.s x.h y.h z.h
1244TARG= /usr/lib
1245.sp \n(psu
1246# programs
1247GET= sccs get
1248REL=
1249AR= \-ar
1250RANLIB= ranlib
1251.sp \n(psu
1252lib.a: $(OBJS)
1253 $(AR) rvu lib.a $(OBJS)
1254 $(RANLIB) lib.a
1255.sp \n(psu
1256install: lib.a
1257 sccs check
1258 cp lib.a $(TARG)/lib.a
1259 $(RANLIB) $(TARG)/lib.a
1260.sp \n(psu
1261sources: $(SRCS)
1262$(SRCS):
1263 $(GET) $(REL) $@
1264.sp \n(psu
1265print: sources
1266 pr *.h *.[cs]
1267clean:
1268 rm \-f *.o
1269 rm \-f core a.out $(LIB)
1270.)b
1271.pp
1272The
1273.q "$(REL)"
1274in the get
1275can be used to get old versions
1276easily; for example:
1277.(b
1278make b.o REL=\-r1.3
1279.)b
1280.pp
1281The
1282.i install
1283entry includes the line
1284.q "sccs check"
1285before anything else.
1286This guarantees that all the s-files
1287are up to date
1288(\c
1289.i i.e. ,
1290nothing is being edited),
1291and will abort the
1292.i make
1293if this condition is not met.
1294.sh 2 "To maintain a large program"
1295.(b
1296OBJS= a.o b.o c.o d.o
1297SRCS= a.c b.c c.y d.s x.h y.h z.h
1298.sp \n(psu
1299GET= sccs get
1300REL=
1301.sp \n(psu
1302a.out: $(OBJS)
1303 $(CC) $(LDFLAGS) $(OBJS) $(LIBS)
1304.sp \n(psu
1305sources: $(SRCS)
1306$(SRCS):
1307 $(GET) $(REL) $@
1308.)b
1309(The
1310.i print
1311and
1312.i clean
1313entries are identical to the previous case.)
1314This makefile requires copies of the source and object files
1315to be kept during development.
1316It is probably also wise to include lines of the form:
1317.(b
1318a.o: x.h y.h
1319b.o: z.h
1320c.o: x.h y.h z.h
1321z.h: x.h
1322.)b
1323so that modules will be recompiled
1324if header files change.
1325.pp
1326Since
1327.i make
1328does not do transitive closure on dependencies,
1329you may find in some makefiles lines like:
1330.(b
1331z.h: x.h
1332 touch z.h
1333.)b
1334This would be used in cases where file z.h
1335has a line:
1336.(b
1337#include "x.h"
1338.)b
1339in order to bring the mod date of z.h in line
1340with the mod date of x.h.
1341When you have a makefile such as above,
1342the
1343.i touch
1344command can be removed completely;
1345the equivalent effect will be achieved
1346by doing an automatic
1347.i get
1348on z.h.
1349.sh 1 "Further Information"
1350.pp
1351The
1352.i "SCCS/PWB User's Manual"
1353gives a deeper description
1354of how to use \*S.
1355Of particular interest
1356are the numbering of branches,
1357the l-file,
1358which gives a description of what deltas were used on a get,
1359and certain other \*S commands.
1360.pp
1361The \*S manual pages
1362are a good last resort.
1363These should be read by software managers
1364and by people who want to know
1365everything about everything.
1366.pp
1367Both of these documents were written without the
1368.i sccs
1369front end in mind,
1370so most of the examples are slightly different from those
1371in this document.
1372.bp
1373.sz 12
1374.ce
1375.b "Quick Reference"
1376.sz
1377.sp 2
1378.sh 1 Commands 1
1379.pp
1380The following commands should all be preceded with
1381.q sccs .
1382This list is not exhaustive;
1383for more options see
1384.i "Further Information" .
1385.ip get 9n
1386Gets files for compilation (not for editing).
1387Id keywords are expanded.
1388.ba 9n
1389.nr ii 8n
1390.ip \-r\fI\*I\fP
1391Version to get.
1392.ip \-p
1393Send to standard output rather than to the actual file.
1394.ip \-k
1395Don't expand id keywords.
1396.ip \-i\fIlist\fP
1397List of deltas to include.
1398.ip \-x\fIlist\fP
1399List of deltas to exclude.
1400.ip \-m
1401Precede each line with \*I of creating delta.
1402.ip \-c\fIdate\fP
1403Don't apply any deltas created after
1404.i date.
1405.ba
1406.ip edit 9n
1407Gets files for editing.
1408Id keywords are not expanded.
1409Should be matched with a
1410.i delta
1411command.
1412.ba 9n
1413.nr ii 8n
1414.ip \-r\fI\*I\fP
1415Same as
1416.i get .
1417If
1418.i \*I
1419specifies a release that does not yet exist,
1420the highest numbered delta is retrieved
1421and the new delta is numbered with
1422.i \*I .
1423.ip \-b
1424Create a branch.
1425.ip \-i\fIlist\fP
1426Same as
1427.i get .
1428.ip \-x\fIlist\fP
1429Same as
1430.i get .
1431.ba
1432.ip delta 9n
1433Merge a file gotten using
1434.i edit
1435back into the s-file.
1436Collect comments about why this delta was made.
1437.ip unedit 9n
1438Remove a file that has been edited previously
1439without merging the changes into the s-file.
1440.ip prt 9n
1441Produce a report of changes.
1442.ba 9n
1443.nr ii 5n
1444.ip \-t
1445Print the descriptive text.
1446.ip \-e
1447Print (nearly) everything.
1448.ba
1449.ip info 9n
1450Give a list of all files being edited.
1451.ba 9n
1452.nr ii 5n
1453.ip \-b
1454Ignore branches.
1455.ip \-u[\fIuser\fP]
1456Ignore files not being edited by
1457.i user .
1458.ba
1459.ip check 9n
1460Same as
1461.i info ,
1462except that nothing is printed if nothing is being edited
1463and exit status is returned.
1464.ip tell 9n
1465Same as
1466.i info ,
1467except that one line is produced per file being edited containing
1468only the file name.
1469.ip clean 9n
1470Remove all files that can be regenerated from the
1471s-file.
1472.ip what 9n
1473Find and print id keywords.
1474.ip admin 9n
1475Create or set parameters on s-files.
1476.ba 9n
1477.nr ii 8n
1478.ip \-i\fIfile\fP
1479Create, using
1480.i file
1481as the initial contents.
1482.ip \-z
1483Rebuild the checksum in case
1484the file has been trashed.
1485.ip \-f\fIflag\fP
1486Turn on the
1487.i flag .
1488.ip \-d\fIflag\fP
1489Turn off (delete) the
1490.i flag .
1491.ip \-t\fIfile\fP
1492Replace the descriptive text
1493in the s-file with the contents of
1494.i file .
1495If
1496.i file
1497is omitted,
1498the text is deleted.
1499Useful for storing documentation
1500or
1501.q "design & implementation"
1502documents to insure they get distributed with the
1503s-file.
1504.lp
1505Useful flags are:
1506.ip b
1507Allow branches to be made using the \-b flag to
1508.i edit.
1509.ip d\fI\*I\fP
1510Default \*I to be used
1511on a
1512.i get
1513or
1514.i edit .
1515.ip i
1516Cause
1517.q "No Id Keywords"
1518error message
1519to be a fatal error rather than a warning.
1520.ip t
1521The module
1522.q type ;
1523the value of this flag replaces the
1524.b %\&Y\&%
1525keyword.
1526.ba
1527.ip fix 9n
1528Remove a delta and reedit it.
1529.ip delget 9n
1530Do a
1531.i delta
1532followed by a
1533.i get .
1534.ip deledit 9n
1535Do a
1536.i delta
1537followed by an
1538.i edit .
1539.sh 1 "Id Keywords"
1540.nr ii 6n
1541.ip "%\&Z\&%"
1542Expands to
1543.q @\&(#)
1544for the
1545.i what
1546command to find.
1547.ip "%\&M\&%"
1548The current module name,
1549.i e.g.,
1550.q prog.c .
1551.ip "%\&I\&%"
1552The highest \*I applied.
1553.ip "%\&W\&%"
1554A shorthand for
1555.q "%\&Z\&%%\&M\&% <tab> %\&I\&%" .
1556.ip "%\&G\&%"
1557The date of the delta
1558corresponding to the
1559.q "%\&I\&%"
1560keyword.
1561.ip "%\&R\&%"
1562The current release number,
1563.i i.e. ,
1564the first component of the
1565.q "%\&I\&%"
1566keyword.
1567.ip "%\&Y\&%"
1568Replaced by the value of the
1569.b t
1570flag
1571(set by
1572.i admin ).