home *** CD-ROM | disk | FTP | other *** search
/ InfoMagic Source Code 1993 July / THE_SOURCE_CODE_CD_ROM.iso / bsd_srcs / share / doc / ps1 / 14.sccs / sccs.me < prev    next >
Encoding:
Text File  |  1991-04-17  |  34.1 KB  |  1,609 lines

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