"fixing" RCS files

Jonathan Stowe jns at gellyfish.com
Thu Feb 2 09:59:20 GMT 2006

On Wed, 2006-02-01 at 21:32, Tara Andrews wrote:

> So.  Is there anything out there that will take an RCS file with some
> amount of revision logging, and output an RCS file from an alternate
> universe where no one was foolish enough to stick the $Log$ keyword
> in?  Is there anything that will get me part of the way there?

I think by now you should be fairly clear on how to prevent the $Log$
being expanded in the files going forward, but what this doesn't address
is the log entries that are already in the files, the thing is that once
they have been inserted into the source file through the $Log$ directive
they are part of the source file and need to be removed in there rather
than in the ,v files directly, how you do that is entirely dependent on
what language the source files are for (i.e. how they are marked as
comment rather than program text) and whereabouts in the file they
appear: if for instance they are Perl files and as is common the log
entries are in a block at the top, you are probably best simply removing
all the comment lines from the beginning of the file and replacing the
shebang line, if you have precious stuff in the comments as well then
you have a different problem which will require a little program.

For a particular comment style in a group of perl files I have something
like this would work but obviously it needs to be adjusted for your

#!/usr/bin/perl -w
use strict;
my $start_log = 0;
my $in_log_entry = 0;
    if (/^#/)
      if (/\$Log:/)
      elsif ( $start_log and /Revision\s+\d/)
      elsif ( /^#\s*$/ ) # adjust this to your comment style
         $in_log_entry = 0;
      elsif ( $in_log_entry )

That is to say it looks for the $Log in the file and then after that it
looks for a 'Revision' line and then excises all of the  lines after
that until it sees a line with just comment character and no text and so
on and so forth.  I'm sure someone could make this into a one liner but
my brane don't work like that.


This e-mail is sponsored by http://www.integration-house.com/

More information about the london.pm mailing list