home | O'Reilly's CD bookshelfs | FreeBSD | Linux | Cisco | Cisco Exam  

Unix Power ToolsUnix Power ToolsSearch this book

39.6. List RCS Revision Numbers with rcsrevs

Figure Go to http://examples.oreilly.com/upt3 for more information on: rcsrevs

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

% rcsrevs myprog

What good is that? Here are two examples.

  1. rcsgrep -a (Section 13.7) 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 (Section 28.9). The shell loop below gets all the revision numbers and stores them in the revnum shell variable one by one; it runs co -p (Section 39.5) to send each revision to the pr -h (Section 45.6) command for formatting with a custom header; the output of the commands in the loop goes to the printer.

    '...' Section 28.14, > Section 27.12

    $ for revnum in `rcsrevs somefile`
    > do
    >   co -p -r$revnum 
     | 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 (Section 12.12) to grab the two highest revision numbers from the rcsrevs output, tail -r (Section 12.9) to reverse the order (put the older revision number first), and 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 (Section 1.21) them to bigboss:

    ? Section 28.12

    % 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

Library Navigation Links

Copyright © 2003 O'Reilly & Associates. All rights reserved.