home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 22 gnu / 22-gnu.zip / rcs57pc1.zip / doc / rcs_doc.doc < prev    next >
Text File  |  1996-02-13  |  60KB  |  1,651 lines

  1.  
  2.  
  3.  
  4.  
  5.  
  6.  
  7.  
  8.  
  9.  
  10.              RCS--A System for Version Control
  11.  
  12.  
  13.                       Walter F. Tichy
  14.               Department of Computer Sciences
  15.                      Purdue University
  16.                West Lafayette, Indiana 47907
  17.  
  18.  
  19.  
  20.  
  21.                           ABSTRACT
  22.  
  23.  
  24.           An  important  problem in program development
  25.      and maintenance is version control, i.e., the task
  26.      of  keeping  a  software system consisting of many
  27.      versions and configurations well  organized.   The
  28.      Revision  Control  System (RCS) is a software tool
  29.      that assists with that task.   RCS  manages  revi-
  30.      sions of text documents, in particular source pro-
  31.      grams, documentation, and test data.  It automates
  32.      the storing, retrieval, logging and identification
  33.      of revisions, and it provides selection mechanisms
  34.      for  composing  configurations.  This paper intro-
  35.      duces basic version control concepts and discusses
  36.      the  practice  of  version control using RCS.  For
  37.      conserving space, RCS stores deltas, i.e., differ-
  38.      ences between successive revisions.  Several delta
  39.      storage methods are discussed.   Usage  statistics
  40.      show  that RCS's delta storage method is space and
  41.      time  efficient.   The  paper  concludes  with   a
  42.      detailed survey of version control tools.
  43.  
  44.      Keywords:  configuration  management, history man-
  45.      agement, version control, revisions, deltas.
  46.  
  47.  
  48.  
  49. 1995/06/01
  50.  
  51.  
  52.  
  53.  
  54.  
  55.  
  56.  
  57.  
  58.  
  59.  
  60.  
  61.  
  62.  
  63.  
  64.  
  65.  
  66.  
  67.  
  68.  
  69.  
  70.  
  71.  
  72.  
  73.  
  74.  
  75.  
  76.              RCS--A System for Version Control
  77.  
  78.  
  79.                       Walter F. Tichy
  80.               Department of Computer Sciences
  81.                      Purdue University
  82.                West Lafayette, Indiana 47907
  83.  
  84.  
  85.  
  86.  
  87. 1.  Introduction
  88.  
  89.      Version control is the task of keeping software systems
  90. consisting  of  many  versions and configurations well orga-
  91. nized.  The Revision Control System (RCS) is a set  of  UNIX
  92. commands that assist with that task.
  93.  
  94.      RCS'  primary function is to manage revision groups.  A
  95. revision group is a set of text documents, called revisions,
  96. that  evolved from each other.  A new revision is created by
  97. manually editing an existing one.  RCS organizes  the  revi-
  98. sions  into  an ancestral tree.  The initial revision is the
  99. root of the tree, and the tree  edges  indicate  from  which
  100. revision  a  given one evolved.  Besides managing individual
  101. revision groups, RCS provides flexible  selection  functions
  102. for  composing  configurations.   RCS  may  be combined with
  103. MAKE1, resulting in a powerful package for version  control.
  104.  
  105.      RCS  also  offers  facilities  for merging updates with
  106. customer modifications, for  distributed  software  develop-
  107. ment,  and  for automatic identification.  Identification is
  108. the `stamping' of revisions and configurations  with  unique
  109. markers.   These markers are akin to serial numbers, telling
  110. software maintainers unambiguously  which  configuration  is
  111. before them.
  112.  
  113.      RCS  is  designed  for both production and experimental
  114. environments.  In production environments,  access  controls
  115. detect update conflicts and prevent overlapping changes.  In
  116. experimental environments, where strong controls  are  coun-
  117. terproductive, it is possible to loosen the controls.
  118.  
  119.      Although  RCS  was originally intended for programs, it
  120. is useful for any text that is revised frequently and  whose
  121. previous  revisions must be preserved.  RCS has been applied
  122. successfully to store the source  text  for  drawings,  VLSI
  123. -----------
  124. An earlier version of this paper was published  in
  125. Software--Practice & Experience 15, 7 (July 1985),
  126. 637-654.
  127.  
  128.  
  129.  
  130.  
  131.  
  132.  
  133.  
  134.  
  135.  
  136.                              -2-
  137.  
  138.  
  139. layouts, documentation, specifications, test data, form let-
  140. ters and articles.
  141.  
  142.      This paper discusses the practice  of  version  control
  143. using  RCS.   It  also introduces basic version control con-
  144. cepts, useful for clarifying current practice and  designing
  145. similar  systems.   Revision groups of individual components
  146. are treated in the next three sections, and  the  extensions
  147. to  configurations follow.  Because of its size, a survey of
  148. version control tools appears at the end of the paper.
  149.  
  150. 2.  Getting started with RCS
  151.  
  152.      Suppose a text file f.c is to be placed  under  control
  153. of RCS.  Invoking the check-in command
  154.  
  155.      ci  f.c
  156.  
  157. creates a new revision group with the contents of f.c as the
  158. initial revision (numbered 1.1) and stores  the  group  into
  159. the  file f.c,v.  Unless told otherwise, the command deletes
  160. f.c.  It also asks for a  description  of  the  group.   The
  161. description should state the common purpose of all revisions
  162. in the group, and becomes part of the group's documentation.
  163. All  later check-in commands will ask for a log entry, which
  164. should summarize the changes made.  (The first  revision  is
  165. assigned  a default log message, which just records the fact
  166. that it is the initial revision.)
  167.  
  168.      Files ending in ,v are called RCS files (v  stands  for
  169. versions); the others are called working files.  To get back
  170. the working file f.c in the previous  example,  execute  the
  171. check-out command:
  172.  
  173.      co  f.c
  174.  
  175. This  command extracts the latest revision from the revision
  176. group f.c,v and writes it into f.c.  The file f.c can now be
  177. edited and, when finished, checked back in with ci:
  178.  
  179.      ci  f.c
  180.  
  181. Ci  assigns number 1.2 to the new revision.  If ci complains
  182. with the message
  183.  
  184.      ci error: no lock set by <login>
  185.  
  186. then the system administrator has decided to  configure  RCS
  187. for a production environment by enabling the `strict locking
  188. feature'.  If this feature is enabled,  all  RCS  files  are
  189. initialized  such that check-in operations require a lock on
  190. the previous revision (the one from which  the  current  one
  191. evolved).   Locking  prevents  overlapping  modifications if
  192. several people  work  on  the  same  file.   If  locking  is
  193.  
  194.  
  195.  
  196.  
  197.  
  198.  
  199.  
  200.  
  201.  
  202.                              -3-
  203.  
  204.  
  205. required,  the  revision  should have been locked during the
  206. check-out by using the option -l:
  207.  
  208.      co  -l  f.c
  209.  
  210. Of course it is too late now for the check-out with locking,
  211. because  f.c has already been changed; checking out the file
  212. again would overwrite the modifications.  (To prevent  acci-
  213. dental  overwrites, co senses the presence of a working file
  214. and asks whether the user really intended to  overwrite  it.
  215. The overwriting check-out is sometimes useful for backing up
  216. to the previous revision.)  To be able to proceed  with  the
  217. check-in in the present case, first execute
  218.  
  219.      rcs  -l  f.c
  220.  
  221. This command retroactively locks the latest revision, unless
  222. someone else locked it in the meantime.  In this  case,  the
  223. two  programmers  involved have to negotiate whose modifica-
  224. tions should take precedence.
  225.  
  226.      If an RCS file is private, i.e., if only the  owner  of
  227. the  file  is  expected  to  deposit  revisions into it, the
  228. strict locking feature is unnecessary and may  be  disabled.
  229. If  strict  locking  is  disabled, the owner of the RCS file
  230. need not have a lock for check-in.  For safety reasons,  all
  231. others  still do.  Turning strict locking off and on is done
  232. with the commands:
  233.  
  234.      rcs  -U  f.c       and         rcs  -L  f.c
  235.  
  236. These commands enable or disable the strict locking  feature
  237. for  each  RCS  file individually.  The system administrator
  238. only decides whether strict locking is enabled initially.
  239.  
  240.      To reduce the clutter in a working directory,  all  RCS
  241. files can be moved to a subdirectory with the name RCS.  RCS
  242. commands look first into that directory for RCS files.   All
  243. the  commands presented above work with the RCS subdirectory
  244. without change.
  245.  
  246.      It may be undesirable that ci deletes the working file.
  247. For instance, sometimes one would like to save  the  current
  248. revision, but continue editing.  Invoking
  249.  
  250.      ci  -l  f.c
  251.  
  252. -----------
  253.    Pairs of RCS and working files can actually  be
  254. specified  in  3  ways: a) both are given, b) only
  255. the working file is given, c) only the RCS file is
  256. given.   If  a  pair is given, both files may have
  257. arbitrary path prefixes; RCS commands pair them up
  258. intelligently.
  259.  
  260.  
  261.  
  262.  
  263.  
  264.  
  265.  
  266.  
  267.  
  268.                              -4-
  269.  
  270.  
  271. checks in f.c as usual, but performs an additional check-out
  272. with locking afterwards.  Thus, the working  file  does  not
  273. disappear after the check-in.  Similarly, the option -u does
  274. a check-in followed by a check-out  without  locking.   This
  275. option is useful if the file is needed for compilation after
  276. the check-in.  Both options update the identification  mark-
  277. ers in the working file (see below).
  278.  
  279.      Besides the operations ci and co, RCS provides the fol-
  280. lowing commands:
  281.  
  282. ident       extract identification markers
  283. rcs         change RCS file attributes
  284. rcsclean    remove unchanged working files (optional)
  285. rcsdiff     compare revisions
  286. rcsfreeze   record a configuration (optional)
  287. rcsmerge    merge revisions
  288. rlog        read log messages and other information in RCS files
  289.  
  290. A synopsis of these commands appears in the Appendix.
  291.  
  292. 2.1.  Automatic Identification
  293.  
  294.      RCS can stamp source and object code with special iden-
  295. tification  strings,  similar to product and serial numbers.
  296. To obtain such identification, place the marker
  297.  
  298.      $Id$
  299.  
  300. into the text of a revision, for instance inside a  comment.
  301. The  check-out  operation  will  replace  this marker with a
  302. string of the form
  303.  
  304.      $Id:  filename  revisionnumber  date  time  author  state  locker $
  305.  
  306. This string need never be touched, because co keeps it up to
  307. date  automatically.   To  propagate  the marker into object
  308. code, simply put it into a literal character string.  In  C,
  309. this is done as follows:
  310.  
  311.      static char rcsid[] = "$Id$";
  312.  
  313. The  command  ident  extracts such markers from any file, in
  314. particular from object code.  Ident helps to find out  which
  315. revisions of which modules were used in a given program.  It
  316. returns a complete  and  unambiguous  component  list,  from
  317. which  a  copy  of  the  program can be reconstructed.  This
  318. facility is invaluable for program maintenance.
  319.  
  320.      There are several  additional  identification  markers,
  321. one for each component of $Id$.  The marker
  322.  
  323.      $Log$
  324.  
  325.  
  326.  
  327.  
  328.  
  329.  
  330.  
  331.  
  332.  
  333.  
  334.                              -5-
  335.  
  336.  
  337. has  a  similar  function.   It accumulates the log messages
  338. that are requested during check-in.  Thus, one can  maintain
  339. the  complete  history  of a revision directly inside it, by
  340. enclosing it in a comment.  Figure 1 is an edited version of
  341. a  log  contained in revision 4.1 of the file ci.c.  The log
  342. appears at the beginning of the file, and makes it  easy  to
  343. determine what the recent modifications were.
  344.  
  345.      /*
  346.       * $Log: ci.c,v $
  347.       * Revision 4.1  1983/05/10 17:03:06  wft
  348.       * Added option -d and -w, and updated assignment of date, etc. to new delta.
  349.       * Added handling of default branches.
  350.       *
  351.       * Revision 3.9  1983/02/15 15:25:44  wft
  352.       * Added call to fastcopy() to copy remainder of RCS file.
  353.       *
  354.       * Revision 3.8  1983/01/14 15:34:05  wft
  355.       * Added ignoring of interrupts while new RCS file is renamed;
  356.       * avoids deletion of RCS files by interrupts.
  357.       *
  358.       * Revision 3.7  1982/12/10 16:09:20  wft
  359.       * Corrected checking of return code from diff.
  360.       * An RCS file now inherits its mode during the first ci from the working file,
  361.       * except that write permission is removed.
  362.       */
  363.     Figure 1.  Log entries produced by the marker $Log$.
  364.  
  365. Since  revisions are stored in the form of differences, each
  366. log message is physically stored once,  independent  of  the
  367. number  of revisions present.  Thus, the $Log$ marker incurs
  368. negligible space overhead.
  369.  
  370. 3.  The RCS Revision Tree
  371.  
  372.      RCS arranges revisions in an ancestral  tree.   The  ci
  373. command  builds  this tree; the auxiliary command rcs prunes
  374. it.  The tree has a root revision,  normally  numbered  1.1,
  375. and  successive  revisions  are numbered 1.2, 1.3, etc.  The
  376. first field of a revision number is called the release  num-
  377. ber  and  the  second  one  the  level number.  Unless given
  378. explicitly, the ci command assigns a new revision number  by
  379. incrementing the level number of the previous revision.  The
  380. release number must be incremented explicitly, using the  -r
  381. option  of  ci.   Assuming there are revisions 1.1, 1.2, and
  382. 1.3 in the RCS file f.c,v, the command
  383.  
  384.      ci  -r2.1  f.c       or       ci  -r2  f.c
  385.  
  386. assigns the number 2.1 to the new revision.  Later check-ins
  387. without  the -r option will assign the numbers 2.2, 2.3, and
  388. so on.  The release number should  be  incremented  only  at
  389. major  transition  points  in  the development, for instance
  390. when a new release of a software product has been completed.
  391.  
  392.  
  393.  
  394.  
  395.  
  396.  
  397.  
  398.  
  399.  
  400.                              -6-
  401.  
  402.  
  403. 3.1.  When are branches needed?
  404.  
  405.      A  young  revision tree is slender: It consists of only
  406. one branch, called  the  trunk.   As  the  tree  ages,  side
  407. branches  may  form.  Branches are needed in the following 4
  408. situations.
  409.  
  410. Temporary fixes
  411.      Suppose a tree has 5 revisions grouped in  2  releases,
  412.      as illustrated in Figure 2.  Revision 1.3, the last one
  413.      of release 1, is in operation at customer sites,  while
  414.      release 2 is in active development.
  415.  
  416.  
  417.              1.1 ----1.2 ----1.3 ----2.1 ----2.2 ++++
  418.  
  419.  
  420.                Figure 2.  A slender revision tree.
  421.      Now imagine a customer requesting a fix of a problem in
  422.      revision 1.3, although actual development has moved  on
  423.      to release 2.  RCS does not permit an extra revision to
  424.      be spliced in between 1.3 and 2.1, since that would not
  425.      reflect  the actual development history.  Instead, cre-
  426.      ate a branch at revision 1.3, and check in the  fix  on
  427.      that branch.  The first branch starting at 1.3 has num-
  428.      ber 1.3.1, and the revisions on that  branch  are  num-
  429.      bered  1.3.1.1,  1.3.1.2, etc.  The double numbering is
  430.      needed to allow for another branch at 1.3,  say  1.3.2.
  431.      Revisions  on  the  second  branch  would  be  numbered
  432.      1.3.2.1, 1.3.2.2, and so on.  The following steps  cre-
  433.      ate branch 1.3.1 and add revision 1.3.1.1:
  434.  
  435.              co  -r1.3  f.c      -- check out revision 1.3
  436.              edit  f.c           -- change it
  437.              ci  -r1.3.1  f.c    -- check it in on branch 1.3.1
  438.  
  439.      This sequence of commands transforms the tree of Figure
  440.      2 into the one in Figure 3.  Note that it may be neces-
  441.      sary  to  incorporate  the  differences between 1.3 and
  442.      1.3.1.1 into a revision  at  level  2.   The  operation
  443.      rcsmerge automates this process (see the Appendix).
  444.  
  445.  
  446.              1.1 ----1.2 ----1.3 ----2.1 ----2.2 ++++
  447.  
  448.  
  449.  
  450.                                    1.3.1.1+++
  451.  
  452.  
  453.          Figure 3.  A revision tree with one side branch
  454.  
  455.  
  456.  
  457.  
  458.  
  459.  
  460.  
  461.  
  462.  
  463.  
  464.  
  465.  
  466.                              -7-
  467.  
  468.  
  469. Distributed development and customer modifications
  470.      Assume  a  situation as in Figure 2, where revision 1.3
  471.      is  in  operation  at  several  customer  sites,  while
  472.      release 2 is in development.  Customer sites should use
  473.      RCS to store the distributed software.   However,  cus-
  474.      tomer  modifications  should  not be placed on the same
  475.      branch as the distributed source; instead, they  should
  476.      be  placed  on  a  side branch.  When the next software
  477.      distribution arrives, it  should  be  appended  to  the
  478.      trunk  of the customer's RCS file, and the customer can
  479.      then merge the local modifications back  into  the  new
  480.      release.   In  the above example, a customer's RCS file
  481.      would contain the following  tree,  assuming  that  the
  482.      customer  has  received  revision  1.3, added his local
  483.      modifications as revision 1.3.1.1, then received  revi-
  484.      sion  2.4,  and  merged  2.4  and 1.3.1.1, resulting in
  485.      2.4.1.1.
  486.  
  487.  
  488.              1.3 --------------------2.4
  489.  
  490.  
  491.  
  492.                    1.3.1.1                 2.4.1.1
  493.  
  494.  
  495.      Figure 4.  A customer's revision tree with local modifications.
  496.  
  497.      This approach is actually practiced in the  CSNET  pro-
  498.      ject,  where several universities and a company cooper-
  499.      ate in developing a national computer network.
  500.  
  501. Parallel development
  502.      Sometimes it  is  desirable  to  explore  an  alternate
  503.      design  or a different implementation technique in par-
  504.      allel with the main line development.  Such development
  505.      should be carried out on a side branch.  The experimen-
  506.      tal changes may later be moved into the main  line,  or
  507.      abandoned.
  508.  
  509. Conflicting updates
  510.      A  common occurrence is that one programmer has checked
  511.      out a revision, but cannot complete the assignment  for
  512.      some reason.  In the meantime, another person must per-
  513.      form another modification immediately.  In  that  case,
  514.      the  second  person should check-out the same revision,
  515.      modify it, and check it in on a side branch, for  later
  516.      merging.
  517.  
  518.      Every node in a revision tree consists of the following
  519. attributes: a revision number, a check-in date and time, the
  520. author's identification, a log entry, a state and the actual
  521. text.  All these attributes are determined at the  time  the
  522. revision  is  checked in.  The state attribute indicates the
  523.  
  524.  
  525.  
  526.  
  527.  
  528.  
  529.  
  530.  
  531.  
  532.                              -8-
  533.  
  534.  
  535. status of a revision.  It is set automatically  to  `experi-
  536. mental'  during  check-in.  A revision can later be promoted
  537. to a higher status, for example `stable' or `released'.  The
  538. set of states is user-defined.
  539.  
  540. 3.2.  Revisions are represented as deltas
  541.  
  542.      For  conserving space, RCS stores revisions in the form
  543. of deltas, i.e., as differences between revisions.  The user
  544. interface completely hides this fact.
  545.  
  546.      A  delta is a sequence of edit commands that transforms
  547. one string into another.  The deltas  employed  by  RCS  are
  548. line-based,  which means that the only edit commands allowed
  549. are insertion and deletion of lines.  If a single  character
  550. in  a  line is changed, the edit scripts consider the entire
  551. line changed.  The program diff2  produces  a  small,  line-
  552. based  delta between pairs of text files.  A character-based
  553. edit script would take much longer to compute, and would not
  554. be significantly shorter.
  555.  
  556.      Using deltas is a classical space-time tradeoff: deltas
  557. reduce the space consumed, but increase access  time.   How-
  558. ever,  a  version control tool should impose as little delay
  559. as possible on programmers.  Excessive delays discourage the
  560. use  of  version  controls,  or  induce  programmers to take
  561. shortcuts that compromise system integrity.  To gain reason-
  562. ably  fast  access  time for both editing and compiling, RCS
  563. arranges deltas in the following way.  The most recent revi-
  564. sion  on the trunk is stored intact.  All other revisions on
  565. the trunk are stored as reverse  deltas.   A  reverse  delta
  566. describes  how to go backward in the development history: it
  567. produces the desired revision if applied to the successor of
  568. that  revision.   This implementation has the advantage that
  569. extraction of the latest revision is a simple and fast  copy
  570. operation.  Adding a new revision to the trunk is also fast:
  571. ci simply adds the new revision intact, replaces the  previ-
  572. ous revision with a reverse delta, and keeps the rest of the
  573. old deltas.  Thus, ci requires the computation of  only  one
  574. new delta.
  575.  
  576.      Branches  need  special  treatment.  The naive solution
  577. would be to store  complete  copies  for  the  tips  of  all
  578. branches.  Clearly, this approach would cost too much space.
  579. Instead, RCS uses forward deltas for branches.  Regenerating
  580. a  revision  on  a  side branch proceeds as follows.  First,
  581. extract the latest revision on the  trunk;  secondly,  apply
  582. reverse  deltas  until  the  fork revision for the branch is
  583. obtained; thirdly, apply forward deltas  until  the  desired
  584. branch  revision  is  reached.   Figure 5 illustrates a tree
  585. with one side branch.  Triangles pointing to  the  left  and
  586.  
  587.  
  588.  
  589.  
  590.  
  591.  
  592.  
  593.  
  594.  
  595.  
  596.  
  597.  
  598.                              -9-
  599.  
  600.  
  601. right represent reverse and forward deltas, respectively.
  602.  
  603.               |        |       |       |
  604.               +----    +----   +----   +----
  605.            1.1|    1.2 |    1.3|    2.1|     2.2
  606.               |        |       |       |
  607.  
  608.  
  609.                                    |        |
  610.                                  1.3.1.1--1.3.1.2
  611.                                    |        |
  612.                                    |        |
  613.  
  614. Figure 5.  A revision tree with reverse and forward deltas.
  615.  
  616.      Although  implementing  fast  check-out  for the latest
  617. trunk revision, this arrangement has the  disadvantage  that
  618. generation of other revisions takes time proportional to the
  619. number of deltas applied.   For  example,  regenerating  the
  620. branch  tip  in Figure 5 requires application of five deltas
  621. (including the initial one).  Since  usage  statistics  show
  622. that  the latest trunk revision is the one that is retrieved
  623. in 95 per cent of  all  cases  (see  the  section  on  usage
  624. statistics),  biasing  check-out time in favor of that revi-
  625. sion  results  in  significant  savings.   However,  careful
  626. implementation of the delta application process is necessary
  627. to provide low retrieval overhead for  other  revisions,  in
  628. particular for branch tips.
  629.  
  630.      There  are  several  techniques  for delta application.
  631. The naive one is to pass each  delta  to  a  general-purpose
  632. text  editor.  A prototype of RCS invoked the UNIX editor ed
  633. both for applying deltas and for expanding  the  identifica-
  634. tion  markers.   Although easy to implement, performance was
  635. poor, owing to the high start-up costs and excess generality
  636. of  ed.   An  intermediate  version  of  RCS used a special-
  637. purpose, stream-oriented editor.  This technique reduced the
  638. cost  of  applying  a  delta to the cost of checking out the
  639. latest trunk revision.  The reason for this behavior is that
  640. each  delta  application  involves  a complete pass over the
  641. preceding revision.
  642.  
  643.      However, there is a much better algorithm.   Note  that
  644. the  deltas are line oriented and that most of the work of a
  645. stream editor involves  copying  unchanged  lines  from  one
  646. revision to the next.  A faster algorithm avoids unnecessary
  647. copying of character strings by  using  a  piece  table.   A
  648. piece  table  is  a  one-dimensional array, specifying how a
  649. given revision is `pieced together' from lines  in  the  RCS
  650. file.   Suppose piece table PTr represents revision r.  Then
  651. PTr[i] contains the starting position of line i of  revision
  652. r.  Application of the next delta transforms piece table PTr
  653. into PTr+1.  For instance, a delete command removes a series
  654. of  entries  from  the  piece  table.   An insertion command
  655.  
  656.  
  657.  
  658.  
  659.  
  660.  
  661.  
  662.  
  663.  
  664.                             -10-
  665.  
  666.  
  667. inserts new entries, moving the entries following the inser-
  668. tion  point  further  down  the array.  The inserted entries
  669. point to the text lines in  the  delta.   Thus,  no  I/O  is
  670. involved  except  for  reading  the  delta itself.  When all
  671. deltas have been applied to the piece  table,  a  sequential
  672. pass  through  the  table looks up each line in the RCS file
  673. and copies it to the output  file,  updating  identification
  674. markers at the same time.  Of course, the RCS file must per-
  675. mit random access, since  the  copied  lines  are  scattered
  676. throughout that file.  Figure 6 illustrates an RCS file with
  677. two revisions and the corresponding piece tables.
  678.  
  679.  
  680.  
  681.  
  682.  
  683.  
  684.                  Figure 6 is not available.
  685.  
  686.  
  687.  
  688.  
  689.  
  690.         Figure 6.  An RCS file and its piece tables
  691.  
  692.      The piece table approach has the property that the time
  693. for  applying  a  single  delta is roughly determined by the
  694. size of the delta, and not by the size of the revision.  For
  695. example,  if  a  delta is 10 per cent of the size of a revi-
  696. sion, then applying it takes only 10 per cent of the time to
  697. generate  the  latest  trunk  revision.   (The stream editor
  698. would take 100 per cent.)
  699.  
  700.      There is  an  important  alternative  for  representing
  701. deltas that affects performance.  SCCS3, a precursor of RCS,
  702. uses interleaved  deltas.   A  file  containing  interleaved
  703. deltas  is partitioned into blocks of lines.  Each block has
  704. a header that  specifies  to  which  revision(s)  the  block
  705. belongs.   The  blocks  are  sorted out in such a way that a
  706. single pass over the file can pick up all the lines  belong-
  707. ing  to  a  given revision.  Thus, the regeneration time for
  708. all revisions is the same: all headers  must  be  inspected,
  709. and  the associated blocks either copied or skipped.  As the
  710. number of revisions increases, the cost  of  retrieving  any
  711. revision  is  much  higher than the cost of checking out the
  712. latest trunk revision with reverse deltas.  A detailed  com-
  713. parison  of  SCCS's  interleaved  deltas  and  RCS's reverse
  714. deltas can be found in Reference 4.  This reference  consid-
  715. ers  the  version  of  RCS with the stream editor only.  The
  716. piece table method improves performance further, so that RCS
  717. is  always faster than SCCS, except if 10 or more deltas are
  718. applied.
  719.  
  720.  
  721.  
  722.  
  723.  
  724.  
  725.  
  726.  
  727.  
  728.  
  729.  
  730.                             -11-
  731.  
  732.  
  733.      Additional speed-up  for  both  delta  methods  can  be
  734. obtained by caching the most recently generated revision, as
  735. has been implemented in DSEE.5 With caching, access time  to
  736. frequently  used  revisions  can approach normal file access
  737. time, at the cost of some additional space.
  738.  
  739. 4.  Locking: A Controversial Issue
  740.  
  741.      The locking mechanism for RCS was difficult to  design.
  742. The  problem  and  its solution are first presented in their
  743. `pure' form, followed by a discussion of  the  complications
  744. caused by `real-world' considerations.
  745.  
  746.      RCS  must  prevent  two or more persons from depositing
  747. competing changes of the same revision.   Suppose  two  pro-
  748. grammers check out revision 2.4 and modify it.  Programmer A
  749. checks in a revision before  programmer  B.   Unfortunately,
  750. programmer B has not seen A's changes, so the effect is that
  751. A's changes are covered up by B's deposit.  A's changes  are
  752. not  lost  since  all revisions are saved, but they are con-
  753. fined to a single revision.
  754.  
  755.      This conflict is prevented in RCS by locking.  Whenever
  756. someone intends to edit a revision (as opposed to reading or
  757. compiling it),  the  revision  should  be  checked  out  and
  758. locked,  using the -l option on co.  On subsequent check-in,
  759. ci tests the lock and then removes it.  At most one program-
  760. mer  at a time may lock a particular revision, and only this
  761. programmer may check  in  the  succeeding  revision.   Thus,
  762. while a revision is locked, it is the exclusive responsibil-
  763. ity of the locker.
  764.  
  765.      An important maxim for software tools like RCS is  that
  766. they  must  not  stand  in the way of making progress with a
  767. project.  This consideration leads to several weakenings  of
  768. the  locking mechanism.  First of all, even if a revision is
  769. locked, it can still be checked out.  This is  necessary  if
  770. other  people wish to compile or inspect the locked revision
  771. while the next one is in preparation.  The  only  operations
  772. they  cannot  do are to lock the revision or to check in the
  773. succeeding one.   Secondly,  check-in  operations  on  other
  774. branches  in the RCS file are still possible; the locking of
  775. one revision does not affect any other  revision.   Thirdly,
  776. revisions  are occasionally locked for a long period of time
  777. because a programmer is absent or otherwise unable  to  com-
  778. plete  the  assignment.  If another programmer has to make a
  779. -----------
  780.    Note that this problem  is  entirely  different
  781. from  the atomicity problem.  Atomicity means that
  782. concurrent update operations on the same RCS  file
  783. cannot  be  permitted,  because that may result in
  784. inconsistent data.  Atomic updates  are  essential
  785. (and  implemented  in  RCS),  but do not solve the
  786. conflict discussed here.
  787.  
  788.  
  789.  
  790.  
  791.  
  792.  
  793.  
  794.  
  795.  
  796.                             -12-
  797.  
  798.  
  799. pressing change, there are the following three  alternatives
  800. for making progress: a) find out who is holding the lock and
  801. ask that person to release it; b) check out the locked revi-
  802. sion,  modify  it,  check  it  in on a branch, and merge the
  803. changes later; c) break the lock.  Breaking a lock leaves  a
  804. highly visible trace, namely an electronic mail message that
  805. is sent automatically to the holder of the  lock,  recording
  806. the  breaker  and  a  commentary  requested from him.  Thus,
  807. breaking locks is tolerated under certain circumstances, but
  808. will  not go unnoticed.  Experience has shown that the auto-
  809. matic mail message attaches a high  enough  stigma  to  lock
  810. breaking,  such  that  programmers  break locks only in real
  811. emergencies, or when a co-worker resigns and  leaves  locked
  812. revisions behind.
  813.  
  814.      If an RCS file is private, i.e., when a programmer owns
  815. an RCS file and does  not  expect  anyone  else  to  perform
  816. check-in operations, locking is an unnecessary nuisance.  In
  817. this case, the `strict locking  feature'  discussed  earlier
  818. may  be  disabled, provided that file protection is set such
  819. that only the owner may write the RCS file.   This  has  the
  820. effect  that only the owner can check-in revisions, and that
  821. no lock is needed for doing so.
  822.  
  823.      As added protection, each RCS file contains  an  access
  824. list  that specifies the users who may execute update opera-
  825. tions.  If an access list is empty, only  normal  UNIX  file
  826. protection  applies.   Thus,  the  access list is useful for
  827. restricting the set  of  people  who  would  otherwise  have
  828. update  permission.   Just  as with locking, the access list
  829. has no effect on read-only  operations  such  as  co.   This
  830. approach is consistent with the UNIX philosophy of openness,
  831. which contributes to a productive software development envi-
  832. ronment.
  833.  
  834. 5.  Configuration Management
  835.  
  836.      The  preceding  sections  described  how RCS deals with
  837. revisions of individual components; this  section  discusses
  838. how  to  handle configurations.  A configuration is a set of
  839. revisions, where each revision comes from a different  revi-
  840. sion  group,  and  the revisions are selected according to a
  841. certain criterion.  For example, in order to build  a  func-
  842. tioning  compiler,  the  `right' revisions from the scanner,
  843. the parser, the optimizer and the  code  generator  must  be
  844. combined.   RCS, in conjunction with MAKE, provides a number
  845. of facilities to effect a smooth selection.
  846.  
  847. 5.1.  RCS Selection Functions
  848.  
  849.  
  850. Default selection
  851.      During development, the usual selection criterion is to
  852.      choose  the  latest revision of all components.  The co
  853.  
  854.  
  855.  
  856.  
  857.  
  858.  
  859.  
  860.  
  861.  
  862.                             -13-
  863.  
  864.  
  865.      command makes this selection by default.  For  example,
  866.      the command
  867.  
  868.           co  *,v
  869.  
  870.      retrieves  the latest revision on the default branch of
  871.      each RCS file in the current  directory.   The  default
  872.      branch  is  usually  the  trunk, but may be set to be a
  873.      side branch.  Side branches as defaults are  needed  in
  874.      distributed  software  development, as discussed in the
  875.      section on the RCS revision tree.
  876.  
  877.  
  878. Release based selection
  879.      Specifying a release or branch number selects the  lat-
  880.      est revision in that release or branch.  For instance,
  881.  
  882.           co  -r2  *,v
  883.  
  884.      retrieves  the  latest  revision  with release number 2
  885.      from each RCS file.  This selection is convenient if  a
  886.      release has been completed and development has moved on
  887.      to the next release.
  888.  
  889.  
  890. State and author based selection
  891.      If the highest level number within a given release num-
  892.      ber  is  not  the  desired one, the state attribute can
  893.      help.  For example,
  894.  
  895.           co  -r2  -sReleased  *,v
  896.  
  897.      retrieves the latest revision  with  release  number  2
  898.      whose  state  attribute  is `Released'.  Of course, the
  899.      state attribute has to be set appropriately, using  the
  900.      ci or rcs commands.  Another alternative is to select a
  901.      revision by its author, using the -w option.
  902.  
  903.  
  904. Date based selection
  905.      Revisions may also be  selected  by  date.   Suppose  a
  906.      release  of  an entire system was completed and current
  907.      on March 4, at 1:00 p.m. local time.  Then the command
  908.  
  909.           co  -d'March 4, 1:00 pm LT'  *,v
  910.  
  911.      checks out all the components of that release, indepen-
  912.      dent of the numbering.  The -d option specifies a `cut-
  913.      off date', i.e., the revision selected has  a  check-in
  914.      date  that is closest to, but not after the date given.
  915.  
  916. Name based selection
  917.      The  most  powerful  selection  function  is  based  on
  918.      assigning symbolic names to revisions and branches.  In
  919.  
  920.  
  921.  
  922.  
  923.  
  924.  
  925.  
  926.  
  927.  
  928.                             -14-
  929.  
  930.  
  931.      large systems, a single release number or date  is  not
  932.      sufficient  to  collect  the appropriate revisions from
  933.      all groups.  For example, suppose one wishes to combine
  934.      release  2  of one subsystem and release 15 of another.
  935.      Most likely, the creation dates of those releases  dif-
  936.      fer  also.   Thus,  a  single  revision  number or date
  937.      passed to the co command will not suffice to select the
  938.      right  revisions.  Symbolic revision numbers solve this
  939.      problem.  Each RCS file may contain a set  of  symbolic
  940.      names that are mapped to numeric revision numbers.  For
  941.      example, assume the symbol V3 is bound to release  num-
  942.      ber  2 in file s,v, and to revision number 15.9 in t,v.
  943.      Then the single command
  944.  
  945.           co  -rV3  s,v  t,v
  946.  
  947.      retrieves the latest revision of release  2  from  s,v,
  948.      and  revision  15.9  from  t,v.  In a large system with
  949.      many modules, checking out all revisions with one  com-
  950.      mand greatly simplifies configuration management.
  951.  
  952.      Judicious  use  of symbolic revision numbers helps with
  953. organizing large configurations.  A  special  command,  rcs-
  954. freeze,  assigns  a  symbolic  revision number to a selected
  955. revision in every RCS file.  Rcsfreeze effectively freezes a
  956. configuration.    The   assigned  symbolic  revision  number
  957. selects all components of the configuration.  If  necessary,
  958. symbolic  numbers  may even be intermixed with numeric ones.
  959. Thus, V3.5 in the above example would select revision 2.5 in
  960. s,v and branch 15.9.5 in t,v.
  961.  
  962.      The  options  -r,  -s, -w and -d may be combined.  If a
  963. branch is given, the latest revision on that branch satisfy-
  964. ing  all  conditions  is  retrieved;  otherwise, the default
  965. branch is used.
  966.  
  967. 5.2.  Combining MAKE and RCS
  968.  
  969.      MAKE1 is a program that processes  configurations.   It
  970. is driven by configuration specifications recorded in a spe-
  971. cial file, called a `Makefile'.  MAKE avoids redundant  pro-
  972. cessing steps by comparing creation dates of source and pro-
  973. cessed objects.  For example, when instructed to compile all
  974. modules  of  a given system, it only recompiles those source
  975. modules that were changed since they were processed last.
  976.  
  977.      MAKE has been extended with  an  auto-checkout  feature
  978. for RCS.*  When a certain file to be processed is  not  pre-
  979. sent,  MAKE  attempts a check-out operation.  If successful,
  980. MAKE performs the required processing, and then deletes  the
  981. checked   out   file   to  conserve  space.   The  selection
  982. -----------
  983.   * This auto-checkout extension is available only
  984. in some versions of MAKE, e.g. GNU MAKE.
  985.  
  986.  
  987.  
  988.  
  989.  
  990.  
  991.  
  992.  
  993.  
  994.                             -15-
  995.  
  996.  
  997. parameters discussed above can be passed to MAKE  either  as
  998. parameters,  or directly embedded in the Makefile.  MAKE has
  999. also been extended to search the subdirectory named RCS  for
  1000. needed  files,  rather  than just the current working direc-
  1001. tory.  However, if a working file is present,  MAKE  totally
  1002. ignores  the  corresponding  RCS  file  and uses the working
  1003. file.  (In newer versions of MAKE distributed  by  AT&T  and
  1004. others, auto-checkout can be achieved with the rule DEFAULT,
  1005. instead of a special extension of  MAKE.   However,  a  file
  1006. checked  out  by  the rule DEFAULT will not be deleted after
  1007. processing. Rcsclean can be used for that purpose.)
  1008.  
  1009.      With auto-checkout, RCS/MAKE  can  effect  a  selection
  1010. rule  especially tuned for multi-person software development
  1011. and maintenance.  In these  situations,  programmers  should
  1012. obtain  configurations  that  consist  of the revisions they
  1013. have personally checked out plus the latest checked in revi-
  1014. sion  of  all other revision groups.  This schema can be set
  1015. up as follows.
  1016.  
  1017.      Each programmer chooses a working directory and  places
  1018. into  it  a  symbolic link, named RCS, to the directory con-
  1019. taining the relevant RCS files.   The  symbolic  link  makes
  1020. sure that co and ci operations need only specify the working
  1021. files, and that the Makefile need not be changed.  The  pro-
  1022. grammer  then checks out the needed files and modifies them.
  1023. If MAKE is invoked, it composes configurations by  selecting
  1024. those  revisions that are checked out, and the rest from the
  1025. subdirectory RCS.  The latter selection may be controlled by
  1026. a  symbolic  revision  number  or any of the other selection
  1027. criteria.  If there are several programmers editing in sepa-
  1028. rate  working  directories,  they  are  insulated  from each
  1029. other's changes until checking in their modifications.
  1030.  
  1031.      Similarly, a maintainer can recreate an older  configu-
  1032. ration  by  starting  to work in an empty working directory.
  1033. During  the  initial  MAKE  invocation,  all  revisions  are
  1034. selected from RCS files.  As the maintainer checks out files
  1035. and modifies them, a new configuration  is  gradually  built
  1036. up.  Every time MAKE is invoked, it substitutes the modified
  1037. revisions into the configuration being manipulated.
  1038.  
  1039.      A final application of RCS is to  use  it  for  storing
  1040. Makefiles.   Revision groups of Makefiles represent multiple
  1041. versions of configurations.   Whenever  a  configuration  is
  1042. baselined  or distributed, the best approach is to unambigu-
  1043. ously fix the configuration with a symbolic revision  number
  1044. by  calling  rcsfreeze,  to embed that symbol into the Make-
  1045. file, and to check in the Makefile (using the same  symbolic
  1046. revision  number).   With  this approach, old configurations
  1047. can be regenerated easily and reliably.
  1048.  
  1049.  
  1050.  
  1051.  
  1052.  
  1053.  
  1054.  
  1055.  
  1056.  
  1057.  
  1058.  
  1059.  
  1060.                             -16-
  1061.  
  1062.  
  1063. 6.  Usage Statistics
  1064.  
  1065.      The following usage statistics were  collected  on  two
  1066. DEC  VAX-11/780  computers  of  the  Purdue Computer Science
  1067. Department.  Both machines are mainly used for research pur-
  1068. poses.   Thus,  the data reflect an environment in which the
  1069. majority of projects involve prototyping and advanced  soft-
  1070. ware  development,  but  relatively little long-term mainte-
  1071. nance.
  1072.  
  1073.      For the first experiment, the ci and co operations were
  1074. instrumented  to  log  the  number  of  backward and forward
  1075. deltas applied.  The data were collected during a  13  month
  1076. period  from Dec. 1982 to Dec. 1983.  Table I summarizes the
  1077. results.
  1078.  
  1079. +----------+-------------+--------------+-------------+---------------+------------+
  1080. |Operation |    Total    | Total deltas | Mean deltas |  Operations   |   Branch   |
  1081. |          | operations  |   applied    |   applied   | with >1 delta | operations |
  1082. +----------+-------------+--------------+-------------+---------------+------------+
  1083. |co        |     7867    |     9320     |    1.18     |  509    (6%)  | 203   (3%) |
  1084. |ci        |     3468    |     2207     |    0.64     |   85    (2%)  |  75   (2%) |
  1085. |ci & co   |    11335    |    11527     |    1.02     |  594    (5%)  | 278   (2%) |
  1086. +----------+-------------+--------------+-------------+---------------+------------+
  1087.        Table I.  Statistics for co and ci operations.
  1088.  
  1089.      The first two lines show statistics for  check-out  and
  1090. check-in; the third line shows the combination.  Recall that
  1091. ci performs an implicit check-out to obtain a  revision  for
  1092. computing  the  delta.   In all measures presented, the most
  1093. recent revision (stored intact) counts as  one  delta.   The
  1094. number  of  deltas  applied  represents the number of passes
  1095. necessary, where the first `pass' is a copying step.
  1096.  
  1097.      Note that the check-out operation is executed more than
  1098. twice  as  frequently as the check-in operation.  The fourth
  1099. column gives the mean number of deltas applied in all  three
  1100. cases.   For  ci,  the mean number of deltas applied is less
  1101. than  one.   The  reasons  are  that  the  initial  check-in
  1102. requires no delta at all, and that the only time ci requires
  1103. more than one delta is for branches.   Column  5  shows  the
  1104. actual  number  of  operations  that  applied  more than one
  1105. delta.  The last column indicates  that  branches  were  not
  1106. used often.
  1107.  
  1108.      The last three columns demonstrate that the most recent
  1109. trunk revision is by far the most frequently accessed.   For
  1110. RCS,  check-out of this revision is a simple copy operation,
  1111. which is the absolute minimum given  the  copy-semantics  of
  1112. co.   Access  to older revisions and branches is more common
  1113. in non-academic environments, yet even if  access  to  older
  1114. deltas  were  an  order of magnitude more frequent, the com-
  1115. bined average number of deltas applied would still be  below
  1116. 1.2.   Since  RCS  is  faster than SCCS until up to 10 delta
  1117.  
  1118.  
  1119.  
  1120.  
  1121.  
  1122.  
  1123.  
  1124.  
  1125.  
  1126.                             -17-
  1127.  
  1128.  
  1129. applications, reverse  deltas  are  clearly  the  method  of
  1130. choice.
  1131.  
  1132.      The  second  experiment,  conducted  in  March of 1984,
  1133. involved  surveying  the  existing  RCS  files  on  our  two
  1134. machines.   The  goal  was  to  determine the mean number of
  1135. revisions per RCS file, as well as  the  space  consumed  by
  1136. them.   Table  II  shows the results.  (Tables I and II were
  1137. produced at different times and are unrelated.)
  1138.  
  1139. +------------+-----------+-----------+-----------+--------------+--------------+----------+
  1140. |            | Total RCS |   Total   |   Mean    | Mean size of | Mean size of | Overhead |
  1141. |            |   files   | revisions | revisions |  RCS files   |  revisions   |          |
  1142. +------------+-----------+-----------+-----------+--------------+--------------+----------+
  1143. |All files   |   8033    |   11133   |   1.39    |     6156     |     5585     |   1.10   |
  1144. |Files with  |   1477    |    4578   |   3.10    |     8074     |     6041     |   1.34   |
  1145. |>= 2 deltas |           |           |           |              |              |          |
  1146. +------------+-----------+-----------+-----------+--------------+--------------+----------+
  1147.             Table II.  Statistics for RCS files.
  1148.  
  1149.      The mean number of revisions  per  RCS  file  is  1.39.
  1150. Columns  5  and  6  show the mean sizes (in bytes) of an RCS
  1151. file and of the latest revision of each  RCS  file,  respec-
  1152. tively.   The  `overhead'  column  contains the ratio of the
  1153. mean sizes.  Assuming that all revisions in an RCS file  are
  1154. approximately  the  same size, this ratio gives a measure of
  1155. the space consumed by the extra revisions.
  1156.  
  1157.      In our sample, over 80 per cent of the RCS  files  con-
  1158. tained  only a single revision.  The reason is that our sys-
  1159. tems programmers routinely check in all source files on  the
  1160. distribution  tapes,  even  though they may never touch them
  1161. again.  To get a better indication of how much space savings
  1162. are possible with deltas, all measures with those files that
  1163. contained 2 or more revisions  were  recomputed.   Only  for
  1164. those  files is RCS necessary.  As shown in the second line,
  1165. the average number of revisions for  those  files  is  3.10,
  1166. with  an  overhead  of 1.34.  This means that the extra 2.10
  1167. deltas require 34 per cent extra space, or 16 per  cent  per
  1168. extra  revision.   Rochkind3  measured the space consumed by
  1169. SCCS, and reported an average of 5 revisions per  group  and
  1170. an  overhead  of  1.37  (or about 9 per cent per extra revi-
  1171. sion).  In a later paper, Glasser6 observed an average of  7
  1172. revisions per group in a single, large project, but provided
  1173. no overhead figure.  In his paper on DSEE5, Leblang reported
  1174. that  delta  storage combined with blank compression results
  1175. in an overhead of a mere 1-2 per cent per  revision.   Since
  1176. leading  blanks  accounted for about 20 per cent of the sur-
  1177. veyed Pascal programs, a revision group  with  5-10  members
  1178. was smaller than a single cleartext copy.
  1179.  
  1180.      The  above  observations  demonstrate  clearly that the
  1181. space needed for extra revisions is small.  With delta stor-
  1182. age,  the  luxury  of  keeping  multiple revisions online is
  1183.  
  1184.  
  1185.  
  1186.  
  1187.  
  1188.  
  1189.  
  1190.  
  1191.  
  1192.                             -18-
  1193.  
  1194.  
  1195. certainly affordable.  In fact, introducing  a  system  with
  1196. delta  storage may reduce storage requirements, because pro-
  1197. grammers often save back-up copies  anyway.   Since  back-up
  1198. copies  are stored much more efficiently with deltas, intro-
  1199. ducing a system such as RCS may actually free a considerable
  1200. amount of space.
  1201.  
  1202. 7.  Survey of Version Control Tools
  1203.  
  1204.      The  need to keep back-up copies of software arose when
  1205. programs and data were no longer stored on paper media,  but
  1206. were  entered  from  terminals  and stored on disk.  Back-up
  1207. copies are desirable for reliability, and many  modern  edi-
  1208. tors  automatically  save  a  back-up  copy  for  every file
  1209. touched.  This strategy is valuable for short-term back-ups,
  1210. but  not  suitable  for  long-term version control, since an
  1211. existing back-up copy is  overwritten  whenever  the  corre-
  1212. sponding file is edited.
  1213.  
  1214.      Tape archives are suitable for long-term, offline stor-
  1215. age.  If all changed files are dumped on a back-up tape once
  1216. per  day,  old  revisions  remain accessible.  However, tape
  1217. archives are unsatisfactory for version control  in  several
  1218. ways.  First, backing up the file system every 24 hours does
  1219. not capture intermediate revisions.  Secondly, the old revi-
  1220. sions  are  not  online,  and  accessing them is tedious and
  1221. time-consuming.  In particular, it is impractical to compare
  1222. several  old  revisions of a group, because that may require
  1223. mounting and searching several  tapes.   Tape  archives  are
  1224. important  fail-safe tools in the event of catastrophic disk
  1225. failures or accidental deletions, but  they  are  ill-suited
  1226. for  version  control.  Conversely, version control tools do
  1227. not obviate the need for tape archives.
  1228.  
  1229.      A natural technique for keeping several  old  revisions
  1230. online  is  to  never  delete a file.  Editing a file simply
  1231. creates a new file with the same name, but with a  different
  1232. sequence  number.  This technique, available as an option in
  1233. DEC's VMS operating system, turns out to be  inadequate  for
  1234. version  control.   First,  it is prohibitively expensive in
  1235. terms of storage costs, especially since no data compression
  1236. techniques are employed.  Secondly, indiscriminately storing
  1237. every change produces too many  revisions,  and  programmers
  1238. have difficulties distinguishing them.  The proliferation of
  1239. revisions forces programmers to spend much time  on  finding
  1240. and  deleting  useless  files.  Thirdly, most of the support
  1241. functions like locking,  logging,  revision  selection,  and
  1242. identification described in this paper are not available.
  1243.  
  1244.      An  alternative  approach  is  to separate editing from
  1245. revision control.  The user  may  repeatedly  edit  a  given
  1246. revision,  until freezing it with an explicit command.  Once
  1247. a revision is frozen, it is stored permanently  and  can  no
  1248. longer  be  modified.  (In RCS, freezing a revisions is done
  1249.  
  1250.  
  1251.  
  1252.  
  1253.  
  1254.  
  1255.  
  1256.  
  1257.  
  1258.                             -19-
  1259.  
  1260.  
  1261. with ci.)  Editing a frozen revision  implicitly  creates  a
  1262. new  one,  which can again be changed repeatedly until it is
  1263. frozen itself.  This approach saves exactly those  revisions
  1264. that  the  user considers important, and keeps the number of
  1265. revisions manageable.  IBM's  CLEAR/CASTER7,  AT&T's  SCCS3,
  1266. CMU's  SDC8  and DEC's CMS9, are examples of version control
  1267. systems using this approach.  CLEAR/CASTER maintains a  data
  1268. base  of  programs,  specifications,  documentation and mes-
  1269. sages, using deltas.  Its goal is to  provide  control  over
  1270. the  development  process from a management viewpoint.  SCCS
  1271. stores multiple revisions of source  text  in  an  ancestral
  1272. tree, records a log entry for each revision, provides access
  1273. control, and has facilities for  uniquely  identifying  each
  1274. revision.   An  efficient  delta technique reduces the space
  1275. consumed by each revision group.  SDC is much  simpler  than
  1276. SCCS  because  it  stores not more than two revisions.  How-
  1277. ever, it maintains a complete log  for  all  old  revisions,
  1278. some  of which may be on back-up tape.  CMS, like SCCS, man-
  1279. ages tree-structured revision groups, but offers no  identi-
  1280. fication mechanism.
  1281.  
  1282.      Tools  for  dealing  with configurations are still in a
  1283. state of flux.  SCCS, SDC and CMS can be combined with  MAKE
  1284. or  MAKE-like  programs.  Since flexible selection rules are
  1285. missing from all these tools, it is sometimes  difficult  to
  1286. specify  precisely  which  revision  of each group should be
  1287. passed to MAKE for building a  desired  configuration.   The
  1288. Xerox  Cedar  system10 provides a `System Modeller' that can
  1289. rebuild a configuration from  an  arbitrary  set  of  module
  1290. revisions.  The revisions of a module are only distinguished
  1291. by creation time, and there is no tool for managing  groups.
  1292. Since the selection rules are primitive, the System Modeller
  1293. appears to be somewhat tedious to use.  Apollo's DSEE5 is  a
  1294. sophisticated  software engineering environment.  It manages
  1295. revision groups in a way similar to SCCS and CMS.   Configu-
  1296. rations are built using `configuration threads'.  A configu-
  1297. ration thread states which revision of each group named in a
  1298. configuration  should be chosen.  A configuration thread may
  1299. contain dynamic specifiers (e.g., `choose the revisions I am
  1300. currently  working  on, and the most recent revisions other-
  1301. wise'), which are bound automatically  at  build  time.   It
  1302. also  provides  a  notification mechanism for alerting main-
  1303. tainers about the need to rebuild a system after a change.
  1304.  
  1305.      RCS is based on a general model for  describing  multi-
  1306. version/multi-configuration  systems11.  The model describes
  1307. systems using AND/OR graphs, where AND nodes represent  con-
  1308. figurations,  and  OR  nodes  represent version groups.  The
  1309. model gives rise to a suit of selection rules for  composing
  1310. configurations,  almost all of which are implemented in RCS.
  1311. The revisions selected by RCS are passed to MAKE for config-
  1312. uration  building.   Revision  group  management is modelled
  1313. after SCCS.  RCS retains SCCS's best features, but offers  a
  1314. significantly  simpler  user  interface,  flexible selection
  1315.  
  1316.  
  1317.  
  1318.  
  1319.  
  1320.  
  1321.  
  1322.  
  1323.  
  1324.                             -20-
  1325.  
  1326.  
  1327. rules, adequate integration with MAKE and improved identifi-
  1328. cation.   A  detailed  comparison of RCS and SCCS appears in
  1329. Reference 4.
  1330.  
  1331.      An important component of all revision control  systems
  1332. is  a  program  for  computing deltas.  SCCS and RCS use the
  1333. program diff2, which first computes the longest common  sub-
  1334. string  of  two  revisions, and then produces the delta from
  1335. that substring.  The delta is simply an edit script consist-
  1336. ing  of  deletion  and  insertion commands that generate one
  1337. revision from the other.
  1338.  
  1339.      A delta based on a longest common substring is not nec-
  1340. essarily  minimal,  because  it  does  not take advantage of
  1341. crossing block moves.  Crossing block moves arise if two  or
  1342. more  blocks of lines (e.g., procedures) appear in a differ-
  1343. ent order in two revisions.  An edit script derived  from  a
  1344. longest  common  substring  first deletes the shorter of the
  1345. two blocks, and then reinserts  it.   Heckel12  proposed  an
  1346. algorithm for detecting block moves, but since the algorithm
  1347. is based on heuristics, there are conditions under which the
  1348. generated  delta  is far from minimal.  DSEE uses this algo-
  1349. rithm combined with blank compression, apparently with  sat-
  1350. isfactory  overall results.  A new algorithm that is guaran-
  1351. teed to produce a minimal delta based on block moves appears
  1352. in  Reference  13.   A  future  release of RCS will use this
  1353. algorithm.
  1354.  
  1355.      Acknowledgements: Many people have helped  make  RCS  a
  1356. success by contributed criticisms, suggestions, corrections,
  1357. and even whole new commands (including manual  pages).   The
  1358. list  of  people  is  too long to be reproduced here, but my
  1359. sincere thanks for their help and goodwill goes  to  all  of
  1360. them.
  1361.  
  1362.  
  1363. Appendix: Synopsis of RCS Operations
  1364.  
  1365.  
  1366. ci - check in revisions
  1367.      Ci  stores the contents of a working file into the cor-
  1368.      responding RCS file as a new revision.  If the RCS file
  1369.      doesn't  exist,  ci creates it.  Ci removes the working
  1370.      file, unless one of the options -u or  -l  is  present.
  1371.      For  each check-in, ci asks for a commentary describing
  1372.      the changes relative to the previous revision.
  1373.  
  1374.      Ci assigns the revision number given by the -r  option;
  1375.      if  that  option is missing, it derives the number from
  1376.      the lock held by the user; if  there  is  no  lock  and
  1377.      locking  is not strict, ci increments the number of the
  1378.      latest revision on the trunk.  A side branch  can  only
  1379.      be started by explicitly specifying its number with the
  1380.      -r option during check-in.
  1381.  
  1382.  
  1383.  
  1384.  
  1385.  
  1386.  
  1387.  
  1388.  
  1389.  
  1390.                             -21-
  1391.  
  1392.  
  1393.      Ci also determines whether the revision to  be  checked
  1394.      in is different from the previous one, and asks whether
  1395.      to proceed if not.  This facility  simplifies  check-in
  1396.      operations  for  large  systems,  because  one need not
  1397.      remember which files were changed.
  1398.  
  1399.      The option -k searches the checked in file for  identi-
  1400.      fication  markers  containing  the  attributes revision
  1401.      number, check-in date, author and  state,  and  assigns
  1402.      these  to  the new revision rather than computing them.
  1403.      This option is useful for software distribution: Recip-
  1404.      ients of distributed software using RCS should check in
  1405.      updates with the -k option.  This convention guarantees
  1406.      that  revision  numbers,  check-in dates, etc., are the
  1407.      same at all sites.
  1408.  
  1409. co - check out revisions
  1410.      Co retrieves revisions according  to  revision  number,
  1411.      date,  author  and  state attributes.  It either places
  1412.      the revision into the working file, or prints it on the
  1413.      standard  output.  Co always expands the identification
  1414.      markers.
  1415.  
  1416. ident - extract identification markers
  1417.      Ident extracts the identification markers  expanded  by
  1418.      co from any file and prints them.
  1419.  
  1420. rcs - change RCS file attributes
  1421.      Rcs  is an administrative operation that changes access
  1422.      lists,  locks,  unlocks,  breaks  locks,  toggles   the
  1423.      strict-locking  feature, sets state attributes and sym-
  1424.      bolic revision numbers, changes  the  description,  and
  1425.      deletes  revisions.   A revision can only be deleted if
  1426.      it is not the fork of a side branch.
  1427.  
  1428. rcsclean - clean working directory
  1429.      Rcsclean removes working files that  were  checked  out
  1430.      but never changed.*
  1431.  
  1432. rcsdiff - compare revisions
  1433.      Rcsdiff compares two revisions and prints their differ-
  1434.      ence,  using  the UNIX tool diff.  One of the revisions
  1435.      compared may be checked out.  This  command  is  useful
  1436.      for finding out about changes.
  1437.  
  1438. rcsfreeze - freeze a configuration
  1439.      Rcsfreeze  assigns the same symbolic revision number to
  1440.      a given revision in all RCS  files.   This  command  is
  1441.      useful for accurately recording a configuration.*
  1442.  
  1443.  
  1444. -----------
  1445.   * The   rcsclean   and  rcsfreeze  commands  are
  1446. optional and are not always installed.
  1447.  
  1448.  
  1449.  
  1450.  
  1451.  
  1452.  
  1453.  
  1454.  
  1455.  
  1456.                             -22-
  1457.  
  1458.  
  1459. rcsmerge - merge revisions
  1460.      Rcsmerge  merges  two  revisions,  rev1  and rev2, with
  1461.      respect to a common ancestor.  A 3-way file  comparison
  1462.      determines  the segments of lines that are (a) the same
  1463.      in all three revisions, or (b) the same in 2 revisions,
  1464.      or  (c)  different  in  all three.  For all segments of
  1465.      type (b) where rev1 is the differing revision, the seg-
  1466.      ment  in  rev1  replaces  the  corresponding segment of
  1467.      rev2.  Type (c) indicates  an  overlapping  change,  is
  1468.      flagged  as an error, and requires user intervention to
  1469.      select the correct alternative.
  1470.  
  1471. rlog - read log messages
  1472.      Rlog prints the log messages and other  information  in
  1473.      an RCS file.
  1474.  
  1475.  
  1476.  
  1477.  
  1478.  
  1479.  
  1480.  
  1481.  
  1482.  
  1483.  
  1484.  
  1485.  
  1486.  
  1487.  
  1488.  
  1489.  
  1490.  
  1491.  
  1492.  
  1493.  
  1494.  
  1495.  
  1496.  
  1497.  
  1498.  
  1499.  
  1500.  
  1501.  
  1502.  
  1503.  
  1504.  
  1505.  
  1506.  
  1507.  
  1508.  
  1509.  
  1510.  
  1511.  
  1512.  
  1513.  
  1514.  
  1515.  
  1516.  
  1517.  
  1518.  
  1519.  
  1520.  
  1521.  
  1522.                             -23-
  1523.  
  1524.  
  1525. References
  1526.  
  1527. 1.   Feldman,  Stuart  I.,  "Make--A Program for Maintaining
  1528.      Computer Programs," Software--Practice & Experience, 9,
  1529.      3, pp. 255-265 (March 1979).
  1530.  
  1531. 2.   Hunt,  James  W.  and McIlroy, M. D., "An Algorithm for
  1532.      Differential File Comparison,"  41,  Computing  Science
  1533.      Technical Report, Bell Laboratories (June 1976).
  1534.  
  1535. 3.   Rochkind,  Marc  J.,  "The Source Code Control System,"
  1536.      IEEE Transactions on Software Engineering, SE-1, 4, pp.
  1537.      364-370 (Dec. 1975).
  1538.  
  1539. 4.   Tichy,  Walter F., "Design, Implementation, and Evalua-
  1540.      tion of a Revision Control System"  in  Proceedings  of
  1541.      the  6th International Conference on Software Engineer-
  1542.      ing, pp. 58-67, ACM, IEEE, IPS, NBS (September 1982).
  1543.  
  1544. 5.   Leblang, David B. and Chase, Robert P., "Computer-Aided
  1545.      Software Engineering in a Distributed Workstation Envi-
  1546.      ronment," SIGPLAN Notices,  19,  5,  pp.  104-112  (May
  1547.      1984).  Proceedings of the ACM SIGSOFT/SIGPLAN Software
  1548.      Engineering Symposium on Practical Software Development
  1549.      Environments..
  1550.  
  1551. 6.   Glasser,  Alan L., "The Evolution of a Source Code Con-
  1552.      trol System," Software Engineering  Notes,  3,  5,  pp.
  1553.      122-125  (Nov. 1978). Proceedings of the Software Qual-
  1554.      ity and Assurance Workshop.
  1555.  
  1556. 7.   Brown, H.B., "The Clear/Caster System," Nato Conference
  1557.      on Software Engineering, Rome (1970).
  1558.  
  1559. 8.   Habermann, A. Nico, A Software Development Control Sys-
  1560.      tem,  Technical  Report,  Carnegie-Mellon   University,
  1561.      Department of Computer Science (Jan. 1979).
  1562.  
  1563. 9.   DEC, Code Management System, Digital Equipment Corpora-
  1564.      tion (1982). Document No. EA-23134-82.
  1565.  
  1566. 10.  Lampson, Butler W. and Schmidt, Eric E., "Practical Use
  1567.      of  a  Polymorphic Applicative Language" in Proceedings
  1568.      of the 10th Symposium on Principles of Programming Lan-
  1569.      guages, pp. 237-255, ACM (January 1983).
  1570.  
  1571. 11.  Tichy, Walter F., "A Data Model for Programming Support
  1572.      Environments and its Application"  in  Automated  Tools
  1573.      for  Information  System  Design  and  Development, ed.
  1574.      Hans-Jochen Schneider and Anthony I. Wasserman,  North-
  1575.      Holland Publishing Company, Amsterdam (1982).
  1576.  
  1577. 12.  Heckel,  Paul,  "A  Technique for Isolating Differences
  1578.      Between Files," Communications of the ACM, 21,  4,  pp.
  1579.  
  1580.  
  1581.  
  1582.  
  1583.  
  1584.  
  1585.  
  1586.  
  1587.  
  1588.                             -24-
  1589.  
  1590.  
  1591.      264-268 (April 1978).
  1592.  
  1593. 13.  Tichy,  Walter  F.,  "The  String-to-String  Correction
  1594.      Problem with Block Moves," ACM Transactions on Computer
  1595.      Systems, 2, 4, pp. 309-321 (Nov. 1984).
  1596.  
  1597.  
  1598.  
  1599.  
  1600.  
  1601.  
  1602.  
  1603.  
  1604.  
  1605.  
  1606.  
  1607.  
  1608.  
  1609.  
  1610.  
  1611.  
  1612.  
  1613.  
  1614.  
  1615.  
  1616.  
  1617.  
  1618.  
  1619.  
  1620.  
  1621.  
  1622.  
  1623.  
  1624.  
  1625.  
  1626.  
  1627.  
  1628.  
  1629.  
  1630.  
  1631.  
  1632.  
  1633.  
  1634.  
  1635.  
  1636.  
  1637.  
  1638.  
  1639.  
  1640.  
  1641.  
  1642.  
  1643.  
  1644.  
  1645.  
  1646.  
  1647.  
  1648.  
  1649.  
  1650.  
  1651.