Previous Section  < Day Day Up >  Next Section

Recipe 18.3. Retrieving Older File Revisions from RCS

18.3.1 Problem

It finally happened: you changed the recipe for the secret sauce, got it wrong, and can't put it right. But you've been using RCS, so you have several versions of the file in your repository, and you want to see a list of all the versions, the changelog entries, and the dates they were last edited. After figuring out which version you want, you need to check out that older working version.

18.3.2 Solution

When you have accumulated multiple revisions of a file, and you want to see a list of all of them, use rlog:

$ rlog cupsd.conf

RCS file: RCS/cupsd.conf,v

Working file: cupsd.conf

head: 1.2


locks: strict

access list:

symbolic names:

keyword substitution: kv

total revisions: 2;     selected revisions: 2


LAN printer server, for windows and linux, no samba


revision 1.3

date: 2004/07/31 03:33:46;  author: terri;  state: Exp;  lines: +1 -1

corrected error in Allow directive


revision 1.2

date: 2004/07/27 05:29:27;  author: terri;  state: Exp;  lines: +2 -0

added administrative controls to prevent users from making changes to the server


revision 1.1

date: 2004/07/27 05:19:25;  author: terri;  state: Exp;

Initial revision

=  =  =  =  =  =  =  =  =  =  =  =  =  =  =  =  =  =  =  =  =  =  =  =  =  =  =  =  =  =  

=  =  =  =  =  =  =  =  =  =  =  =  =  =  =  =  =  =  =  =  =  =  =  =  =

As you can see, this shows the importance of writing helpful comments. To check out a specific revision, specify the revision number:

$ co -l -r1.1 cupsd.conf

This overwrites your working copy of the file, which in this example is projecthome/cupsd.conf. If you don't want your working copy overwritten, preserve it by first checking it into the RCS repository.

To quickly display the file without having to check it out and open it in an editor, use the -p option:

$ co -p -r1.5 cupsd.conf

18.3.3 Discussion

When you have multiple versions of a file in your repository, the newest one will be checked out by default when you do not specify a revision number.

Once your repository is set up and working, you can see your files listed in the RCS directory and even open them in a text editor to see what RCS does to them. You'll see that even though you may have a dozen revisions of a file, there is only a single file in the repository. RCS changes only records inside the file; it does not make individual copies of each revision.

Using RCS is liberating; you don't have to waste mental energy remembering your changes because RCS will track them for you.

18.3.4 See Also

    Previous Section  < Day Day Up >  Next Section