Previous Section  < Day Day Up >  Next Section

Recipe 18.13. Retrieving Specific Older Revisions from CVS

18.13.1 Problem

You want to check out a particular older revision of a file. It might be a configuration script that you want to roll back to, or an earlier version of some brilliant code, or the best version of a short story you've been working on. Whatever it is, you're not happy with the current version, so you want to review an earlier version or versions.

18.13.2 Solution

From your sandbox, use cvs log to see the available versions of the file:

$ cvs log newerfile

   

RCS file: /home/foober/cvsroot/project/newerfile,v

Working file: newerfile

head: 1.2

branch:

locks: strict

access list:

symbolic names:

keyword substitution: kv

total revisions: 2;     selected revisions: 2

description:

----------------------------

revision 1.2

date: 2004-08-01 07:37:07 +0000;  author: foober;  state: Exp;  lines: +3 -0

added a new line for tracking specific hosts

----------------------------

revision 1.1

date: 2004-07-29 21:22:20 +0000;  author: foober;  state: Exp;

simple ethereal script to monitor HTTPS traffic

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

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

=  =  =  =

Then fetch the version you want:

$ cvs update -r 1.1 newerfile

U newerfile

This downloads a static, unchangeable version of the file. You can see the "sticky tag" with the cvs status command; this is what marks a file as static, by locking it at a particular revision:

$ cvs status newerfile

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

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

=  =  =  =  

File: newerfile         Status: Up-to-date

   Working revision:    1.1     Sun Aug  1 07:47:17 2003

   Repository revision: 1.1     /home/foober/cvsroot/project/newerfile,v

   Sticky Tag:          1.1

   Sticky Date:         (none)

   Sticky Options:      -kkv

At this point, there are a lot of things you can do with this file: use it as a reference, copy things out of it, or make a copy of it. Don't try to edit it directly, because this will goof up the revision history.

If you make a copy, you'll need to remove the sticky tag from the copy. Simply open the copy in a text editor, and change "Sticky Tag: 1.1" to "Sticky Tag: (none)."

Then, when you're finished editing, commit the file in the usual manner:

$ cvs commit

18.13.3 Discussion

This recipe demonstrates the importance of making good, descriptive log entries. When the revisions start accumulating, the descriptions are the best tool you have to find what you want.

Use cvs diff to view the differences between revisions:


cvs diff newerfile

Show changes that have been made in this file.


cvs diff -r1.3 newerfile

Show changes in this file from Version 1.3 to the current version.


cvs diff -r1.3 -r1.5 newerfile

Show changes in this file between Versions 1.3 and 1.5.

18.13.4 See Also

    Previous Section  < Day Day Up >  Next Section