1 .\" $NetBSD: rcs.ms,v 1.1.1.2 1996/10/13 21:57:13 veego Exp $
3 .\" Format this file with:
4 .\" pic file | tbl | troff -ms
6 .\" \*s stands for $, and avoids problems when this file is checked in.
23 .\" Id: rcs.ms,v 5.4 1995/06/01 16:23:43 eggert Exp
26 RCS\*-A System for Version Control
31 Department of Computer Sciences
33 West Lafayette, Indiana 47907
36 An important problem in program development and maintenance is version control,
37 i.e., the task of keeping a software system consisting of many versions and
38 configurations well organized.
39 The Revision Control System (RCS)
40 is a software tool that assists with that task.
41 RCS manages revisions of text documents, in particular source programs,
42 documentation, and test data.
43 It automates the storing, retrieval, logging and identification of revisions,
44 and it provides selection mechanisms for composing configurations.
45 This paper introduces basic version control concepts and
46 discusses the practice of version control
48 For conserving space, RCS stores deltas, i.e., differences between
49 successive revisions. Several delta storage methods are discussed.
50 Usage statistics show that RCS's delta storage method is
51 space and time efficient.
52 The paper concludes with a detailed survey of version control tools.
54 \fBKeywords\fR: configuration management, history management,
55 version control, revisions, deltas.
58 An earlier version of this paper was published in
59 .I "Software\*-Practice & Experience"
61 7 (July 1985), 637-654.
68 Version control is the task of keeping software
69 systems consisting of many versions and configurations well organized.
70 The Revision Control System (RCS) is a set of UNIX
71 commands that assist with that task.
73 RCS' primary function is to manage \fIrevision groups\fR.
74 A revision group is a set of text documents, called \fIrevisions\fR,
75 that evolved from each other. A new revision is
76 created by manually editing an existing one.
77 RCS organizes the revisions into an ancestral tree. The initial revision
78 is the root of the tree, and the tree edges indicate
79 from which revision a given one evolved.
80 Besides managing individual revision groups, RCS provides
81 flexible selection functions for composing configurations.
82 RCS may be combined with MAKE\u1\d,
83 resulting in a powerful package for version control.
85 RCS also offers facilities for
86 merging updates with customer modifications,
87 for distributed software development, and
88 for automatic identification.
89 Identification is the `stamping'
90 of revisions and configurations with unique markers.
91 These markers are akin to serial numbers,
92 telling software maintainers unambiguously which configuration
95 RCS is designed for both production and experimental
97 In production environments,
98 access controls detect update conflicts and prevent overlapping changes.
99 In experimental environments, where strong controls are
100 counterproductive, it is possible to loosen the controls.
102 Although RCS was originally intended for programs, it is useful for any
103 text that is revised frequently and whose previous revisions must be
104 preserved. RCS has been applied successfully to store the source
105 text for drawings, VLSI layouts, documentation, specifications,
106 test data, form letters and articles.
108 This paper discusses the practice of
109 version control using RCS.
110 It also introduces basic version control concepts,
111 useful for clarifying current practice and designing similar systems.
112 Revision groups of individual components are treated in the next three sections,
113 and the extensions to configurations follow.
114 Because of its size, a survey of version control tools
115 appears at the end of the paper.
117 Getting started with RCS
119 Suppose a text file \fIf.c\fR is to be placed under control of RCS.
120 Invoking the check-in command
124 creates a new revision group with the contents of
125 \fIf.c\fR as the initial
126 revision (numbered 1.1)
127 and stores the group into the file \fIf.c,v\fR.
128 Unless told otherwise, the command deletes \fIf.c\fR.
129 It also asks for a description of the group.
130 The description should state the common purpose of all revisions in the group,
131 and becomes part of the group's documentation.
132 All later check-in commands will ask for a log entry,
133 which should summarize the changes made.
134 (The first revision is assigned a default log message,
135 which just records the fact that it is the initial revision.)
137 Files ending in \fI,v\fR
138 are called \fIRCS files\fR (\fIv\fR stands for \fIv\fRersions);
139 the others are called working files.
140 To get back the working file \fIf.c\fR in the previous example,
141 execute the check-out command:
146 This command extracts the latest revision from
147 the revision group \fIf.c,v\fR and writes
149 The file \fIf.c\fR can now be edited and, when finished,
150 checked back in with \fIci\fR:
154 \fICi\fR assigns number 1.2 to
156 If \fIci\fR complains with the message
158 ci error: no lock set by <login>
160 then the system administrator has decided to configure RCS for a
161 production environment by enabling the `strict locking feature'.
162 If this feature is enabled, all RCS files are initialized
163 such that check-in operations require a lock on the previous revision
164 (the one from which the current one evolved).
165 Locking prevents overlapping modifications if several people work on the same file.
166 If locking is required, the revision should
167 have been locked during the check-out by using
168 the option \fI\-l\fR:
172 Of course it is too late now for the check-out with locking, because
173 \fIf.c\fR has already been changed; checking out the file again
174 would overwrite the modifications.
175 (To prevent accidental overwrites, \fIco\fR senses the presence
176 of a working file and asks whether the user really intended to overwrite it.
177 The overwriting check-out is sometimes useful for
178 backing up to the previous revision.)
179 To be able to proceed with the check-in in the present case, first execute
183 This command retroactively locks the latest revision, unless someone
184 else locked it in the meantime. In this case, the two programmers
185 involved have to negotiate whose
186 modifications should take precedence.
188 If an RCS file is private, i.e., if only the owner of the file is expected
189 to deposit revisions into it, the strict locking feature is unnecessary and
191 If strict locking is disabled,
192 the owner of the RCS file need not have a lock for check-in.
193 For safety reasons, all others
194 still do. Turning strict locking off and on is done with the commands:
196 rcs \-U f.c \fRand\fP rcs \-L f.c
198 These commands enable or disable the strict locking feature for each RCS file
200 The system administrator only decides whether strict locking is
203 To reduce the clutter in a working directory, all RCS files can be moved
204 to a subdirectory with the name \fIRCS\fR.
205 RCS commands look first into that directory for RCS files.
206 All the commands presented above work
207 with the \fIRCS\fR subdirectory without change.\(dg
209 Pairs of RCS and working files can actually be specified in 3 ways:
210 a) both are given, b) only the working file is given, c) only the
212 If a pair is given, both files may have arbitrary path prefixes;
213 RCS commands pair them up intelligently.
216 It may be undesirable that \fIci\fR deletes the working file.
217 For instance, sometimes one would like to save the current revision,
218 but continue editing.
223 checks in \fIf.c\fR as usual, but performs an additional
224 check-out with locking afterwards. Thus, the working file does
225 not disappear after the check-in.
226 Similarly, the option
227 \fI\-u\fR does a check-in followed by a check-out without
228 locking. This option is useful if the file is needed for compilation after the check-in.
229 Both options update the identification markers in the working file
232 Besides the operations \fIci\fR and \fIco\fR, RCS provides the following
240 ident%extract identification markers
241 rcs%change RCS file attributes
242 rcsclean%remove unchanged working files (optional)
243 rcsdiff%compare revisions
244 rcsfreeze%record a configuration (optional)
245 rcsmerge%merge revisions
246 rlog%read log messages and other information in RCS files
248 A synopsis of these commands appears in the Appendix.
250 Automatic Identification
252 RCS can stamp source and object code with special identification strings,
253 similar to product and serial numbers.
254 To obtain such identification, place the marker
258 into the text of a revision, for instance inside a comment.
259 The check-out operation will replace this marker with a string of the form
261 \*sId: filename revisionnumber date time author state locker \*s
263 This string need never be touched, because \fIco\fR keeps it
264 up to date automatically.
265 To propagate the marker into object code, simply put
266 it into a literal character string. In C, this is done as follows:
268 static char rcsid[] = \&"\*sId\*s\&";
270 The command \fIident\fR extracts such markers from any file, in particular from
272 \fIIdent\fR helps to find out
273 which revisions of which modules were used in a given program.
274 It returns a complete and unambiguous component list,
275 from which a copy of the program can be reconstructed.
276 This facility is invaluable for program maintenance.
278 There are several additional identification markers, one for each component
284 has a similar function. It accumulates
285 the log messages that are requested during check-in.
286 Thus, one can maintain the complete history of a revision directly inside it,
287 by enclosing it in a comment.
288 Figure 1 is an edited version of a log contained in revision 4.1 of
289 the file \fIci.c\fR. The log appears at the beginning of the file,
290 and makes it easy to determine what the recent modifications were.
300 * Revision 4.1 1983/05/10 17:03:06 wft
301 * Added option \-d and \-w, and updated assignment of date, etc. to new delta.
302 * Added handling of default branches.
304 * Revision 3.9 1983/02/15 15:25:44 wft
305 * Added call to fastcopy() to copy remainder of RCS file.
307 * Revision 3.8 1983/01/14 15:34:05 wft
308 * Added ignoring of interrupts while new RCS file is renamed;
309 * avoids deletion of RCS files by interrupts.
311 * Revision 3.7 1982/12/10 16:09:20 wft
312 * Corrected checking of return code from diff.
313 * An RCS file now inherits its mode during the first ci from the working file,
314 * except that write permission is removed.
318 Figure 1. Log entries produced by the marker \*sLog\*s.
324 Since revisions are stored in the form of differences,
326 physically stored once,
327 independent of the number of revisions present.
328 Thus, the \*sLog\*s marker incurs negligible space overhead.
330 The RCS Revision Tree
332 RCS arranges revisions in an ancestral tree.
333 The \fIci\fR command builds this tree; the auxiliary command \fIrcs\fR
335 The tree has a root revision, normally numbered 1.1, and successive revisions
336 are numbered 1.2, 1.3, etc. The first field of a revision number
337 is called the \fIrelease number\fR and the second one
338 the \fIlevel number\fR. Unless given explicitly,
339 the \fIci\fR command assigns a new revision number
340 by incrementing the level number of the previous revision.
341 The release number must be incremented explicitly, using the
342 \fI\-r\fR option of \fIci\fR.
343 Assuming there are revisions 1.1, 1.2, and 1.3 in the RCS file f.c,v, the command
345 ci \-r2.1 f.c \fRor\fP ci \-r2 f.c
347 assigns the number 2.1 to the new revision.
348 Later check-ins without the \fI\-r\fR option will assign the numbers 2.2, 2.3,
350 The release number should be incremented only at major transition points
351 in the development, for instance when a new release of a software product has
354 When are branches needed?
356 A young revision tree is slender:
357 It consists of only one branch, called the trunk.
358 As the tree ages, side branches may form.
359 Branches are needed in the following 4 situations.
360 .IP "\fITemporary fixes\fR"
362 Suppose a tree has 5 revisions grouped in 2 releases,
363 as illustrated in Figure 2.
364 Revision 1.3, the last one of release 1, is in operation at customer sites,
365 while release 2 is in active development.
382 Figure 2. A slender revision tree.
384 Now imagine a customer requesting a fix of
385 a problem in revision 1.3, although actual development has moved on
386 to release 2. RCS does not permit an extra
387 revision to be spliced in between 1.3 and 2.1, since that would not reflect
388 the actual development history. Instead, create a branch
389 at revision 1.3, and check in the fix on that branch.
390 The first branch starting at 1.3 has number 1.3.1, and
391 the revisions on that branch are numbered 1.3.1.1, 1.3.1.2, etc.
392 The double numbering is needed to allow for another
393 branch at 1.3, say 1.3.2.
394 Revisions on the second branch would be numbered
395 1.3.2.1, 1.3.2.2, and so on.
396 The following steps create
397 branch 1.3.1 and add revision 1.3.1.1:
405 %co \-r1.3 f.c% \*- check out revision 1.3
406 %edit f.c% \*- change it
407 %ci \-r1.3.1 f.c% \*- check it in on branch 1.3.1
412 This sequence of commands transforms the tree of Figure 2 into
414 Note that it may be necessary to incorporate the differences
415 between 1.3 and 1.3.1.1
416 into a revision at level 2. The operation \fIrcsmerge\fR automates this
417 process (see the Appendix).
431 line invis down from R21.s
433 arrow dashed right from RB1.e
434 arrow from R13.s to RB1.w
438 Figure 3. A revision tree with one side branch
440 .IP "\fIDistributed development and customer modifications\fR"
442 Assume a situation as in Figure 2, where revision 1.3 is in operation
443 at several customer sites,
444 while release 2 is in development.
445 Customer sites should use RCS to store the distributed software.
446 However, customer modifications should not be placed on the same branch
447 as the distributed source; instead, they should be placed on a side branch.
448 When the next software distribution arrives,
449 it should be appended to the trunk of
450 the customer's RCS file, and the customer
451 can then merge the local modifications back into the new release.
452 In the above example, a
453 customer's RCS file would contain the following tree, assuming
454 that the customer has received revision 1.3, added his local modifications
455 as revision 1.3.1.1, then received revision 2.4, and merged
456 2.4 and 1.3.1.1, resulting in 2.4.1.1.
470 arrow from R13.e to R24.w
471 line invis down from R21.s
473 arrow from R13.s to RB1.w
475 line invis down from R25.s
477 arrow from R24.s to RB2.w
481 Figure 4. A customer's revision tree with local modifications.
483 This approach is actually practiced in the CSNET project,
484 where several universities and a company cooperate
485 in developing a national computer network.
486 .IP "\fIParallel development\fR"
488 Sometimes it is desirable to explore an alternate design or
489 a different implementation technique in parallel with the
490 main line development. Such development
491 should be carried out on a side branch.
492 The experimental changes may later be moved into the main line, or abandoned.
493 .IP "\fIConflicting updates\fR"
495 A common occurrence is that one programmer
496 has checked out a revision, but cannot complete the assignment
497 for some reason. In the meantime, another person
498 must perform another modification
499 immediately. In that case, the second person should check-out the same revision,
500 modify it, and check it in on a side branch, for later merging.
502 Every node in a revision tree consists of the following attributes:
503 a revision number, a check-in date and time, the author's identification,
504 a log entry, a state and the actual text. All these attributes
505 are determined at the time the revision is checked in.
506 The state attribute indicates the status of a revision.
507 It is set automatically to `experimental' during check-in.
508 A revision can later be promoted to a higher status, for example
509 `stable' or `released'. The set of states is user-defined.
511 Revisions are represented as deltas
513 For conserving space, RCS stores revisions in the form
514 of deltas, i.e., as differences between revisions.
515 The user interface completely hides this fact.
517 A delta is a sequence of edit commands that transforms one string
518 into another. The deltas employed by RCS are line-based, which means
519 that the only edit commands allowed are insertion and deletion of lines.
520 If a single character in a line is changed, the
521 edit scripts consider the entire line changed.
522 The program \fIdiff\fR\u2\d
523 produces a small, line-based delta between pairs of text files.
524 A character-based edit script would take much longer to compute,
525 and would not be significantly shorter.
527 Using deltas is a classical space-time tradeoff: deltas reduce the
528 space consumed, but increase access time.
529 However, a version control tool should impose as little delay
530 as possible on programmers.
531 Excessive delays discourage the use of version controls,
532 or induce programmers to take shortcuts that compromise system integrity.
533 To gain reasonably fast access time for both editing and compiling,
534 RCS arranges deltas in the following way.
535 The most recent revision on the trunk is stored intact.
536 All other revisions on the trunk are stored as reverse deltas.
537 A reverse delta describes how to go backward in the development history:
538 it produces the desired revision if applied to the successor of that revision.
539 This implementation has the advantage
540 that extraction of the latest revision is a simple and fast copy
542 Adding a new revision to the trunk is also fast: \fIci\fR simply
543 adds the new revision intact, replaces the previous
544 revision with a reverse delta, and keeps the rest of the old deltas.
545 Thus, \fIci\fR requires the computation
546 of only one new delta.
548 Branches need special treatment. The naive solution would be to
549 store complete copies for the tips of all branches.
550 Clearly, this approach would cost too much space. Instead,
551 RCS uses \fIforward\fR deltas for branches. Regenerating a revision
552 on a side branch proceeds as follows. First, extract the latest revision
553 on the trunk; secondly, apply reverse deltas until the fork revision for
554 the branch is obtained; thirdly, apply forward deltas until the desired
555 branch revision is reached. Figure 5 illustrates a tree with
556 one side branch. Triangles pointing to the left and right represent
557 reverse and forward deltas, respectively.
561 define BD X [line invis $1 right .5;
562 line up .3 then left .5 down .3 then right .5 down .3 then up .3] X
564 define FD X [line invis $1 right .5;
565 line left .5 down .3 then up .6 then right .5 down .3;] X
569 arrow right from D11.e
571 arrow right from D12.e
573 arrow right from D13.e
575 arrow right from D21.e
577 line invis down from D21.s
579 arrow from D13.se to F1.w
580 arrow from F1.e right
586 Figure 5. A revision tree with reverse and forward deltas.
589 Although implementing fast check-out for the latest trunk revision,
590 this arrangement has the disadvantage that generation of other revisions
591 takes time proportional to the number of deltas applied. For example,
592 regenerating the branch tip in Figure 5 requires application of five
593 deltas (including the initial one). Since usage statistics show that
594 the latest trunk revision is the one that is retrieved in 95 per cent
595 of all cases (see the section on usage statistics), biasing check-out time
596 in favor of that revision results in significant savings.
597 However, careful implementation of the delta application process is
598 necessary to provide low retrieval overhead for other revisions, in
599 particular for branch tips.
601 There are several techniques for delta application.
602 The naive one is to pass each delta to a general-purpose text editor.
603 A prototype of RCS invoked the UNIX editor \fIed\fR both
604 for applying deltas and for expanding the identification markers.
605 Although easy to implement, performance was poor, owing to the
606 high start-up costs and excess generality of \fIed\fR. An intermediate
607 version of RCS used a special-purpose, stream-oriented editor.
608 This technique reduced the cost of applying a delta to the cost of
609 checking out the latest trunk revision. The reason for this behavior
610 is that each delta application involves a complete pass over
611 the preceding revision.
613 However, there is a much better algorithm. Note that the deltas are
614 line oriented and that most of the work of a stream editor involves
615 copying unchanged lines from one revision to the next. A faster
616 algorithm avoids unnecessary copying of character strings by using
618 A piece table is a one-dimensional array, specifying how a given
619 revision is `pieced together' from lines in the RCS file.
620 Suppose piece table \fIPT\dr\u\fR represents revision \fIr\fR.
621 Then \fIPT\dr\u[i]\fR contains the starting position of line \fIi\fR
623 Application of the next delta transforms piece table \fIPT\dr\u\fR
624 into \fIPT\dr+1\u\fR. For instance, a delete command removes a
625 series of entries from the piece table. An insertion command inserts
626 new entries, moving the entries following the insertion point further down the
627 array. The inserted entries point to the text lines in the delta.
628 Thus, no I/O is involved except for reading the delta itself. When all
629 deltas have been applied to the piece table, a sequential pass
630 through the table looks up each line in the RCS file and copies it to
631 the output file, updating identification markers at the same time.
632 Of course, the RCS file must permit random access, since the copied
633 lines are scattered throughout that file. Figure 6 illustrates an
634 RCS file with two revisions and the corresponding piece tables.
638 \fIFigure 6 is not available.\fP
641 Figure 6. An RCS file and its piece tables
644 The piece table approach has the property that the time for applying a single
645 delta is roughly determined by the size of the delta, and not by the
646 size of the revision. For example, if a delta is
647 10 per cent of the size of a revision, then applying it takes only
648 10 per cent of the time to generate the latest trunk revision. (The stream
649 editor would take 100 per cent.)
651 There is an important alternative for representing deltas that affects
652 performance. SCCS\u3\d,
653 a precursor of RCS, uses \fIinterleaved\fR deltas.
654 A file containing interleaved deltas is partitioned into blocks of lines.
655 Each block has a header that specifies to which revision(s) the block
656 belongs. The blocks are sorted out in such a way that a single
657 pass over the file can pick up all the lines belonging to a given
658 revision. Thus, the regeneration time for all revisions is the same:
659 all headers must be inspected, and the associated blocks either copied
660 or skipped. As the number of revisions increases, the cost of retrieving
661 any revision is much higher than the cost of checking out the
662 latest trunk revision with reverse deltas. A detailed comparison
663 of SCCS's interleaved deltas and RCS's reverse deltas can be found
665 This reference considers the version of RCS with the
666 stream editor only. The piece table method improves performance
667 further, so that RCS is always faster than SCCS, except if 10
668 or more deltas are applied.
670 Additional speed-up for both delta methods can be obtained by caching
671 the most recently generated revision, as has been implemented in DSEE.\u5\d
672 With caching, access time to frequently used revisions can approach normal file
673 access time, at the cost of some additional space.
675 Locking: A Controversial Issue
677 The locking mechanism for RCS was difficult to design.
678 The problem and its solution are first presented in their `pure' form,
679 followed by a discussion of the complications
680 caused by `real-world' considerations.
682 RCS must prevent two or more persons from depositing competing changes of the
684 Suppose two programmers check out revision 2.4 and
685 modify it. Programmer A checks in a revision before programmer B\&.
686 Unfortunately, programmer B has not seen A's
687 changes, so the effect is that A's changes are covered up by B's deposit.
688 A's changes are not lost since all revisions
689 are saved, but they are confined to a single revision.\(dd
691 Note that this problem is entirely different from the atomicity problem.
693 concurrent update operations on the same RCS file cannot be permitted,
694 because that may result in inconsistent data.
695 Atomic updates are essential (and implemented in RCS),
696 but do not solve the conflict discussed here.
699 This conflict is prevented in RCS by locking.
700 Whenever someone intends to edit a revision (as opposed
701 to reading or compiling it), the revision should be checked out
703 using the \fI\-l\fR option on \fIco\fR. On subsequent check-in,
704 \fIci\fR tests the lock and then removes it.
705 At most one programmer at a time may
706 lock a particular revision, and only this programmer may check in
707 the succeeding revision.
708 Thus, while a revision is locked, it is the exclusive responsibility
711 An important maxim for software tools like RCS is that they must
712 not stand in the way of making progress with a project.
713 This consideration leads to several weakenings of the locking mechanism.
714 First of all, even if a revision is locked, it can
715 still be checked out. This is necessary if other people
716 wish to compile or inspect the locked revision
717 while the next one is in preparation. The only operations they
718 cannot do are to lock the revision or to check in the succeeding one. Secondly,
719 check-in operations on other branches in the RCS file are still possible; the
720 locking of one revision does not affect any other revision.
721 Thirdly, revisions are occasionally locked for a long period of time
722 because a programmer is absent or otherwise unable to complete
723 the assignment. If another programmer has to make a pressing change,
724 there are the following three alternatives for making progress:
725 a) find out who is holding the lock and ask that person to release it;
726 b) check out the locked revision, modify it, check it
727 in on a branch, and merge the changes later;
728 c) break the lock. Breaking a lock leaves a highly visible
729 trace, namely an electronic mail message that is sent automatically to the
730 holder of the lock, recording the breaker and a commentary requested from him.
731 Thus, breaking locks is tolerated under certain circumstances,
732 but will not go unnoticed.
733 Experience has shown that the automatic mail message attaches a high enough
734 stigma to lock breaking,
735 such that programmers break locks only in real emergencies,
736 or when a co-worker resigns and leaves locked revisions behind.
738 If an RCS file is private, i.e., when a programmer owns an RCS file
739 and does not expect anyone else to perform check-in operations,
740 locking is an unnecessary nuisance.
742 the `strict locking feature' discussed earlier may be disabled,
743 provided that file protection
744 is set such that only the owner may write the RCS file.
745 This has the effect that only the owner can check-in revisions,
746 and that no lock is needed for doing so.
749 each RCS file contains an access list that specifies the users
750 who may execute update operations. If an access list is empty,
751 only normal UNIX file protection applies. Thus, the access list is
752 useful for restricting the set of people who would otherwise have update
753 permission. Just as with locking, the access list
754 has no effect on read-only operations such as \fIco\fR. This approach
755 is consistent with the UNIX philosophy of openness, which contributes
756 to a productive software development environment.
758 Configuration Management
760 The preceding sections described how RCS deals with revisions of individual
761 components; this section discusses how to handle configurations.
762 A configuration is a set of revisions, where each revision comes
763 from a different revision group, and the revisions are selected
764 according to a certain criterion.
766 in order to build a functioning compiler, the `right'
767 revisions from the scanner, the parser, the optimizer
768 and the code generator must be combined.
769 RCS, in conjunction with MAKE,
770 provides a number of facilities to effect a smooth selection.
772 RCS Selection Functions
774 .IP "\fIDefault selection\fR"
776 During development, the usual selection criterion is to choose
777 the latest revision of all components. The \fIco\fR command
778 makes this selection by default. For example, the command
782 retrieves the latest revision on the default branch of each RCS file
783 in the current directory.
784 The default branch is usually the trunk, but may be
785 set to be a side branch.
786 Side branches as defaults are needed in distributed software development,
787 as discussed in the section on the RCS revision tree.
789 .IP "\fIRelease based selection\fR"
791 Specifying a release or branch number selects the latest revision in
792 that release or branch.
797 retrieves the latest revision with release number 2 from each RCS file.
798 This selection is convenient if a release has been completed and
799 development has moved on to the next release.
801 .IP "\fIState and author based selection\fR"
803 If the highest level number within a given release number
804 is not the desired one,
805 the state attribute can help. For example,
807 co \-r2 \-sReleased *,v
809 retrieves the latest revision with release number 2 whose state attribute
811 Of course, the state attribute has to be set appropriately, using the
812 \fIci\fR or \fIrcs\fR commands.
813 Another alternative is to select a revision by its author,
814 using the \fI\-w\fR option.
816 .IP "\fIDate based selection\fR"
818 Revisions may also be selected by date.
819 Suppose a release of an entire system was
820 completed and current on March 4, at 1:00 p.m. local time. Then the command
822 co \-d'March 4, 1:00 pm LT' *,v
824 checks out all the components of that release, independent of the numbering.
825 The \fI\-d\fR option specifies a `cutoff date', i.e.,
826 the revision selected has a check-in date that
827 is closest to, but not after the date given.
828 .IP "\fIName based selection\fR"
830 The most powerful selection function is based on assigning symbolic
831 names to revisions and branches.
832 In large systems, a single release number or date is not sufficient
833 to collect the appropriate revisions from all groups.
834 For example, suppose one wishes to combine release 2
835 of one subsystem and release 15 of another.
836 Most likely, the creation dates of those releases differ also.
837 Thus, a single revision number or date passed to the \fIco\fR command
838 will not suffice to select the right revisions.
839 Symbolic revision numbers solve this problem.
840 Each RCS file may contain a set of symbolic names that are mapped
841 to numeric revision numbers. For example, assume
842 the symbol \fIV3\fR is bound to release number 2 in file \fIs,v\fR, and to
843 revision number 15.9 in \fIt,v\fR.
844 Then the single command
848 retrieves the latest revision of release 2 from \fIs,v\fR,
849 and revision 15.9 from \fIt,v\fR.
850 In a large system with many modules, checking out all
851 revisions with one command greatly simplifies configuration management.
853 Judicious use of symbolic revision numbers helps with organizing
854 large configurations.
855 A special command, \fIrcsfreeze\fR,
856 assigns a symbolic revision number to a selected revision
858 \fIRcsfreeze\fR effectively freezes a configuration.
859 The assigned symbolic revision number selects all components
860 of the configuration.
861 If necessary, symbolic numbers
862 may even be intermixed with numeric ones. Thus, \fIV3.5\fR in the
864 would select revision 2.5 in \fIs,v\fR and branch 15.9.5 in \fIt,v\fR.
866 The options \fI\-r\fR, \fI\-s\fR, \fI\-w\fR and \fI\-d\fR
867 may be combined. If a branch is given, the latest revision
868 on that branch satisfying all conditions is retrieved;
869 otherwise, the default branch is used.
871 Combining MAKE and RCS
874 is a program that processes configurations.
875 It is driven by configuration specifications
876 recorded in a special file, called a `Makefile'.
877 MAKE avoids redundant processing steps
878 by comparing creation dates of source and processed objects.
879 For example, when instructed to compile all
880 modules of a given system, it only recompiles
881 those source modules that were changed
882 since they were processed last.
884 MAKE has been extended with an auto-checkout feature for RCS.*
886 This auto-checkout extension is available only in some versions of MAKE,
889 When a certain file to be processed is not present,
890 MAKE attempts a check-out operation.
891 If successful, MAKE performs the required processing, and then deletes
892 the checked out file to conserve space.
893 The selection parameters discussed above can be passed to MAKE
894 either as parameters, or directly embedded in the Makefile.
895 MAKE has also been extended to search the subdirectory named \fIRCS\fR
896 for needed files, rather than just the current working directory.
897 However, if a working file is present, MAKE totally ignores the corresponding
898 RCS file and uses the working file.
899 (In newer versions of MAKE distributed by AT&T and others,
901 achieved with the rule DEFAULT, instead of a special extension of MAKE.
902 However, a file checked out by the rule DEFAULT
903 will not be deleted after processing. \fIRcsclean\fR can be
904 used for that purpose.)
906 With auto-checkout, RCS/MAKE can effect a selection rule
907 especially tuned for multi-person software development and maintenance.
909 programmers should obtain configurations that consist of
910 the revisions they have personally checked out plus the latest
911 checked in revision of all other revision groups.
912 This schema can be set up as follows.
914 Each programmer chooses a working directory
915 and places into it a symbolic link, named \fIRCS\fR,
916 to the directory containing the relevant RCS files.
917 The symbolic link makes sure that \fIco\fR and \fIci\fR
918 operations need only specify the working files, and that
919 the Makefile need not be changed.
920 The programmer then checks out the needed files and modifies them.
922 it composes configurations by selecting those
923 revisions that are checked out, and the rest from the
924 subdirectory \fIRCS\fR.
925 The latter selection may be controlled by a symbolic
926 revision number or any of the other selection criteria.
927 If there are several programmers editing in separate working directories,
928 they are insulated from each other's changes until checking in their
931 Similarly, a maintainer can recreate an older configuration
932 by starting to work in an empty working directory.
933 During the initial MAKE invocation, all revisions are selected from RCS files.
934 As the maintainer checks out files and modifies them,
935 a new configuration is gradually built up.
936 Every time MAKE is invoked, it substitutes the modified revisions
937 into the configuration being manipulated.
939 A final application of RCS is to use it for storing Makefiles.
940 Revision groups of Makefiles represent
941 multiple versions of configurations.
942 Whenever a configuration is baselined or distributed,
943 the best approach is to unambiguously fix
944 the configuration with a symbolic revision number by calling
946 to embed that symbol into the Makefile, and to
947 check in the Makefile (using the same symbolic revision number).
948 With this approach, old configurations
949 can be regenerated easily and reliably.
953 The following usage statistics were collected on two DEC VAX-11/780
954 computers of the Purdue Computer Science Department. Both machines
955 are mainly used for research purposes. Thus, the data
956 reflect an environment in which the majority of projects
957 involve prototyping and advanced software development,
958 but relatively little long-term maintenance.
960 For the first experiment,
961 the \fIci\fR and \fIco\fR operations were instrumented
962 to log the number of backward and forward deltas applied.
963 The data were collected during a 13 month period
964 from Dec. 1982 to Dec. 1983.
965 Table I summarizes the results.
974 Operation#Total#Total deltas#Mean deltas#Operations#Branch
975 #operations #applied#applied#with >1 delta#operations
977 co # 7867# 9320#1.18#509#(6%)#203#(3%)
978 ci # 3468# 2207#0.64# 85#(2%)# 75#(2%)
979 ci & co#11335#11527#1.02#594#(5%)#278#(2%)
982 Table I. Statistics for \fIco\fR and \fIci\fR operations.
986 The first two lines show statistics for check-out and check-in;
987 the third line shows the combination.
988 Recall that \fIci\fR performs an implicit check-out to obtain
989 a revision for computing the delta.
990 In all measures presented, the most recent revision (stored intact)
991 counts as one delta. The number of deltas applied represents
992 the number of passes necessary, where the first `pass' is a copying step.
994 Note that the check-out operation is executed more than
995 twice as frequently as the check-in operation.
996 The fourth column gives the mean number of deltas
997 applied in all three cases.
998 For \fIci\fR, the mean number of deltas applied is less
1000 The reasons are that the initial check-in requires no delta at all, and that
1001 the only time \fIci\fR requires more than one delta is for branches.
1002 Column 5 shows the actual number of operations that applied more than one
1004 The last column indicates that branches were not used often.
1006 The last three columns demonstrate that the most recent trunk revision
1007 is by far the most frequently accessed.
1008 For RCS, check-out of
1009 this revision is a simple copy operation, which is the absolute minimum
1010 given the copy-semantics of \fIco\fR.
1011 Access to older revisions and branches
1012 is more common in non-academic environments,
1013 yet even if access to older deltas were an order
1014 of magnitude more frequent,
1015 the combined average number of deltas applied would still be below 1.2.
1016 Since RCS is faster than SCCS until up to 10 delta applications,
1017 reverse deltas are clearly the method of choice.
1019 The second experiment, conducted in March of 1984,
1020 involved surveying the existing RCS files
1021 on our two machines. The goal was to determine the mean number of
1022 revisions per RCS file, as well as the space consumed by them.
1023 Table II shows the results. (Tables I and II were produced at different
1024 times and are unrelated.)
1030 c | c | c | c | c | c | c
1031 c | c | c | c | c | c | c
1032 l | n | n | n | n | n | n.
1033 #Total RCS#Total#Mean#Mean size of#Mean size of#Overhead
1034 #files#revisions#revisions#RCS files#revisions
1036 All files #8033#11133#1.39#6156#5585#1.10
1037 Files with#1477# 4578#3.10#8074#6041#1.34
1041 Table II. Statistics for RCS files.
1045 The mean number of revisions per RCS file is 1.39.
1046 Columns 5 and 6 show the mean sizes (in bytes) of an RCS file
1047 and of the latest revision of each RCS file, respectively.
1048 The `overhead' column contains the ratio of the mean sizes.
1049 Assuming that all revisions in an RCS file are approximately the same size,
1050 this ratio gives a measure of the space consumed by the extra revisions.
1052 In our sample, over 80 per cent of the RCS files contained only a single revision.
1053 The reason is that our
1054 systems programmers routinely check in all source files
1055 on the distribution tapes, even though they may never touch them again.
1056 To get a better indication of how much space savings are possible
1057 with deltas, all measures with those files
1058 that contained 2 or more revisions were recomputed. Only for those files
1060 As shown in the second line, the average number of revisions for those files is
1061 3.10, with an overhead of 1.34. This means that the extra 2.10 deltas
1062 require 34 per cent extra space, or
1063 16 per cent per extra revision.
1065 measured the space consumed by SCCS, and
1066 reported an average of 5 revisions per group
1067 and an overhead of 1.37 (or about 9 per cent per extra revision).
1068 In a later paper, Glasser\u6\d
1069 observed an average of 7 revisions per group in a single, large project,
1070 but provided no overhead figure.
1071 In his paper on DSEE\u5\d,
1072 Leblang reported that delta storage combined with blank compression
1073 results in an overhead of a mere 1\-2 per cent per revision.
1074 Since leading blanks accounted for about 20 per cent of the surveyed Pascal
1075 programs, a revision group with 5\-10 members was smaller
1076 than a single cleartext copy.
1078 The above observations demonstrate clearly that the space needed
1079 for extra revisions is small. With delta storage, the luxury of
1080 keeping multiple revisions online is certainly affordable.
1081 In fact, introducing a system with delta storage may reduce
1082 storage requirements, because programmers often save back-up copies
1083 anyway. Since back-up copies are stored much more efficiently with deltas,
1084 introducing a system such as RCS may
1085 actually free a considerable amount of space.
1087 Survey of Version Control Tools
1089 The need to keep back-up copies of software arose when
1090 programs and data were no longer stored on paper media, but were entered
1091 from terminals and stored on disk.
1092 Back-up copies are desirable for reliability, and many modern editors
1093 automatically save a back-up copy for every file touched.
1095 is valuable for short-term back-ups, but not suitable for long-term
1096 version control, since an existing back-up copy is overwritten whenever the
1097 corresponding file is edited.
1099 Tape archives are suitable for long-term, offline storage.
1100 If all changed files are dumped on a back-up tape once per day, old revisions
1101 remain accessible. However, tape archives are unsatisfactory
1102 for version control in several ways. First, backing up the file
1103 system every 24 hours does not capture intermediate revisions.
1104 Secondly, the old revisions are not online,
1105 and accessing them is tedious and time-consuming.
1106 In particular, it is impractical to
1107 compare several old revisions of a group,
1108 because that may require mounting and searching several tapes.
1109 Tape archives are important fail-safe tools in the
1110 event of catastrophic disk failures or accidental deletions,
1111 but they are ill-suited for version control.
1112 Conversely, version control tools do not obviate the
1113 need for tape archives.
1115 A natural technique for keeping several old revisions online is
1116 to never delete a file.
1118 simply creates a new file with the same
1119 name, but with a different sequence number.
1120 This technique, available as an option in DEC's VMS operating system,
1121 turns out to be inadequate for version control.
1122 First, it is prohibitively expensive in terms of storage costs,
1123 especially since no data compression techniques are employed.
1124 Secondly, indiscriminately storing every change produces too many
1125 revisions, and programmers have difficulties distinguishing them.
1126 The proliferation of revisions forces programmers to spend much time on
1127 finding and deleting useless files.
1128 Thirdly, most of the support functions like locking, logging,
1130 and identification described in this paper are not available.
1132 An alternative approach is to separate editing from revision control.
1133 The user may repeatedly edit a given revision,
1134 until freezing it with an explicit command.
1135 Once a revision is frozen, it is stored permanently and can no longer be modified.
1136 (In RCS, freezing a revisions is done with \fIci\fR.)
1137 Editing a frozen revision implicitly creates a new one, which
1138 can again be changed repeatedly until it is frozen itself.
1139 This approach saves exactly those revisions that the user
1140 considers important, and keeps the number of revisions manageable.
1141 IBM's CLEAR/CASTER\u7\d,
1145 are examples of version control systems using this approach.
1146 CLEAR/CASTER maintains a data base of programs, specifications,
1147 documentation and messages, using deltas.
1148 Its goal is to provide control over the development process from a
1149 management viewpoint.
1150 SCCS stores multiple revisions of source text in an ancestral tree,
1151 records a log entry for each revision,
1152 provides access control, and has facilities
1153 for uniquely identifying each revision.
1154 An efficient delta technique
1155 reduces the space consumed by each revision group.
1156 SDC is much simpler than SCCS because it stores not more than
1157 two revisions. However, it maintains a complete log for all old
1158 revisions, some of which may be on back-up tape.
1159 CMS, like SCCS, manages tree-structured revision groups,
1160 but offers no identification mechanism.
1162 Tools for dealing with configurations are still in a state of flux.
1163 SCCS, SDC and CMS can be combined with MAKE or MAKE-like programs.
1164 Since flexible selection rules are missing from all these tools,
1165 it is sometimes difficult
1166 to specify precisely which revision of each group
1167 should be passed to MAKE for building a desired configuration.
1168 The Xerox Cedar system\u10\d
1169 provides a `System Modeller' that can rebuild
1170 a configuration from an arbitrary set of module revisions.
1171 The revisions of a module are only distinguished by creation time,
1172 and there is no tool for managing groups.
1173 Since the selection rules are primitive,
1174 the System Modeller appears to be somewhat tedious to use.
1176 is a sophisticated software engineering environment.
1177 It manages revision groups in a way similar to SCCS and CMS. Configurations
1178 are built using `configuration threads'.
1179 A configuration thread states which revision of each group
1180 named in a configuration should be chosen.
1181 A configuration thread may contain dynamic specifiers
1182 (e.g., `choose the revisions I am currently working on,
1183 and the most recent revisions otherwise'), which are bound
1184 automatically at build time.
1185 It also provides a notification mechanism for alerting
1186 maintainers about the need to rebuild a system after a change.
1188 RCS is based on a general model for describing
1189 multi-version/multi-configuration systems\u11\d.
1190 The model describes systems using AND/OR graphs, where AND nodes represent
1191 configurations, and OR nodes represent version groups.
1192 The model gives rise to a suit of selection rules for
1193 composing configurations, almost all of which are implemented in RCS.
1194 The revisions selected by RCS are passed to MAKE for configuration building.
1195 Revision group management is modelled after SCCS.
1196 RCS retains SCCS's best features,
1197 but offers a significantly simpler user interface,
1198 flexible selection rules, adequate integration with MAKE
1199 and improved identification.
1200 A detailed comparison of RCS and SCCS appears in Reference 4.
1202 An important component of all revision control systems
1203 is a program for computing deltas.
1204 SCCS and RCS use the program \fIdiff\fR\u2\d,
1205 which first computes the longest common substring of two
1206 revisions, and then produces the delta from that substring.
1207 The delta is simply an edit script consisting of deletion and
1208 insertion commands that generate one revision from the other.
1210 A delta based on a longest common substring is not necessarily minimal,
1211 because it does not take advantage of crossing block moves.
1212 Crossing block moves arise if two or more blocks of lines
1214 appear in a different order in two revisions.
1215 An edit script derived from a longest common substring
1216 first deletes the shorter of the two blocks, and then reinserts it.
1218 proposed an algorithm for detecting block moves, but
1219 since the algorithm is based on heuristics,
1220 there are conditions
1221 under which the generated delta is far from minimal.
1222 DSEE uses this algorithm combined with blank compression,
1223 apparently with satisfactory overall results.
1224 A new algorithm that is guaranteed to produce a minimal delta based on
1225 block moves appears in Reference 13.
1226 A future release of RCS will use this algorithm.
1228 \fIAcknowledgements\fR:
1229 Many people have helped make RCS a success by contributed criticisms, suggestions,
1230 corrections, and even whole new commands (including manual pages).
1231 The list of people is too long to be
1232 reproduced here, but my sincere thanks for their help and
1233 goodwill goes to all of them.
1238 Appendix: Synopsis of RCS Operations
1240 .IP "\fIci\fP \fB\- check in revisions\fP"
1242 \fICi\fR stores the contents of a working file into the
1243 corresponding RCS file as a new revision.
1244 If the RCS file doesn't exist, \fIci\fR creates it.
1245 \fICi\fR removes the working file, unless one of the options
1246 \fI\-u\fR or \fI\-l\fR is present.
1247 For each check-in, \fIci\fR asks for a commentary
1248 describing the changes relative to the previous revision.
1250 \fICi\fR assigns the revision number given by the \fI\-r\fR option;
1251 if that option is missing, it derives the number from the
1252 lock held by the user; if there is no lock and locking is not strict,
1253 \fIci\fR increments the number of the latest revision on the trunk.
1254 A side branch can only be started by explicitly specifying its
1255 number with the \fI\-r\fR option during check-in.
1257 \fICi\fR also determines
1258 whether the revision to be checked in is different from the
1259 previous one, and asks whether to proceed if not.
1260 This facility simplifies check-in operations for large systems,
1261 because one need not remember which files were changed.
1263 The option \fI\-k\fR searches the checked in file for identification
1266 revision number, check-in date, author and state, and assigns these
1267 to the new revision rather than computing them. This option is
1268 useful for software distribution: Recipients of distributed software
1269 using RCS should check in updates with the \fI\-k\fR option.
1270 This convention guarantees that revision numbers, check-in dates,
1271 etc., are the same at all sites.
1272 .IP "\fIco\fP \fB\- check out revisions\fP"
1274 \fICo\fR retrieves revisions according to revision number,
1275 date, author and state attributes. It either places the revision
1276 into the working file, or prints it on the standard output.
1277 \fICo\fR always expands the identification markers.
1278 .IP "\fIident\fP \fB\- extract identification markers\fP"
1280 \fIIdent\fR extracts the identification markers expanded by \fIco\fR
1281 from any file and prints them.
1282 .IP "\fIrcs\fP \fB\- change RCS file attributes\fP"
1284 \fIRcs\fR is an administrative operation that changes access lists,
1285 locks, unlocks, breaks locks, toggles the strict-locking feature,
1286 sets state attributes and symbolic revision numbers, changes the
1287 description, and deletes revisions. A revision can
1288 only be deleted if it is not the fork of a side branch.
1291 .IP "\fIrcsclean\fP \fB\- clean working directory\fP"
1293 \fIRcsclean\fR removes working files that were checked out but never changed.*
1295 The \fIrcsclean\fP and \fIrcsfreeze\fP commands
1296 are optional and are not always installed.
1298 .IP "\fIrcsdiff\fP \fB\- compare revisions\fP"
1300 \fIRcsdiff\fR compares two revisions and prints their
1301 difference, using the UNIX tool \fIdiff\fR.
1302 One of the revisions compared may be checked out.
1303 This command is useful for finding out about changes.
1304 .IP "\fIrcsfreeze\fP \fB\- freeze a configuration\fP"
1306 \fIRcsfreeze\fR assigns the same symbolic revision number
1307 to a given revision in all RCS files.
1308 This command is useful for accurately recording a configuration.*
1309 .IP "\fIrcsmerge\fP \fB\- merge revisions\fP"
1311 \fIRcsmerge\fR merges two revisions, \fIrev1\fR and \fIrev2\fR,
1312 with respect to a common ancestor.
1313 A 3-way file comparison determines the segments of lines that
1314 are (a) the same in all three revisions, or (b) the same in 2 revisions,
1315 or (c) different in all three. For all segments of type (b) where
1316 \fIrev1\fR is the differing revision,
1317 the segment in \fIrev1\fR replaces the corresponding segment of \fIrev2\fR.
1318 Type (c) indicates an overlapping change, is flagged as an error, and requires user
1319 intervention to select the correct alternative.
1320 .IP "\fIrlog\fP \fB\- read log messages\fP"
1322 \fIRlog\fR prints the log messages and other information in an RCS file.
1332 .ds [A Feldman, Stuart I.
1334 .ds [T Make\*-A Program for Maintaining Computer Programs
1335 .ds [J Software\*-Practice & Experience
1343 .][ 1 journal-article
1347 .ds [T An Algorithm for Differential File Comparison
1348 .ds [A Hunt, James W.
1349 .as [A " and McIlroy, M. D.
1350 .ds [I Computing Science Technical Report, Bell Laboratories
1360 .ds [A Rochkind, Marc J.
1362 .ds [T The Source Code Control System
1363 .ds [J IEEE Transactions on Software Engineering
1371 .][ 1 journal-article
1375 .ds [T Design, Implementation, and Evaluation of a Revision Control System
1376 .ds [A Tichy, Walter F.
1377 .ds [B Proceedings of the 6th International Conference on Software Engineering
1378 .ds [I ACM, IEEE, IPS, NBS
1379 .ds [D September 1982
1385 .][ 3 article-in-book
1389 .ds [A Leblang, David B.
1390 .as [A " and Chase, Robert P.
1391 .ds [T Computer-Aided Software Engineering in a Distributed Workstation Environment
1392 .ds [O Proceedings of the ACM SIGSOFT/SIGPLAN Software Engineering Symposium
1393 .as [O " on Practical Software Development Environments.
1394 .ds [J SIGPLAN Notices
1403 .][ 1 journal-article
1409 .ds [A Glasser, Alan L.
1411 .ds [T The Evolution of a Source Code Control System
1412 .ds [J Software Engineering Notes
1417 .ds [O Proceedings of the Software Quality and Assurance Workshop.
1421 .][ 1 journal-article
1425 .ds [K IBMClearCaster
1428 .ds [T The Clear/Caster System
1429 .ds [J Nato Conference on Software Engineering, Rome
1433 .][ 1 journal-article
1438 .ds [A Habermann, A. Nico
1440 .ds [T A Software Development Control System
1441 .ds [I Technical Report, Carnegie-Mellon University, Department of Computer Science
1450 .ds [T Code Management System
1451 .ds [I Digital Equipment Corporation
1452 .ds [O Document No.\ EA-23134-82
1461 .ds [A Lampson, Butler W.
1462 .as [A " and Schmidt, Eric E.
1463 .ds [T Practical Use of a Polymorphic Applicative Language
1464 .ds [B Proceedings of the 10th Symposium on Principles of Programming Languages
1472 .][ 3 article-in-book
1477 .ds [T A Data Model for Programming Support Environments and its Application
1478 .ds [A Tichy, Walter F.
1479 .ds [B Automated Tools for Information System Design and Development
1480 .ds [E Hans-Jochen Schneider and Anthony I. Wasserman
1482 .ds [I North-Holland Publishing Company
1487 .][ 3 article-in-book
1493 .ds [T A Technique for Isolating Differences Between Files
1495 .ds [J Communications of the ACM
1504 .][ 1 journal-article
1508 .ds [T The String-to-String Correction Problem with Block Moves
1509 .ds [A Tichy, Walter F.
1511 .ds [J ACM Transactions on Computer Systems
1519 .][ 1 journal-article