home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / rcstxi11.zip / rcstexi.110 / rcs_doc.tex < prev    next >
Text File  |  1997-03-30  |  59KB  |  1,380 lines

  1. @c
  2. @c ================================================================================
  3. @c                               Edition 1.1
  4. @c                      of the Texinfo-manuals for the
  5. @c                      (R)evision (C)ontrol (S)ystem
  6. @c                               Version 5.7
  7. @c
  8. @c                  (c) 1982, 1988, 1989 Walter F. Tichy.
  9. @c           (c) 1990, 1991, 1992, 1993, 1994, 1995 Paul Eggert.
  10. @c        (c) 1996, 1997 Karl Heinz Marbaise (doing converting job)
  11. @c ================================================================================
  12. @c
  13. @c Discription:
  14. @c    A story about RCS and version control
  15. @c
  16. @c Authors:
  17. @c    Walter Tichy,
  18. @c    Paul Eggert,
  19. @c    Karl Heinz Marbaise (doing converting job)
  20. @c
  21. @c e-mail:
  22. @c    Internet: KHMarbaise@p69.ks.fido.de
  23. @c    Fido-net: 2:2452/117.69
  24. @c
  25. @c Bugs, question:
  26. @c    to above e-mail adress.
  27. @c
  28. @c License:
  29. @c    The "Texinfo Edition of the RCS V5.7 manuals" are free
  30. @c    software; you can redistribute it and/or modify it under
  31. @c    the terms of the GNU General Public License as published
  32. @c    by the Free Software Foundation; either version 2, or (at
  33. @c    your option) any later version.
  34. @c
  35. @c    The "Texinfo Edition of the RCS V5.7 manuals" are distributed
  36. @c    in the hope that they will be useful, but WITHOUT ANY WARRANTY;
  37. @c    without even the implied warranty of MERCHANTABILITY or
  38. @c    FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public
  39. @c    License for more details.
  40. @c
  41. @c    You should have received a copy of the GNU General Public License
  42. @c    along with the "Texinfo Edition of the RCS V5.7 manuals"; see the
  43. @c    file COPYING. If not, write to the:
  44. @c    Free Software Foundation,
  45. @c    59 Temple Place - Suite 330,
  46. @c    Boston, MA 02111-1307, USA.
  47. @c
  48. @c    See \rcstxi.110\COPYING for details.
  49. @c
  50. @c ================================================================================
  51. @c
  52. @c
  53. @c $Id: RCS_DOC.TEX 1.2 1997/03/30 22:53:19 KHM Exp $
  54. @c
  55. @c =============================================================================
  56. @c RCS -- A System for Version Control
  57. @c -----------------------------------------------------------------------------
  58. @node VersionControl,rcsIntroduction,About,Top
  59. @chapter RCS--A System for Version Control
  60.  
  61. @center Walter F. Tichy
  62. @center Department of Computer Sciences
  63. @center Purdue University
  64. @center West Lafayette, Indiana 47907
  65.  
  66. An important problem in program development and maintenance is
  67. version control, i.e., the task of keeping a software system
  68. consisting of many versions and configurations well organized.
  69. The Revision Control System (RCS) is a software tool that assists
  70. with that task. RCS manages revisions of text documents, in
  71. particular source programs, documentation, and test data. It
  72. automates the storing, retrieval, logging and identification of
  73. revisions, and it provides selection mechanisms for composing
  74. configurations. This paper introduces basic version control
  75. concepts and discusses the practice of version control using RCS.
  76. For conserving space, RCS stores deltas, i.e., differences
  77. between successive revisions.  Several delta storage methods are
  78. discussed. Usage statistics show that RCS's delta storage method
  79. is space and time efficient. The paper concludes with a detailed
  80. survey of version control tools.
  81.  
  82. Keywords: configuration management, history management,
  83. version control, revisions, deltas.
  84.  
  85. An earlier version of this paper was published in
  86. @cite{Software--Practice & Experience, 7 (July 1985), 637-654.}
  87.  
  88. @ifinfo
  89. @menu
  90. * Introduction::        Introduction to RCS.
  91. * StartRCS::            Getting started with RCS.
  92. * Identification::      Automatic Identification.
  93. * RevisionTree::        The RCS Revision Tree.
  94. * Branches::            When are branches needed?.
  95. * Deltas::              Revisions are represented as deltas.
  96. * Controversial::       Locking: A Controversial Issue.
  97. * Configuration::       Configuration Management.
  98. * Functions::           RCS Selection Functions.
  99. * MAKERCS::             Combining MAKE and RCS.
  100. * Statistics::          Usage Statistics.
  101. * Survey::              Survey of Version Control Tools.
  102. @end menu
  103. @end ifinfo
  104.  
  105. @c -----------------------------------------------------------------------------
  106. @c RCS -- A System for Version Control
  107. @c     Introduction
  108. @c -----------------------------------------------------------------------------
  109. @node Introduction,StartRCS,,VersionControl
  110. @section Introduction
  111. Version control is the task of keeping software systems
  112. consisting of many versions and configurations well organized.
  113. The Revision Control System (RCS) is a set of UNIX commands that
  114. assist with that task.
  115.  
  116. RCS' primary function is to manage @b{revision groups}. A
  117. revision group is a set of text documents, called @b{revisions},
  118. that evolved from each other. A new revision is created by
  119. manually editing an existing one. RCS organizes the revisions
  120. into an ancestral tree.  The initial revision is the root of the
  121. tree, and the tree edges indicate from which revision a given one
  122. evolved. Besides managing individual revision groups, RCS
  123. provides flexible selection functions for composing
  124. configurations. RCS may be combined with MAKE (@xref{Feldman}),
  125. resulting in a powerful package for version control.
  126.  
  127. RCS also offers facilities for merging updates with customer
  128. modifications, for distributed software development, and for
  129. automatic identification. Identification is the @file{stamping}
  130. of revisions and configurations with unique markers. These
  131. markers are akin to serial numbers, telling software maintainers
  132. unambiguously which configuration is before them.
  133.  
  134. RCS is designed for both production and experimental
  135. environments. In production environments, access controls detect
  136. update conflicts and prevent overlapping changes. In experimental
  137. environments, where strong controls are counterproductive, it is
  138. possible to loosen the controls.
  139.  
  140. Although RCS was originally intended for programs, it is useful
  141. for any text that is revised frequently and whose previous
  142. revisions must be preserved.  RCS has been applied successfully
  143. to store the source text for drawings, VLSI layouts,
  144. documentation, specifications, test data, form letters and
  145. articles.
  146.  
  147. This paper discusses the practice of version control using RCS.
  148. It also introduces basic version control concepts, useful for
  149. clarifying current practice and designing similar systems.
  150. Revision groups of individual components are treated in the next
  151. three sections, and the extensions to configurations follow.
  152. Because of its size, a survey of version control tools appears at
  153. the end of the paper.
  154.  
  155. @c -----------------------------------------------------------------------------
  156. @c RCS -- A System for Version Control
  157. @c     Getting started with RCS
  158. @c -----------------------------------------------------------------------------
  159. @node StartRCS,Identification,Introduction,VersionControl
  160. @section Getting started with RCS
  161. Suppose a text file @file{f.c} is to be placed under control of
  162. RCS. Invoking the check-in command
  163.  
  164.  
  165. @example
  166. ci  f.c
  167. @end example
  168.  
  169.  
  170. creates a new revision group with the contents of @file{f.c} as
  171. the initial revision (numbered 1.1) and stores the group into the
  172. file @file{f.c,v}. Unless told otherwise, the command deletes
  173. @file{f.c}. It also asks for a description of the group. The
  174. description should state the common purpose of all revisions in
  175. the group, and becomes part of the group's documentation. All
  176. later check-in commands will ask for a log entry, which should
  177. summarize the changes made. (The first revision is assigned a
  178. default log message, which just records the fact that it is the
  179. initial revision.)
  180.  
  181. Files ending in @file{,v} are called @b{RCS files}
  182. (@b{v} stands for @b{Rersions}); the others are called working
  183. files. To get back the working file @file{f.c} in the previous
  184. example, execute the check-out command:
  185.  
  186.  
  187. @example
  188. co  f.c
  189. @end example
  190.  
  191.  
  192. This command extracts the latest revision from the revision group
  193. @file{f.c,v} and writes it into @file{f.c}. The file @file{f.c}
  194. can now be edited and, when finished, checked back in with
  195. @code{ci}:
  196.  
  197.  
  198. @example
  199. ci  f.c
  200. @end example
  201.  
  202.  
  203. @code{Ci} assigns number 1.2 to the new revision.
  204. If @code{ci} complains with the message
  205.  
  206.  
  207. @example
  208. ci error: no lock set by <login>
  209. @end example
  210.  
  211.  
  212. then the system administrator has decided to configure RCS for a
  213. production environment by enabling the @file{strict locking
  214. feature}. If this feature is enabled, all RCS files are
  215. initialized such that check-in operations require a lock on the
  216. previous revision (the one from which the current one evolved).
  217. Locking prevents overlapping modifications if several people work
  218. on the same file. If locking is required, the revision should
  219. have been locked during the check-out by using the option
  220. @code{-l}:
  221.  
  222.  
  223. @example
  224. co -l  f.c
  225. @end example
  226.  
  227.  
  228. Of course it is too late now for the check-out with locking,
  229. because @file{f.c} has already been changed; checking out the
  230. file again would overwrite the modifications. (To prevent
  231. accidental overwrites, @code{co} senses the presence of a working
  232. file and asks whether the user really intended to overwrite it.
  233. The overwriting check-out is sometimes useful for backing up to
  234. the previous revision.) To be able to proceed with the check-in
  235. in the present case, first execute
  236.  
  237.  
  238. @example
  239. rcs  -l  f.c
  240. @end example
  241.  
  242.  
  243. command retroactively locks the latest revision, unless someone
  244. else locked it in the meantime.  In this case, the two
  245. programmers involved have to negotiate whose modifications should
  246. take precedence.
  247.  
  248.  
  249. If an RCS file is private, i.e., if only the
  250. owner of the file is expected to deposit revisions into it, the
  251. strict locking feature is unnecessary and may be disabled. If
  252. strict locking is disabled, the owner of the RCS file need not
  253. have a lock for check-in. For safety reasons, all others still
  254. do.  Turning strict locking off and on is done with the commands:
  255.  
  256.  
  257. @example
  258. rcs  -U  f.c   and rcs  -L  f.c
  259. @end example
  260.  
  261.  
  262. These commands enable or disable the strict locking feature for each
  263. RCS file individually. The system administrator only decides
  264. whether strict locking is enabled initially.
  265.  
  266.  
  267. To reduce the clutter in a working directory, all RCS files can
  268. be moved to a subdirectory with the name @code{RCS}. RCS commands
  269. look first into that directory for RCS files. All the commands
  270. presented above work with the @code{RCS}
  271. subdirectory@footnote{Pairs of RCS and working files can actually
  272. be specified in 3 ways: a) both are given, b) only the working
  273. file is given, c) only the RCS file is given. If a pair is given,
  274. both files may have arbitrary path prefixes; RCS commands pair
  275. them up intelligently}. without change.
  276.  
  277.  
  278. It may be undesirable that @code{ci} deletes the working file.
  279. For instance, sometimes one would like
  280. to save the current revision, but continue editing. Invoking
  281.  
  282.  
  283. @example
  284. ci  -l  f.c
  285. @end example
  286.  
  287.  
  288. checks in @file{f.c} as usual, but performs an additional
  289. check-out with locking afterwards.  Thus, the working file does
  290. not disappear after the check-in. Similarly, the option @code{-u}
  291. does a check-in followed by a check-out without locking.  This
  292. option is useful if the file is needed for compilation after the
  293. check-in. Both options update the identification markers in the
  294. working file (see below).
  295.  
  296.  
  297. Besides the operations @code{ci} and @code{co}, RCS provides the
  298. following commands:
  299.  
  300.  
  301. @table @code
  302. @item ident
  303. extract identification markers
  304.  
  305. @item rcs
  306. change RCS file attributes
  307.  
  308. @item rcsclean
  309. remove unchanged working files (optional)
  310.  
  311. @item rcsdiff
  312. compare revisions
  313.  
  314. @item rcsfreeze
  315. record a configuration (optional)
  316.  
  317. @item rcsmerge
  318. merge revisions
  319.  
  320. @item rlog
  321. read log messages and other information in RCS files
  322.  
  323. @end table
  324.  
  325.  
  326. A synopsis of these commands appears in the Appendix.
  327.  
  328.  
  329. @c -----------------------------------------------------------------------------
  330. @c RCS -- A System for Version Control
  331. @c     Getting started with RCS
  332. @c         Automatic Indentification
  333. @c -----------------------------------------------------------------------------
  334. @node Identification,RevisionTree,StartRCS,VersionControl
  335. @subsection Automatic Identification
  336.  
  337. RCS can stamp source and object code with special identification
  338. strings, similar to product and serial numbers. To obtain such
  339. identification, place the marker
  340.  
  341.  
  342. @example
  343. @value{RCSID}
  344. @end example
  345.  
  346.  
  347. into the text of a revision, for instance inside a comment.
  348. The check-out operation will replace this marker with a string of the form
  349.  
  350.  
  351. @example
  352. @value{RCSD}Id:  filename  revisionnumber  date  time  author state  locker @value{RCSD}
  353. @end example
  354.  
  355.  
  356. This string need never be touched, because @code{co} keeps it
  357. up to date automatically. To propagate the marker into object code,
  358. simply put it into a literal character string.
  359. In C, this is done as follows:
  360.  
  361.  
  362. @example
  363. static char rcsid[] = "@value{RCSID}";
  364. @end example
  365.  
  366.  
  367. The command @code{ident} extracts such markers from any file,
  368. in particular from object code.
  369. @code{Ident} helps to find out which revisions of which modules
  370. were used in a given program. It returns a complete and unambiguous
  371. component list, from which a copy of the program can be reconstructed.
  372. This facility is invaluable for program maintenance.
  373.  
  374. There are several additional identification markers, one for each component
  375. of @value{RCSID}. The marker
  376.  
  377.  
  378. @example
  379. @value{RCSLOG}
  380. @end example
  381.  
  382.  
  383. has a similar function.  It accumulates
  384. the log messages that are requested during check-in.
  385. Thus, one can maintain the complete history of a revision directly inside it,
  386. by enclosing it in a comment.
  387. Figure 1 is an edited version of a log contained in revision 4.1 of
  388. the file @file{ci.c}.  The log appears at the beginning of the file,
  389. and makes it easy to determine what the recent modifications were.
  390.  
  391.  
  392. @example
  393. /*
  394.  * @value{RCSD}Log: ci.c,v @value{RCSD}
  395.  * Revision 4.1  1983/05/10 17:03:06  wft
  396.  * Added option -d and -w, and updated assignment of date, etc.
  397.  * to new delta. Added handling of default branches.
  398.  *
  399.  * Revision 3.9  1983/02/15 15:25:44  wft
  400.  * Added call to fastcopy() to copy remainder of RCS file.
  401.  *
  402.  * Revision 3.8  1983/01/14 15:34:05  wft
  403.  * Added ignoring of interrupts while new RCS file is renamed;
  404.  * avoids deletion of RCS files by interrupts.
  405.  *
  406.  * Revision 3.7  1982/12/10 16:09:20  wft
  407.  * Corrected checking of return code from diff.
  408.  * An RCS file now inherits its mode during the first ci from the
  409.  * working file, except that write permission is removed.
  410.  */
  411. @end example
  412. @center Figure 1.  Log entries produced by the marker @value{RCSLOG}
  413.  
  414.  
  415. Since revisions are stored in the form of differences, each log
  416. message is physically stored once, independent of the number of
  417. revisions present. Thus, the @value{RCSLOG} marker incurs
  418. negligible space overhead.
  419.  
  420. @c -----------------------------------------------------------------------------
  421. @c RCS -- A System for Version Control
  422. @c     The RCS Revision Tree
  423. @c -----------------------------------------------------------------------------
  424. @node RevisionTree,Branches,Identification,VersionControl
  425. @section The RCS Revision Tree
  426.  
  427. RCS arranges revisions in an ancestral tree. The @code{ci}
  428. command builds this tree; the auxiliary command @code{rcs} prunes
  429. it. The tree has a root revision, normally numbered 1.1, and
  430. successive revisions are numbered 1.2, 1.3, etc.  The first field
  431. of a revision number is called the @code{release number} and the
  432. second one the @code{level number}.  Unless given explicitly, the
  433. @code{ci} command assigns a new revision number by incrementing
  434. the level number of the previous revision. The release number
  435. must be incremented explicitly, using the @code{-r} option of
  436. @code{ci}. Assuming there are revisions 1.1, 1.2, and 1.3 in the
  437. RCS file @file{f.c,v}, the command
  438.  
  439.  
  440. @example
  441. ci  -r2.1  f.c       or       ci  -r2  f.c
  442. @end example
  443.  
  444.  
  445. assigns the number 2.1 to the new revision. Later check-ins
  446. without the @code{-r} option will assign the numbers 2.2, 2.3,
  447. and so on. The release number should be incremented only at major
  448. transition points in the development, for instance when a new
  449. release of a software product has been completed.
  450.  
  451.  
  452. @c -----------------------------------------------------------------------------
  453. @c RCS -- A System for Version Control
  454. @c     The RCS Revision Tree
  455. @c         When are branches needed?
  456. @c -----------------------------------------------------------------------------
  457. @node Branches,Deltas,RevisionTree,VersionControl
  458. @subsection When are branches needed?
  459. A young revision tree is slender: It consists of only one branch,
  460. called the trunk. As the tree ages, side branches may form.
  461. Branches are needed in the following 4 situations.
  462.  
  463. @enumerate
  464. @item Temporary fixes
  465.  
  466. Suppose a tree has 5 revisions grouped in 2 releases, as
  467. illustrated in Figure 2. Revision 1.3, the last one of release 1,
  468. is in operation at customer sites, while release 2 is in active
  469. development.
  470. @*
  471. @example
  472. @group
  473. @w{+-----+     +-----+     +-----+     +-----+     +-----+}
  474. @w{! 1.1 !---->! 1.2 !---->! 1.3 !---->! 2.1 !---->! 2.2 !--->>}
  475. @w{+-----+     +-----+     +-----+     +-----+     +-----+}
  476. @w{}
  477. @end group
  478. @end example
  479. @center Figure 2.  A slender revision tree.
  480. @*
  481. Now imagine a customer requesting a fix of a problem in revision
  482. 1.3, although actual development has moved on to release 2.  RCS
  483. does not permit an extra revision to be spliced in between 1.3
  484. and 2.1, since that would not reflect the actual development
  485. history.  Instead, create a branch at revision 1.3, and check in
  486. the fix on that branch. The first branch starting at 1.3 has
  487. number 1.3.1, and the revisions on that branch are numbered
  488. 1.3.1.1, 1.3.1.2, etc. The double numbering is needed to allow
  489. for another branch at 1.3, say 1.3.2. Revisions on the second
  490. branch would be numbered 1.3.2.1, 1.3.2.2, and so on. The
  491. following steps create branch 1.3.1 and add revision 1.3.1.1:
  492. @*
  493. @*
  494. @example
  495. @w{co -r1.3 f.c     -- check out revision 1.3}
  496. @w{edit f.c         -- change it}
  497. @w{ci  -r1.3.1  f.c -- check it in on branch 1.3.1}
  498. @end example
  499. @*
  500. @*
  501. This sequence of commands transforms the tree of Figure 2 into
  502. the one in Figure 3. Note that it may be necessary to incorporate
  503. the differences between 1.3 and 1.3.1.1 into a revision at level
  504. 2.  The operation @code{rcsmerge} automates this process (see the
  505. Appendix).
  506. @*
  507. @example
  508. @group
  509. @w{+-----+     +-----+     +-----+     +-----+     +-----+}
  510. @w{! 1.1 !---->! 1.2 !---->! 1.3 !---->! 2.1 !---->! 2.2 !--->>}
  511. @w{+-----+     +-----+     +--+--+     +-----+     +-----+}
  512. @w{                           !}
  513. @w{                           !        +---------+}
  514. @w{                           +------->! 1.3.1.1 !---->>}
  515. @w{                                    +---------+}
  516. @end group
  517. @end example
  518. @center Figure 3.  A revision tree with one side branch
  519. @*
  520. @item Distributed development and customer modifications
  521.  
  522. Assume a situation as in Figure 2, where revision 1.3 is in
  523. operation at several customer sites, while release 2 is in
  524. development. Customer sites should use RCS to store the
  525. distributed software. However, customer modifications should not
  526. be placed on the same branch as the distributed source; instead,
  527. they should be placed on a side branch. When the next software
  528. distribution arrives, it should be appended to the trunk of the
  529. customer's RCS file, and the customer can then merge the local
  530. modifications back into the new release. In the above example, a
  531. customer's RCS file would contain the following tree, assuming
  532. that the customer has received revision 1.3, added his local
  533. modifications as revision 1.3.1.1, then received revision 2.4,
  534. and merged 2.4 and 1.3.1.1, resulting in 2.4.1.1.
  535. @*
  536. @example
  537. @group
  538. @w{    +-----+                 +-----+}
  539. @w{--->! 1.3 !---------------->! 2.4 !---->>}
  540. @w{    +--+--+                 +---+-+}
  541. @w{       !                        !}
  542. @w{       !     +---------+        !       +---------+}
  543. @w{       +---->! 1.3.1.1 !        +------>! 2.4.1.1 !}
  544. @w{             +---------+                +---------+}
  545. @end group
  546. @end example
  547. @center Figure 4.  A customer's revision tree with local modifications.
  548. @*
  549. This approach is actually practiced in the CSNET project, where
  550. several universities and a company cooperate in developing a
  551. national computer network.
  552.  
  553.  
  554. @item Parallel development
  555.  
  556.  
  557. Sometimes it is desirable to explore an alternate design or
  558. a different implementation technique in parallel with the
  559. main line development.  Such development
  560. should be carried out on a side branch.
  561. The experimental changes may later be moved into the main line, or abandoned.
  562.  
  563. @item Conflicting updates
  564.  
  565.  
  566. A common occurrence is that one programmer has checked out a
  567. revision, but cannot complete the assignment for some reason.  In
  568. the meantime, another person must perform another modification
  569. immediately.  In that case, the second person should check-out
  570. the same revision, modify it, and check it in on a side branch,
  571. for later merging.
  572.  
  573.  
  574. Every node in a revision tree consists of the following
  575. attributes: a revision number, a check-in date and time, the
  576. author's identification, a log entry, a state and the actual
  577. text.  All these attributes are determined at the time the
  578. revision is checked in. The state attribute indicates the status
  579. of a revision. It is set automatically to `experimental' during
  580. check-in. A revision can later be promoted to a higher status,
  581. for example `stable' or `released'.  The set of states is
  582. user-defined.
  583.  
  584. @end enumerate
  585.  
  586.  
  587. @c -----------------------------------------------------------------------------
  588. @c RCS -- A System for Version Control
  589. @c     The RCS Revision Tree
  590. @c         Revisions are represented as deltas
  591. @c -----------------------------------------------------------------------------
  592. @node Deltas,Controversial,Branches,VersionControl
  593. @subsection Revisions are represented as deltas
  594. For conserving space, RCS stores revisions in the form of deltas,
  595. i.e., as differences between revisions. The user interface
  596. completely hides this fact.
  597.  
  598.  
  599. A delta is a sequence of edit commands that transforms one string
  600. into another.  The deltas employed by RCS are line-based, which
  601. means that the only edit commands allowed are insertion and
  602. deletion of lines. If a single character in a line is changed,
  603. the edit scripts consider the entire line changed. The program
  604. @code{diff} produces a small, line-based delta between pairs of
  605. text files. A character-based edit script would take much longer
  606. to compute, and would not be significantly shorter.
  607.  
  608.  
  609. Using deltas is a classical space-time tradeoff: deltas reduce
  610. the space consumed, but increase access time. However, a version
  611. control tool should impose as little delay as possible on
  612. programmers. Excessive delays discourage the use of version
  613. controls, or induce programmers to take shortcuts that compromise
  614. system integrity. To gain reasonably fast access time for both
  615. editing and compiling, RCS arranges deltas in the following way.
  616. The most recent revision on the trunk is stored intact. All other
  617. revisions on the trunk are stored as reverse deltas. A reverse
  618. delta describes how to go backward in the development history: it
  619. produces the desired revision if applied to the successor of that
  620. revision. This implementation has the advantage that extraction
  621. of the latest revision is a simple and fast copy operation.
  622. Adding a new revision to the trunk is also fast: @code{ci} simply
  623. adds the new revision intact, replaces the previous revision with
  624. a reverse delta, and keeps the rest of the old deltas. Thus,
  625. @code{ci} requires the computation of only one new delta.
  626.  
  627.  
  628. Branches need special treatment.  The naive solution would be to
  629. store complete copies for the tips of all branches. Clearly, this
  630. approach would cost too much space.  Instead, RCS uses
  631. @code{forward} deltas for branches.  Regenerating a revision on a
  632. side branch proceeds as follows.  First, extract the latest
  633. revision on the trunk; secondly, apply reverse deltas until the
  634. fork revision for the branch is obtained; thirdly, apply forward
  635. deltas until the desired branch revision is reached.  Figure 5
  636. illustrates a tree with one side branch.  Triangles pointing to
  637. the left and right(with five exclamation marks) represent
  638. reverse and forward deltas,
  639. respectively.
  640. @*
  641. @example
  642. @group
  643. @w{      !           !           !           !           !}
  644. @w{+-----!     +-----!     +-----!     +-----!     +-----!}
  645. @w{! 1.1 !---->! 1.2 !---->! 1.3 !---->! 2.1 !---->! 2.2 !--->>}
  646. @w{+-----+     +-----!     +--+--!     +-----!     +-----!}
  647. @w{      !           !        !  !           !           !}
  648. @w{                           !}
  649. @w{                           !            !               !}
  650. @w{                           !  +---------!     +---------!}
  651. @w{                           +->! 1.3.1.1 !---->! 1.3.1.2 !}
  652. @w{                              +---------!     +---------!}
  653. @w{                                        !               !}
  654. @end group
  655. @end example
  656. @center Figure 3.  A revision tree with one side branch
  657. @*
  658.  
  659. @c
  660. @c This part have to be "translated" into TeXinfo or plain ASCII
  661. @c
  662. @c .ne 8
  663. @c .PS 4i
  664. @c .ps -2
  665. @c define BD X [line invis $1 right .5;
  666. @c line up .3 then left .5 down .3 then right .5 down .3 then up .3] X
  667. @c
  668. @c define FD X [line invis $1 right .5;
  669. @c line left .5 down .3 then up .6 then right .5 down .3;] X
  670. @c
  671. @c right
  672. @c D11:    BD(" 1.1")
  673. @c         arrow right from D11.e
  674. @c D12:    BD(" 1.2")
  675. @c         arrow right from D12.e
  676. @c D13:    BD(" 1.3")
  677. @c         arrow right from D13.e
  678. @c D21:    BD(" 2.1")
  679. @c         arrow right from D21.e
  680. @c D22:    box "2.2"
  681. @c         line invis down from D21.s
  682. @c F1:     FD("1.3.1.1 ")
  683. @c         arrow from D13.se to F1.w
  684. @c         arrow from F1.e right
  685. @c         right
  686. @c F2:     FD("1.3.1.2 ")
  687. @c .ps +2
  688. @c .PE
  689. @c .ce 1
  690. @c Figure 5.  A revision tree with reverse and forward deltas.
  691. @c .sp 0
  692. @c
  693.  
  694. Although implementing fast check-out for the latest trunk
  695. revision, this arrangement has the disadvantage that generation
  696. of other revisions takes time proportional to the number of
  697. deltas applied.  For example, regenerating the branch tip in
  698. Figure 5 requires application of five deltas (including the
  699. initial one).  Since usage statistics show that the latest trunk
  700. revision is the one that is retrieved in 95 per cent of all cases
  701. (see the section on usage statistics), biasing check-out time in
  702. favor of that revision results in significant savings. However,
  703. careful implementation of the delta application process is
  704. necessary to provide low retrieval overhead for other revisions,
  705. in particular for branch tips.
  706.  
  707.  
  708. There are several techniques for delta application. The naive one
  709. is to pass each delta to a general-purpose text editor. A
  710. prototype of RCS invoked the UNIX editor @code{ed} both for
  711. applying deltas and for expanding the identification markers.
  712. Although easy to implement, performance was poor, owing to the
  713. high start-up costs and excess generality of @code{ed}.  An
  714. intermediate version of RCS used a special-purpose,
  715. stream-oriented editor. This technique reduced the cost of
  716. applying a delta to the cost of checking out the latest trunk
  717. revision.  The reason for this behavior is that each delta
  718. application involves a complete pass over the preceding revision.
  719.  
  720.  
  721. However, there is a much better algorithm.  Note that the deltas
  722. are line oriented and that most of the work of a stream editor
  723. involves copying unchanged lines from one revision to the next. A
  724. faster algorithm avoids unnecessary copying of character strings
  725. by using a @code{piece table}. A piece table is a one-dimensional
  726. array, specifying how a given revision is @file{pieced-together}
  727. from lines in the RCS file. Suppose piece table @code{PTr}
  728. represents revision @code{r}. Then @code{PTr[i]} contains the
  729. starting position of line @code{i} of revision @code{r}.
  730. Application of the next delta transforms piece table @code{PTr}
  731. into @code{PTr+1}.  For instance, a delete command removes a
  732. series of entries from the piece table.  An insertion command
  733. inserts new entries, moving the entries following the insertion
  734. point further down the array.  The inserted entries point to the
  735. text lines in the delta. Thus, no I/O is involved except for
  736. reading the delta itself. When all deltas have been applied to
  737. the piece table, a sequential pass through the table looks up
  738. each line in the RCS file and copies it to the output file,
  739. updating identification markers at the same time. Of course, the
  740. RCS file must permit random access, since the copied lines are
  741. scattered throughout that file.  Figure 6 illustrates an RCS file
  742. with two revisions and the corresponding piece tables.
  743.  
  744. @c
  745. @c This part have to be "translated" into TeXinfo or plain ASCII
  746. @c
  747. @c .ne 13
  748. @c .sp 6
  749. @c .ce 1
  750. @c \fIFigure 6 is not available.\fP
  751. @c .sp 5
  752. @c .ce 1
  753. @c Figure 6.  An RCS file and its piece tables
  754. @c .sp 0
  755. @c
  756.  
  757.  
  758. The piece table approach has the property that the time for
  759. applying a single delta is roughly determined by the size of the
  760. delta, and not by the size of the revision.  For example, if a
  761. delta is 10 per cent of the size of a revision, then applying it
  762. takes only 10 per cent of the time to generate the latest trunk
  763. revision.  (The stream editor would take 100 per cent.)
  764.  
  765.  
  766. There is an important alternative for representing deltas that
  767. affects performance.  @code{SCCS}, a precursor of RCS, uses
  768. @code{interleaved} deltas. A file containing interleaved deltas
  769. is partitioned into blocks of lines. Each block has a header that
  770. specifies to which revision(s) the block belongs.  The blocks are
  771. sorted out in such a way that a single pass over the file can
  772. pick up all the lines belonging to a given revision.  Thus, the
  773. regeneration time for all revisions is the same: all headers must
  774. be inspected, and the associated blocks either copied or skipped.
  775. As the number of revisions increases, the cost of retrieving any
  776. revision is much higher than the cost of checking out the latest
  777. trunk revision with reverse deltas.  A detailed comparison of
  778. @code{SCCS's} interleaved deltas and RCS's reverse deltas can be
  779. found in Reference 4. This reference considers the version of RCS
  780. with the stream editor only.  The piece table method improves
  781. performance further, so that RCS is always faster than SCCS,
  782. except if 10 or more deltas are applied.
  783.  
  784.  
  785. Additional speed-up for both delta methods can be obtained by
  786. caching the most recently generated revision, as has been
  787. implemented in @code{DSEE} With caching, access time to
  788. frequently used revisions can approach normal file access time,
  789. at the cost of some additional space.
  790.  
  791. @c -----------------------------------------------------------------------------
  792. @c RCS -- A System for Version Control
  793. @c     Locking: A Controlversial Issue
  794. @c -----------------------------------------------------------------------------
  795. @node Controversial,Configuration,Deltas,VersionControl
  796. @section Locking: A Controversial Issue
  797.  
  798. The locking mechanism for RCS was difficult to design. The
  799. problem and its solution are first presented in their @file{pure}
  800. form, followed by a discussion of the complications caused by
  801. @file{real-world} considerations.
  802.  
  803.  
  804. RCS must prevent two or more persons from depositing competing
  805. changes of the same revision. Suppose two programmers check out
  806. revision 2.4 and modify it.  Programmer A checks in a revision
  807. before programmer @b{B}. Unfortunately, programmer B has not seen
  808. A's changes, so the effect is that A's changes are covered up by
  809. B's deposit. A's changes are not lost since all revisions are
  810. saved, but they are confined to a single revision@footnote{Note
  811. that this problem is entirely different from the atomicity
  812. problem. Atomicity means that concurrent update operations on the
  813. same RCS file cannot be permitted, because that may result in
  814. inconsistent data. Atomic updates are essential (and implemented
  815. in RCS), but do not solve the conflict discussed here.}.
  816.  
  817.  
  818. This conflict is prevented in RCS by locking. Whenever someone
  819. intends to edit a revision (as opposed to reading or compiling
  820. it), the revision should be checked out and locked, using the
  821. @code{-l} option on @code{co}.  On subsequent check-in, @code{ci}
  822. tests the lock and then removes it. At most one programmer at a
  823. time may lock a particular revision, and only this programmer may
  824. check in the succeeding revision. Thus, while a revision is
  825. locked, it is the exclusive responsibility of the locker.
  826.  
  827.  
  828. An important maxim for software tools like RCS is that they must
  829. not stand in the way of making progress with a project. This
  830. consideration leads to several weakenings of the locking
  831. mechanism. First of all, even if a revision is locked, it can
  832. still be checked out.  This is necessary if other people wish to
  833. compile or inspect the locked revision while the next one is in
  834. preparation.  The only operations they cannot do are to lock the
  835. revision or to check in the succeeding one.  Secondly, check-in
  836. operations on other branches in the RCS file are still possible;
  837. the locking of one revision does not affect any other revision.
  838. Thirdly, revisions are occasionally locked for a long period of
  839. time because a programmer is absent or otherwise unable to
  840. complete the assignment.  If another programmer has to make a
  841. pressing change, there are the following three alternatives for
  842. making progress:
  843.  
  844. @itemize @minus
  845. @item find out who is holding the lock and ask that person to release it;
  846.  
  847. @item check out the locked revision, modify it, check it
  848. in on a branch, and merge the changes later;
  849.  
  850. @item break the lock.  Breaking a lock leaves a highly visible
  851. trace, namely an electronic mail message that is sent
  852. automatically to the holder of the lock, recording the breaker
  853. and a commentary requested from him. Thus, breaking locks is
  854. tolerated under certain circumstances, but will not go unnoticed.
  855. Experience has shown that the automatic mail message attaches a
  856. high enough stigma to lock breaking, such that programmers break
  857. locks only in real emergencies, or when a co-worker resigns and
  858. leaves locked revisions behind.
  859.  
  860. @end itemize
  861.  
  862.  
  863. If an RCS file is private, i.e., when a programmer owns an RCS
  864. file and does not expect anyone else to perform check-in
  865. operations, locking is an unnecessary nuisance. In this case, the
  866. @file{strict locking feature} discussed earlier may be disabled,
  867. provided that file protection is set such that only the owner may
  868. write the RCS file. This has the effect that only the owner can
  869. check-in revisions, and that no lock is needed for doing so.
  870.  
  871.  
  872. As added protection, each RCS file contains an access list that
  873. specifies the users who may execute update operations.  If an
  874. access list is empty, only normal UNIX file protection applies.
  875. Thus, the access list is useful for restricting the set of people
  876. who would otherwise have update permission.  Just as with
  877. locking, the access list has no effect on read-only operations
  878. such as @code{co}.  This approach is consistent with the UNIX
  879. philosophy of openness, which contributes to a productive
  880. software development environment.
  881.  
  882.  
  883. @c -----------------------------------------------------------------------------
  884. @c RCS -- A System for Version Control
  885. @c     Configuration Management
  886. @c -----------------------------------------------------------------------------
  887. @node Configuration,Functions,Controversial,VersionControl
  888. @section Configuration Management
  889.  
  890. The preceding sections described how @code{RCS} deals with
  891. revisions of individual components; this section discusses how to
  892. handle configurations. A configuration is a set of revisions,
  893. where each revision comes from a different revision group, and
  894. the revisions are selected according to a certain criterion. For
  895. example, in order to build a functioning compiler, the `right'
  896. revisions from the scanner, the parser, the optimizer and the
  897. code generator must be combined. @code{RCS}, in conjunction with
  898. @code{MAKE}, provides a number of facilities to effect a smooth
  899. selection.
  900.  
  901. @c -----------------------------------------------------------------------------
  902. @c RCS -- A System for Version Control
  903. @c     Configuration Management
  904. @c         RCS Selection Functions
  905. @c -----------------------------------------------------------------------------
  906. @node Functions,MAKERCS,Configuration,VersionControl
  907. @subsection RCS Selection Functions
  908.  
  909. @itemize @minus
  910. @item Default selection
  911.  
  912. During development, the usual selection criterion is to choose
  913. the latest revision of all components.  The @code{co} command
  914. makes this selection by default.  For example, the command
  915.  
  916.  
  917. @example
  918. co  *,v
  919. @end example
  920.  
  921.  
  922. retrieves the latest revision on the default branch of each RCS
  923. file in the current directory. The default branch is usually the
  924. trunk, but may be set to be a side branch. Side branches as
  925. defaults are needed in distributed software development, as
  926. discussed in the section on the RCS revision tree.
  927.  
  928. @item Release based selection
  929.  
  930. Specifying a release or branch number selects the latest revision
  931. in that release or branch. For instance,
  932.  
  933.  
  934. @example
  935. co  -r2  *,v
  936. @end example
  937.  
  938.  
  939. retrieves the latest revision with release number 2 from each RCS
  940. file. This selection is convenient if a release has been
  941. completed and development has moved on to the next release.
  942.  
  943. @item State and author based selection
  944.  
  945. If the highest level number within a given release number is not
  946. the desired one, the state attribute can help.  For example,
  947.  
  948.  
  949. @example
  950. co  -r2  -sReleased  *,v
  951. @end example
  952.  
  953.  
  954. retrieves the latest revision with release number 2 whose state
  955. attribute is `Released'. Of course, the state attribute has to be
  956. set appropriately, using the @code{ci} or @code{rcs} commands.
  957. Another alternative is to select a revision by its author, using
  958. the @code{-w} option.
  959.  
  960. @item Date based selection
  961.  
  962. Revisions may also be selected by date. Suppose a release of an
  963. entire system was completed and current on March 4, at 1:00 p.m.
  964. local time.  Then the command
  965.  
  966.  
  967. @example
  968. co  -d'March 4, 1:00 pm LT'  *,v
  969. @end example
  970.  
  971.  
  972. checks out all the components of that release, independent of the
  973. numbering. The @code{-d} option specifies a `cutoff date', i.e.,
  974. the revision selected has a check-in date that is closest to, but
  975. not after the date given.
  976.  
  977.  
  978. @item Name based selection
  979.  
  980. The most powerful selection function is based on assigning
  981. symbolic names to revisions and branches. In large systems, a
  982. single release number or date is not sufficient to collect the
  983. appropriate revisions from all groups. For example, suppose one
  984. wishes to combine release 2 of one subsystem and release 15 of
  985. another. Most likely, the creation dates of those releases differ
  986. also. Thus, a single revision number or date passed to the
  987. @code{co} command will not suffice to select the right revisions.
  988. Symbolic revision numbers solve this problem. Each RCS file may
  989. contain a set of symbolic names that are mapped to numeric
  990. revision numbers.  For example, assume the symbol @code{V3} is
  991. bound to release number 2 in file @file{s,v}, and to revision
  992. number 15.9 in @file{t,v}. Then the single command
  993.  
  994.  
  995. @example
  996. co  -rV3  s,v  t,v
  997. @end example
  998.  
  999.  
  1000. retrieves the latest revision of release 2 from @file{s,v}, and
  1001. revision 15.9 from @file{t,v}. In a large system with many
  1002. modules, checking out all revisions with one command greatly
  1003. simplifies configuration management.
  1004.  
  1005. Judicious use of symbolic revision numbers helps with organizing
  1006. large configurations.
  1007.  
  1008.  
  1009. A special command, @code{rcsfreeze}, assigns a symbolic revision
  1010. number to a selected revision in every RCS file. @code{rcsfreeze}
  1011. effectively freezes a configuration. The assigned symbolic
  1012. revision number selects all components of the configuration. If
  1013. necessary, symbolic numbers may even be intermixed with numeric
  1014. ones.  Thus, @code{V3.5} in the above example would select
  1015. revision 2.5 in @file{s,v} and branch 15.9.5 in @file{t,v}.
  1016.  
  1017.  
  1018. The options @code{-r}, @code{-s}, @code{-w} and @code{-d} may be
  1019. combined.  If a branch is given, the latest revision on that
  1020. branch satisfying all conditions is retrieved; otherwise, the
  1021. default branch is used.
  1022.  
  1023. @end itemize
  1024.  
  1025.  
  1026. @c -----------------------------------------------------------------------------
  1027. @c RCS -- A System for Version Control
  1028. @c     Configuration Management
  1029. @c         Combining MAKE and RCS
  1030. @c -----------------------------------------------------------------------------
  1031. @node MAKERCS,Statistics,Functions,VersionControl
  1032. @subsection Combining MAKE and RCS
  1033.  
  1034. MAKE (@ref{Feldman}) is a program that processes
  1035. configurations. It is driven by configuration specifications
  1036. recorded in a special file, called a `Makefile'. MAKE avoids
  1037. redundant processing steps by comparing creation dates of source
  1038. and processed objects. For example, when instructed to compile
  1039. all modules of a given system, it only recompiles those source
  1040. modules that were changed since they were processed last.
  1041.  
  1042.  
  1043. MAKE has been extended with an auto-checkout
  1044. feature@footnote{This auto-checkout extension is available only
  1045. in some versions of MAKE, e.g. GNU MAKE.} for RCS.* When a
  1046. certain file to be processed is not present, MAKE attempts a
  1047. check-out operation. If successful, MAKE performs the required
  1048. processing, and then deletes the checked out file to conserve
  1049. space. The selection parameters discussed above can be passed to
  1050. MAKE either as parameters, or directly embedded in the Makefile.
  1051. MAKE has also been extended to search the subdirectory named
  1052. @code{RCS} for needed files, rather than just the current working
  1053. directory. However, if a working file is present, MAKE totally
  1054. ignores the corresponding RCS file and uses the working file. (In
  1055. newer versions of MAKE distributed by AT&T and others,
  1056. auto-checkout can be achieved with the rule DEFAULT, instead of a
  1057. special extension of MAKE. However, a file checked out by the
  1058. rule DEFAULT will not be deleted after processing.
  1059. @code{Rcsclean} can be used for that purpose.)
  1060.  
  1061.  
  1062. With auto-checkout, RCS/MAKE can effect a selection rule
  1063. especially tuned for multi-person software development and
  1064. maintenance. In these situations, programmers should obtain
  1065. configurations that consist of the revisions they have personally
  1066. checked out plus the latest checked in revision of all other
  1067. revision groups. This schema can be set up as follows.
  1068.  
  1069.  
  1070. Each programmer chooses a working directory and places into it a
  1071. symbolic link, named @code{RCS}, to the directory containing the
  1072. relevant RCS files. The symbolic link makes sure that @code{co}
  1073. and @code{ci} operations need only specify the working files, and
  1074. that the Makefile need not be changed. The programmer then checks
  1075. out the needed files and modifies them. If MAKE is invoked, it
  1076. composes configurations by selecting those revisions that are
  1077. checked out, and the rest from the subdirectory @code{RCS}. The
  1078. latter selection may be controlled by a symbolic revision number
  1079. or any of the other selection criteria. If there are several
  1080. programmers editing in separate working directories, they are
  1081. insulated from each other's changes until checking in their
  1082. modifications.
  1083.  
  1084.  
  1085. Similarly, a maintainer can recreate an older configuration by
  1086. starting to work in an empty working directory. During the
  1087. initial MAKE invocation, all revisions are selected from RCS
  1088. files. As the maintainer checks out files and modifies them, a
  1089. new configuration is gradually built up. Every time MAKE is
  1090. invoked, it substitutes the modified revisions into the
  1091. configuration being manipulated.
  1092.  
  1093.  
  1094. A final application of RCS is to use it for storing Makefiles.
  1095. Revision groups of Makefiles represent multiple versions of
  1096. configurations. Whenever a configuration is baselined or
  1097. distributed, the best approach is to unambiguously fix the
  1098. configuration with a symbolic revision number by calling
  1099. @code{rcsfreeze}, to embed that symbol into the Makefile, and to
  1100. check in the Makefile (using the same symbolic revision number).
  1101. With this approach, old configurations can be regenerated easily
  1102. and reliably.
  1103.  
  1104.  
  1105. @c -----------------------------------------------------------------------------
  1106. @c RCS -- A System for Version Control
  1107. @c     Configuration Management
  1108. @c         Usage Statistics
  1109. @c -----------------------------------------------------------------------------
  1110. @node Statistics,Survey,MAKERCS,VersionControl
  1111. @section Usage Statistics
  1112.  
  1113. The following usage statistics were collected on two DEC
  1114. VAX-11/780 computers of the Purdue Computer Science Department.
  1115. Both machines are mainly used for research purposes.  Thus, the
  1116. data reflect an environment in which the majority of projects
  1117. involve prototyping and advanced software development, but
  1118. relatively little long-term maintenance.
  1119.  
  1120.  
  1121. For the first experiment, the @code{ci} and @code{co} operations
  1122. were instrumented to log the number of backward and forward
  1123. deltas applied. The data were collected during a 13 month period
  1124. from Dec. 1982 to Dec. 1983. Table I summarizes the results.
  1125.  
  1126.  
  1127. @example
  1128. @group
  1129. @w{Oper.  !   Total  !Total deltas!mean deltas! Operations  !Branch }
  1130. @w{       !operations!   applied  !  applied  !with >1 delta!operations}
  1131. @w{-------+----------+------------+-----------+-------------+----------}
  1132. @w{co     !     7867 !    9320    !    1.18   !   509 (6%)  ! 203 (3%)}
  1133. @w{ci     !     3468 !    2207    !    0.64   !    85 (2%)  !  75 (2%)}
  1134. @w{ci & co!    11335 !   11527    !    1.02   !   594 (5%)  ! 278 (2%)}
  1135. @w{ }
  1136. @w{ }
  1137. @center Table I.  Statistics for @code{co} and @code{ci} operations
  1138. @end group
  1139. @end example
  1140. @*
  1141. @*
  1142.  
  1143. The first two lines show statistics for check-out and check-in;
  1144. the third line shows the combination. Recall that @code{ci}
  1145. performs an implicit check-out to obtain a revision for computing
  1146. the delta. In all measures presented, the most recent revision
  1147. (stored intact) counts as one delta.  The number of deltas
  1148. applied represents the number of passes necessary, where the
  1149. first `pass' is a copying step.
  1150.  
  1151.  
  1152. Note that the check-out operation is executed more than twice as
  1153. frequently as the check-in operation. The fourth column gives the
  1154. mean number of deltas applied in all three cases. For @code{ci},
  1155. the mean number of deltas applied is less than one. The reasons
  1156. are that the initial check-in requires no delta at all, and that
  1157. the only time @code{ci} requires more than one delta is for
  1158. branches. Column 5 shows the actual number of operations that
  1159. applied more than one delta. The last column indicates that
  1160. branches were not used often.
  1161.  
  1162.  
  1163. The last three columns demonstrate that the most recent trunk
  1164. revision is by far the most frequently accessed. For RCS,
  1165. check-out of this revision is a simple copy operation, which is
  1166. the absolute minimum given the copy-semantics of @code{co}.
  1167. Access to older revisions and branches is more common in
  1168. non-academic environments, yet even if access to older deltas
  1169. were an order of magnitude more frequent, the combined average
  1170. number of deltas applied would still be below 1.2. Since RCS is
  1171. faster than SCCS until up to 10 delta applications, reverse
  1172. deltas are clearly the method of choice. .PP The second
  1173. experiment, conducted in March of 1984, involved surveying the
  1174. existing RCS files on our two machines.  The goal was to
  1175. determine the mean number of revisions per RCS file, as well as
  1176. the space consumed by them. Table II shows the results. (Tables I
  1177. and II were produced at different times and are unrelated.)
  1178.  
  1179. @smallexample
  1180. @group
  1181. @w{          !Total RCS!  Total  !Mean     !Means size!Mean size!Overhead}
  1182. @w{          ! files   !revisions!revisions!RCS files !revisions!}
  1183. @w{----------+---------+---------+---------+----------+---------+--------}
  1184. @w{All Files !    8033 !   11133 !   1.39  !   6156   !  5585   !  1.10}
  1185. @w{Files with!    1477 !    4578 !   3.10  !   8074   !  6041   !  1.34}
  1186. @w{>= 2 delta!         !         !         !          !         !}
  1187. @w{ }
  1188. @w{ }
  1189. @center Table II. Statistics for RCS files
  1190. @end group
  1191. @end smallexample
  1192. @*
  1193. @*
  1194. The mean number of revisions per RCS file is 1.39.
  1195. Columns 5 and 6 show the mean
  1196. sizes (in bytes) of an RCS file and of the latest revision of
  1197. each RCS file, respectively. The `overhead' column contains the
  1198. ratio of the mean sizes. Assuming that all revisions in an RCS
  1199. file are approximately the same size, this ratio gives a measure
  1200. of the space consumed by the extra revisions.
  1201.  
  1202.  
  1203. In our sample, over 80 per cent of the RCS files contained only a
  1204. single revision. The reason is that our systems programmers
  1205. routinely check in all source files on the distribution tapes,
  1206. even though they may never touch them again. To get a better
  1207. indication of how much space savings are possible with deltas,
  1208. all measures with those files that contained 2 or more revisions
  1209. were recomputed.  Only for those files is RCS necessary. As shown
  1210. in the second line, the average number of revisions for those
  1211. files is 3.10, with an overhead of 1.34. This means that the
  1212. extra 2.10 deltas require 34 per cent extra space, or 16 per cent
  1213. per extra revision. Rochkind(@ref{Rochkind}) measured the space
  1214. consumed by SCCS, and reported an average of 5 revisions per
  1215. group and an overhead of 1.37 (or about 9 per cent per extra
  1216. revision). In a later paper, Glasser (@ref{Glasser}) observed an
  1217. average of 7 revisions per group in a single, large project, but
  1218. provided no overhead figure. In his paper on DSEE , Leblang
  1219. (@ref{Leblang}) reported that delta storage combined with blank
  1220. compression results in an overhead of a mere 1-2 per cent per
  1221. revision. Since leading blanks accounted for about 20 per cent of
  1222. the surveyed Pascal programs, a revision group with 5-10 members
  1223. was smaller than a single cleartext copy.
  1224.  
  1225.  
  1226. The above observations demonstrate clearly that the space needed
  1227. for extra revisions is small.  With delta storage, the luxury of
  1228. keeping multiple revisions online is certainly affordable. In
  1229. fact, introducing a system with delta storage may reduce storage
  1230. requirements, because programmers often save back-up copies
  1231. anyway.  Since back-up copies are stored much more efficiently
  1232. with deltas, introducing a system such as RCS may actually free a
  1233. considerable amount of space.
  1234.  
  1235.  
  1236. @c -----------------------------------------------------------------------------
  1237. @c RCS -- A System for Version Control
  1238. @c     Survey of Version Control Tools
  1239. @c -----------------------------------------------------------------------------
  1240. @node Survey,,Statistics,VersionControl
  1241. @section Survey of Version Control Tools
  1242. The need to keep back-up copies of software arose when programs
  1243. and data were no longer stored on paper media, but were entered
  1244. from terminals and stored on disk. Back-up copies are desirable
  1245. for reliability, and many modern editors automatically save a
  1246. back-up copy for every file touched. This strategy is valuable
  1247. for short-term back-ups, but not suitable for long-term version
  1248. control, since an existing back-up copy is overwritten whenever
  1249. the corresponding file is edited.
  1250.  
  1251.  
  1252. Tape archives are suitable for long-term, offline storage. If all
  1253. changed files are dumped on a back-up tape once per day, old
  1254. revisions remain accessible.  However, tape archives are
  1255. unsatisfactory for version control in several ways.  First,
  1256. backing up the file system every 24 hours does not capture
  1257. intermediate revisions. Secondly, the old revisions are not
  1258. online, and accessing them is tedious and time-consuming. In
  1259. particular, it is impractical to compare several old revisions of
  1260. a group, because that may require mounting and searching several
  1261. tapes. Tape archives are important fail-safe tools in the event
  1262. of catastrophic disk failures or accidental deletions, but they
  1263. are ill-suited for version control. Conversely, version control
  1264. tools do not obviate the need for tape archives.
  1265.  
  1266.  
  1267. A natural technique for keeping several old revisions online is
  1268. to never delete a file. Editing a file simply creates a new file
  1269. with the same name, but with a different sequence number. This
  1270. technique, available as an option in DEC's VMS operating system,
  1271. turns out to be inadequate for version control. First, it is
  1272. prohibitively expensive in terms of storage costs, especially
  1273. since no data compression techniques are employed. Secondly,
  1274. indiscriminately storing every change produces too many
  1275. revisions, and programmers have difficulties distinguishing them.
  1276. The proliferation of revisions forces programmers to spend much
  1277. time on finding and deleting useless files. Thirdly, most of the
  1278. support functions like locking, logging, revision selection, and
  1279. identification described in this paper are not available.
  1280.  
  1281.  
  1282. An alternative approach is to separate editing from revision
  1283. control. The user may repeatedly edit a given revision, until
  1284. freezing it with an explicit command. Once a revision is frozen,
  1285. it is stored permanently and can no longer be modified. (In RCS,
  1286. freezing a revisions is done with @code{ci}.) Editing a frozen
  1287. revision implicitly creates a new one, which can again be changed
  1288. repeatedly until it is frozen itself. This approach saves exactly
  1289. those revisions that the user considers important, and keeps the
  1290. number of revisions manageable. IBM's CLEAR/CASTER (@ref{Brown}),
  1291. AT&T's SCCS (@ref{Rochkind}), CMU's SDC (@ref{Habermann}), and
  1292. DEC's CMS (@ref{DEC}), are examples of version control systems
  1293. using this approach. CLEAR/CASTER maintains a data base of
  1294. programs, specifications, documentation and messages, using
  1295. deltas. Its goal is to provide control over the development
  1296. process from a management viewpoint. SCCS stores multiple
  1297. revisions of source text in an ancestral tree, records a log
  1298. entry for each revision, provides access control, and has
  1299. facilities for uniquely identifying each revision. An efficient
  1300. delta technique reduces the space consumed by each revision
  1301. group. SDC is much simpler than SCCS because it stores not more
  1302. than two revisions.  However, it maintains a complete log for all
  1303. old revisions, some of which may be on back-up tape. CMS, like
  1304. SCCS, manages tree-structured revision groups, but offers no
  1305. identification mechanism.
  1306.  
  1307.  
  1308. Tools for dealing with configurations are still in a state of
  1309. flux. SCCS, SDC and CMS can be combined with MAKE or MAKE-like
  1310. programs. Since flexible selection rules are missing from all
  1311. these tools, it is sometimes difficult to specify precisely which
  1312. revision of each group should be passed to MAKE for building a
  1313. desired configuration. The Xerox Cedar system (@ref{Lampson})
  1314. provides a `System Modeller' that can rebuild a configuration
  1315. from an arbitrary set of module revisions. The revisions of a
  1316. module are only distinguished by creation time, and there is no
  1317. tool for managing groups. Since the selection rules are
  1318. primitive, the System Modeller appears to be somewhat tedious to
  1319. use. Apollo's DSEE (@ref{Leblang}) is a sophisticated software
  1320. engineering environment. It manages revision groups in a way
  1321. similar to SCCS and CMS. Configurations are built using
  1322. `configuration threads'. A configuration thread states which
  1323. revision of each group named in a configuration should be chosen.
  1324. A configuration thread may contain dynamic specifiers (e.g.,
  1325. `choose the revisions I am currently working on, and the most
  1326. recent revisions otherwise'), which are bound automatically at
  1327. build time. It also provides a notification mechanism for
  1328. alerting maintainers about the need to rebuild a system after a
  1329. change.
  1330.  
  1331.  
  1332. RCS is based on a general model for describing
  1333. multi-version/multi-configuration systems (@ref{Tichy1}). The
  1334. model describes systems using AND/OR graphs, where AND nodes
  1335. represent configurations, and OR nodes represent version groups.
  1336. The model gives rise to a suit of selection rules for composing
  1337. configurations, almost all of which are implemented in RCS. The
  1338. revisions selected by RCS are passed to MAKE for configuration
  1339. building. Revision group management is modelled after SCCS. RCS
  1340. retains SCCS's best features, but offers a significantly simpler
  1341. user interface, flexible selection rules, adequate integration
  1342. with MAKE and improved identification. A detailed comparison of
  1343. RCS and SCCS appears in Reference 4.
  1344.  
  1345.  
  1346. An important component of all revision control systems is a
  1347. program for computing deltas. SCCS and RCS use the program
  1348. @code{diff} (@ref{Rochkind}), which first computes the longest
  1349. common substring of two revisions, and then produces the delta
  1350. from that substring. The delta is simply an edit script
  1351. consisting of deletion and insertion commands that generate one
  1352. revision from the other.
  1353.  
  1354.  
  1355. A delta based on a longest common substring is not necessarily
  1356. minimal, because it does not take advantage of crossing block
  1357. moves. Crossing block moves arise if two or more blocks of lines
  1358. (e.g., procedures) appear in a different order in two revisions.
  1359. An edit script derived from a longest common substring first
  1360. deletes the shorter of the two blocks, and then reinserts it.
  1361. Heckel (@ref{Heckel}) proposed an algorithm for detecting block
  1362. moves, but since the algorithm is based on heuristics, there are
  1363. conditions under which the generated delta is far from minimal.
  1364. DSEE uses this algorithm combined with blank compression,
  1365. apparently with satisfactory overall results. A new algorithm
  1366. that is guaranteed to produce a minimal delta based on block
  1367. moves appears in Reference 13. A future release of RCS will use
  1368. this algorithm.
  1369. @example
  1370. @group
  1371. @code{Acknowledgements}:@*
  1372. Many people have helped make RCS a success by contributed
  1373. criticisms, suggestions, corrections, and even whole new commands
  1374. (including manual pages). The list of people is too long to be
  1375. reproduced here, but my sincere thanks for their help and
  1376. goodwill goes to all of them.
  1377. @end group
  1378. @end example
  1379.  
  1380.