home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / RCS43X.ZIP / RCS.DOC < prev    next >
Text File  |  1990-11-19  |  61KB  |  1,704 lines

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