rcs_sample_session
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revision | |||
rcs_sample_session [2025/03/05 15:19] – minor formatting tweaks zilog | rcs_sample_session [2025/03/05 15:47] (current) – minor re-wording zilog | ||
---|---|---|---|
Line 1: | Line 1: | ||
+ | ==== Annotated RCS Practice Session ==== | ||
+ | |||
+ | <code diff> | ||
+ | ## The Working Directory: | ||
+ | ## To get started we first need to make a working directory as well as a | ||
+ | ## RCS sub-directory. | ||
+ | ## the delta files, ex. ' | ||
+ | ## perhaps not really ideal. | ||
+ | # | ||
+ | $ mkdir -p rcs_test/ | ||
+ | $ cd rcs_test | ||
+ | |||
+ | ## Create a test file: | ||
+ | ## RCS supports a handful of keyword tags which can be included in source | ||
+ | ## files like so: " | ||
+ | ## acts upon the file. | ||
+ | ## | ||
+ | ## fubar test file with ' | ||
+ | # | ||
+ | $ printf ' | ||
+ | |||
+ | |||
+ | ## Initial file check-in: | ||
+ | ## When a file is first placed under RCS management the user is prompted | ||
+ | ## for just the file's description. | ||
+ | ## finalized with a " | ||
+ | ## subsequent check-ins as well. The ' | ||
+ | ## file in unlocked and place a read-only copy of the file in the working | ||
+ | ## directory. | ||
+ | ## especially for configuration files which need to be present. | ||
+ | # | ||
+ | $ ci -u fubar | ||
+ | RCS/ | ||
+ | enter description, | ||
+ | NOTE: This is NOT the log message! | ||
+ | >> The fubar RCS practice file | ||
+ | >> . | ||
+ | initial revision: 1.1 | ||
+ | done | ||
+ | |||
+ | ## The current state of our working directory. | ||
+ | ## file under ../RCS/ which are used to track the changes: | ||
+ | # | ||
+ | $ ls -FR | ||
+ | RCS/ fubar | ||
+ | |||
+ | ./RCS: | ||
+ | fubar,v | ||
+ | |||
+ | ## Verifying the read-only status of fubar file: | ||
+ | # | ||
+ | $ ls -l fubar | ||
+ | -r--r--r-- | ||
+ | |||
+ | |||
+ | ## Checking out RCS-managed files for editing: | ||
+ | ## The co(1) command is used for check-outs. | ||
+ | ## the file via the ' | ||
+ | ## over-writes or having to do a merge if previously checked out. In addition | ||
+ | ## the lock state of a file can be polled via rlog(1) as a proxy to determine | ||
+ | ## if it is liked check out. | ||
+ | # | ||
+ | $ co -l fubar | ||
+ | RCS/ | ||
+ | revision 1.1 (locked) | ||
+ | done | ||
+ | |||
+ | ## Verifying the read-write status of working file: | ||
+ | # | ||
+ | $ ls -l fubar | ||
+ | -rw-r--r-- | ||
+ | |||
+ | ## Committing additional revisions: | ||
+ | ## As with the initial check-in, the ci(1) command is used to commit changes made | ||
+ | ## to our test file. Below we add a second line to fubar then check it back in. | ||
+ | ## This time RCS prompts for a description of our edit(s) followed by a " | ||
+ | ## new line: | ||
+ | # | ||
+ | $ echo 'This is fubar line two.' >> fubar | ||
+ | $ ci -u fubar | ||
+ | RCS/ | ||
+ | new revision: 1.2; previous revision: 1.1 | ||
+ | enter log message, terminated with single ' | ||
+ | >> added 2nd line | ||
+ | >> . | ||
+ | done | ||
+ | |||
+ | |||
+ | ## Verifying RCS keyword Tag expansion: | ||
+ | ## It's a small file so we'll use cat(1) to show current content of fubar. | ||
+ | ## the expansion of the " | ||
+ | ## NetBSD project as can be seen at the top of various /etc/* config files: | ||
+ | # | ||
+ | $ cat fubar | ||
+ | # $Id: fubar,v 1.2 2025/03/04 04:19:48 sdfer Exp $ | ||
+ | This is fubar line one. | ||
+ | This is fubar line two. | ||
+ | |||
+ | |||
+ | ## The Art of Reversion: | ||
+ | ## It's common for humans to have a change of heart in their endeavors | ||
+ | ## and file editing is certainly not exempt. | ||
+ | ## dealing with our indecisiveness. | ||
+ | ## test file, make some edits to the working copy, then over-write the | ||
+ | ## working copy with the latest checked in version, leaving us back at | ||
+ | ## our starting point. | ||
+ | # | ||
+ | $ co -l fubar | ||
+ | RCS/ | ||
+ | revision 1.2 (locked) | ||
+ | done | ||
+ | |||
+ | ## add a third line to test file: | ||
+ | # | ||
+ | $ echo 'This is fubar line 3.' >> fubar | ||
+ | |||
+ | ## We've changed our mind => revert back to latest checked-in version. | ||
+ | ## We'll use the ' | ||
+ | ## the lock on the latest checked-in version and over-write our edited | ||
+ | ## working file with a read-only copy if we confirm the action: | ||
+ | # | ||
+ | $ co -u fubar | ||
+ | RCS/ | ||
+ | revision 1.2 (unlocked) | ||
+ | writable fubar exists; remove it? [ny](n): y # << type " | ||
+ | done | ||
+ | |||
+ | ## Verifying file state is read-only: | ||
+ | # | ||
+ | $ ls -l fubar | ||
+ | -r--r--r-- | ||
+ | |||
+ | |||
+ | ## Comparing revisions with rcsdiff(1): | ||
+ | ## The rcsdiff(1) command is similar to the standard Unix diff(1) and is | ||
+ | ## used to compute the differences between two revisions. For ease of use | ||
+ | ## The default reference point is the latest checked in revision and if | ||
+ | ## run without specifying an alternate revision the comparison is with | ||
+ | ## the working copy. Since our file is identical to the latest checked | ||
+ | ## in version the rcsdiff(1) command reports just that: | ||
+ | # | ||
+ | $ rcsdiff fubar | ||
+ | =================================================================== | ||
+ | RCS file: RCS/fubar,v | ||
+ | retrieving revision 1.2 | ||
+ | diff -r1.2 fubar | ||
+ | |||
+ | ## Providing specific versions to rcsdiff(1) shows the differences; | ||
+ | ## r1.1 and r1.2 are compared. | ||
+ | ## just ' | ||
+ | # | ||
+ | $ rcsdiff -r1.1 -r1.2 fubar | ||
+ | =================================================================== | ||
+ | RCS file: RCS/fubar,v | ||
+ | retrieving revision 1.1 | ||
+ | retrieving revision 1.2 | ||
+ | diff -r1.1 -r1.2 | ||
+ | 1c1 | ||
+ | < # $Id: fubar,v 1.1 2025/03/04 04:18:22 sdfer Exp $ | ||
+ | --- | ||
+ | > # $Id: fubar,v 1.2 2025/03/04 04:19:48 sdfer Exp $ | ||
+ | 2a3 | ||
+ | > This is fubar line two. | ||
+ | |||
+ | |||
+ | ## Similarly, if we do another check out, make some edits and run the | ||
+ | ## rcsdiff(1) command again we can see how our working copy compares | ||
+ | ## to the latest checked in revision: | ||
+ | # | ||
+ | $ co -l fubar | ||
+ | RCS/ | ||
+ | revision 1.2 (locked) | ||
+ | done | ||
+ | |||
+ | |||
+ | ## Re-add a third line to test file: | ||
+ | # | ||
+ | $ echo 'This is fubar line 3, again.' | ||
+ | |||
+ | ## Compute diff between working file and r1.2: | ||
+ | # | ||
+ | $ rcsdiff fubar | ||
+ | RCS file: RCS/fubar,v | ||
+ | retrieving revision 1.2 | ||
+ | diff -r1.2 | ||
+ | 3a4 | ||
+ | > This is fubar line 3, again. | ||
+ | |||
+ | ## Toss line 3 again and revert back to RO r1.2: | ||
+ | # | ||
+ | $ co -u fubar | ||
+ | RCS/ | ||
+ | revision 1.2 (unlocked) | ||
+ | writable fubar exists; remove it? [ny](n): y # << type " | ||
+ | done | ||
+ | |||
+ | |||
+ | ## Deleting versions: | ||
+ | ## Oops -- we've changed our mind AGAIN and want to revert to r1.1 and | ||
+ | ## DELETE r1.2 from the RCS record. | ||
+ | ## with the ' | ||
+ | ## the order doesn' | ||
+ | # | ||
+ | $ rcs -o1.2 fubar | ||
+ | RCS file: RCS/fubar,v | ||
+ | deleting revision 1.2 | ||
+ | done | ||
+ | |||
+ | ## rcs(1) left the RO copy which was still at r1.2.. | ||
+ | # | ||
+ | $ ls -l fubar | ||
+ | # | ||
+ | -r--r--r-- | ||
+ | |||
+ | ## Just for fun, instead of using cat(1) lets use the ident(1) command | ||
+ | ## to display the current state of our RCS keyword tag " | ||
+ | # | ||
+ | $ ident fubar | ||
+ | fubar: | ||
+ | $Id: fubar,v 1.2 2025/03/04 04:19:48 sdfer Exp $ | ||
+ | |||
+ | ## As we can see above the RO copy in the working directory still shows | ||
+ | ## the r1.2 edits; to fix this we'll need to check out latest checked in | ||
+ | ## version (now 1.1) and UNLOCK it: | ||
+ | # | ||
+ | $ co -u fubar | ||
+ | RCS/ | ||
+ | revision 1.1 (unlocked) | ||
+ | done | ||
+ | |||
+ | ## Re-running ident(1) shows our read-only copy now matches the latest | ||
+ | ## checked revision which is now r1.1: | ||
+ | # | ||
+ | $ ident fubar | ||
+ | fubar: | ||
+ | $Id: fubar,v 1.1 2025/03/04 04:18:22 sdfer Exp $ | ||
+ | |||
+ | |||
+ | ## Checking the logs: | ||
+ | ## The rlog(1) command can show us the change comments for any checked in | ||
+ | ## revision using ' | ||
+ | # | ||
+ | $ rlog fubar | ||
+ | RCS file: RCS/fubar,v | ||
+ | Working file: fubar | ||
+ | head: 1.1 | ||
+ | branch: | ||
+ | locks: strict | ||
+ | access list: | ||
+ | symbolic names: | ||
+ | keyword substitution: | ||
+ | total revisions: 1; | ||
+ | description: | ||
+ | The fubar RCS practice file | ||
+ | ---------------------------- | ||
+ | revision 1.1 | ||
+ | date: 2025/03/04 04: | ||
+ | Initial revision | ||
+ | ============================================================================= | ||
+ | |||
+ | |||
+ | ## Checking lock states with rlog(1): | ||
+ | ## As long as locking hasn't been disabled the rlog(1) command can be used | ||
+ | ## to determine whether a file is currently locked and thus is a proxy for | ||
+ | ## discerning whether a file is likely checked out. When the ' | ||
+ | ## used rlog(1) will print the file name(s) of any files with active locks; | ||
+ | ## files without locks are omitted, i.e. no output. | ||
+ | ## can be made utilizing this behavior like so: | ||
+ | # | ||
+ | $ [ -z " | ||
+ | => Unlocked | ||
+ | |||
+ | ## If we check out and lock our test file and re-run the above we can see | ||
+ | ## change in lock status: | ||
+ | # | ||
+ | $ co -l fubar | ||
+ | RCS/ | ||
+ | revision 1.1 (locked) | ||
+ | done | ||
+ | |||
+ | $ [ -z " | ||
+ | => Locked | ||
+ | |||
+ | </ | ||
+ | |||
+ | This concludes our whirlwind tour of RCS -- you are now an expert! 8-) | ||