|
|
RCS is a Revision Control System. RCS manages multiple revisions of text files by automating their storage, retrieval, logging, identification, and merging. RCS is useful for text that is revised frequently, for example programs, documentation,graphics, papers, form letters, etc. Any time you have a file which is periodically modified you should consider using RCS.
On this page, you'll learn four commands that will give you a "quick start" on RCS:
ci -u filenameCheck a file into the RCS system co -l filenameCheck a file out with exclusive write privileges rcsdiff filenameShow changes (differences) in the file since the previous revision rlog filenameShow the detailed log of what's been done to a file in its long and storied history
Essentially, RCS saves an original copy of your file and then logs the changes you later make to it. Its archive files end with a ,v. While RCS can store its archives in your working directory, we recommend that you create a directory called RCS/ in your working directory. RCS will store its archive files in an RCS/ directory if it finds one present.
You will use the Unix mkdir (make directory) command. Make sure the directory name is in uppercase letters (i.e. "RCS," not "rcs").
login% mkdir RCS
Now we'll need to make a file to modify. Let's call it class. We'll use the pico text editor, since it's simple and available on all CSEE UNIX servers.
login% pico class
Type a simple four-line file, changing "Full name" to something more personal for you:
Full name
Oregon Graduate Institute
Beaverton, Oregon
USA
Now save the file using the Ctrl + X key sequence. Tell it Y for yes to save the modified buffer and press Enter to accept the name "class" as the file name.
You should see a "Wrote 4 lines." message
Now you'll have to check your file in, just like checking a book into a library for the first time.
login% ci -u class
We strongly recommend that you use the -u switch with the ci command. The -u makes certain that a read-only working copy of the file remains available for use after your changes have been applied and checked in. Without -u, for example, the file class will not exist until someone enters the command co class.
After you check the file in, you'll see the following message:
RCS/class,v <-- class
enter description, terminated with single '.' or end of file:
NOTE: This is NOT the log message!
>>
Add a line or two describing the file, then put a single period in the first column of the next line to end your log message.
>> This is the new class file just for testing
>> .
Your file will be assigned a revision number so that it may be tracked by RCS:
initial revision: 1.1
done
A filename,v file will be created in your RCS/ directory. This file keeps a record of the changes made throughout various versions.
If you do an ls -l class, you'll see something interesting:
-r--r--r-- 1 yourname yourgroup 165 Feb 24 08:42 class
The file is now write-protected. This is RCS's way of trying to remind people to check out the file rather than just writing to it in an undisciplined manner. Hence we come to ...
Now we're ready to modify various files in the directory. First, check out and lock (with the -l switch; that's an el, not a one) the file for writing:
login% co -l class
Let's remove the USA from the bottom of the file. Since this file will be used by people within the US only, it's unnecessary.
Open the file in the pico text editor and use the arrow keys to move your cursor to the beginning of the 4th row of text. Press and hold the Ctrl key then press K once (CTRL + K) to cut the line.
If we wanted to write out (save) the file without exiting, we could simply use Ctrl + O. Type Y to accept the name of the file being written.
Now use Ctrl + X to exit. You'll notice that, since you haven't made changes since your last save, Ctrl + X simply drops you back out to the shell.
If we want to verify what we've done, we can use the rcsdiff command to show the change in the file.
state% rcsdiff class
=====================================================
RCS file: RCS/class,v
retrieving revision 1.1
diff -r1.1 class
4c4
< USA
---
>
This tells us that where there once was a line containing the string "USA" (< USA), there's now nothing (>).
Now we'll check in "class" and note the changes we've made.
state% ci -u class
class,v <-- class
new revision: 1.2; previous revision: 1.1
enter log message, terminated with single '.' or end of file:
>> Removed country name from file.
>> .
done
If you want to review the changes that have been made to "class", just take a look at its revision log file using the rlog command.
state% rlog class
RCS file: RCS/class,v
Working file: class
head: 1.2
branch:
locks: strict
access list:
symbolic names:
keyword substitution: kv
total revisions: 2; selected revisions: 2
description:
This is the new class file just for testing
----------------------------
revision 1.2
date: 1997/09/23 06:44:16; author: reid; state: Exp; lines: +1 -1
Removed country name from file.
----------------------------
revision 1.1
date: 1997/09/23 06:39:04; author: reid; state: Exp;
Initial revision
=================================================================
This gives me the list of revisions in reverse chronological order, and what notes have been logged to the file after each revision.
So far, we've done nothing but save an ever-improving file. Where RCS really shines, however, is in retrieving an older version of your file. This comes in very handy when, say, you've added an item that you don't like or that didn't work. You can then simply check out an older revision.
state% co -l1.1 class
RCS/class,v --> class
revision 1.1 (locked)
done
The first line may seem ambiguous, so here it is in all caps:
state% CO -L1.1 CLASS
Notice how the version number is placed directly behind the -l parameter. I've opened version 1.1 of my file and locked it for writing.
Now if I open the file in a text editor, it will reflect the first version:
Your Name
Oregon Graduate Institute
Beaverton, Oregon
USA
Notice that the "USA" is back.
Once we've retrieved our old version, we can edit it like nothing has happened. So let's do so in pico:
Open the file with the command pico class.
Using the down-arrow, go to the beginning of the "Oregon Graduate Institute" line, just to the left of the text.
Press Ctrl + K to cut that line of text.
Now move the cursor to the beginning of the "Your Name" line.
Press Ctrl + U to "uncut" (or paste) the text.
Press Ctrl + X to save and exit.
Answer Y to accept the file name.
Now check the file back in and unlock it for the next person who may need to edit it.
state% ci -u class
RCS/class,v <-- class
new revision: 1.1.1.1; previous revision: 1.1
enter log message, terminated with single '.' or end of file:
>> Promoted the Institute's name.
>> .
done
Did you notice how it assigned it revision #1.1.1.1? Let's check its rlog file.
state% rlog class
RCS file: RCS/class,v
Working file: class
head: 1.2
branch:
locks: strict
access list:
symbolic names:
keyword substitution: kv
total revisions: 3; selected revisions: 3
description:
This is the new class file just for testing
----------------------------
revision 1.2
date: 1997/09/23 06:44:16; author: reid; state: Exp; lines: +1 -1
removed country name from file.
----------------------------
revision 1.1
date: 1997/09/23 06:39:04; author: reid; state: Exp;
branches: 1.1.1;
Initial revision
----------------------------
revision 1.1.1.1
date: 1997/09/23 06:56:19; author: reid; state: Exp; lines: +1 -1
Promoted the Institute's name.
=================================================================
OHSU :: OGI :: CSEE :: Support :: CSEE :: Unix
This page was most recently revised on February 03, 2006.
Please address questions or comments to the webmaster.