start page | rating of books | rating of authors | reviews | copyrights

UNIX Power Tools

UNIX Power ToolsSearch this book
Previous: 20.14 RCS Basics Chapter 20
Backing Up Files
Next: 21. More About Managing Files
 

20.15 List RCS Revision Numbers with rcsrevs

rcsrevs
The rcsrevs script tells you all the revision numbers that are stored in an RCS (20.14) file. For instance:

% rcsrevs myprog
1.3 
1.2
1.1
1.2.1.1

What good is that? Here are two examples.

  1. rcsgrep -a (27.10) uses rcsrevs when it's searching all revisions of an RCS file. If you want to print all revisions, run a program across all revisions to do some kind of check, and so on, rcsrevs can give you the revision numbers to use in a loop (9.12, 9.11). The shell loop below gets all the revision numbers and stores them in the revnum shell variable one by one; it runs co -p (20.14) to send each revision to the pr -h (43.7) command for formatting with a custom header; the output of the commands in the loop goes to the printer.

    `...` 
    > 
    
    done|lpr 
    $ for revnum in `rcsrevs somefile`
    > do 
    >   co -p -r$revnum somefile | pr -h "somefile revision #$revnum"
    > done | lpr

  2. You'd like to compare the two most recent revisions of several RCS files to see what the last change was. But the revision numbers in each file are different. (One file's latest revision might be 2.4, another file could be at 1.7, etc.) Use head (25.20) to grab the two highest revision numbers from the rcsrevs output, tail -r (25.15) to reverse the order (put the older revision number first), use sed to make the revision numbers into a pair of -r options (like -r1.6 -r1.7), then run rcsdiff to do the comparisons and email (1.33) them to bigboss:

    
? 
    
    % foreach file (*.cc *.h Makefile)
    ? set revs=`rcsrevs $f | head -2 | tail -r | sed 's/^/-r/'`
    ? rcsdiff $revs $f | mail -s "changes to $file" bigboss
    ? end

rcsrevs accepts rlog options to control what revisions are shown. So rcsrevs -r2 somefile would list only revisions 2.0 and above, rcsrevs -sbeta would list the revisions in beta state, and so on.

- JP


Previous: 20.14 RCS Basics UNIX Power ToolsNext: 21. More About Managing Files
20.14 RCS Basics Book Index21. More About Managing Files

The UNIX CD Bookshelf NavigationThe UNIX CD BookshelfUNIX Power ToolsUNIX in a NutshellLearning the vi Editorsed & awkLearning the Korn ShellLearning the UNIX Operating System