In preparation for a migration to Mercurial, I would like to make some systematic changes to many thousands of ,v files. (I'll be editing copies of the originals, I hasten to add.)
Examples of the sorts of changes I'm after:
[Fred Bloggs]
), if the username in the comment matches the Author in the ,v file, then delete the unnecessary username text from the commit messageThings I've considered:
rcs -m
to change this history. Problems with this include:
rcs -m
- so if the revision message contained singled and/or or double quotes, or spanned multiple lines, it would be quite a challenge quoting it correctly in the script\n
Are there any other approaches that would be less work, or any existing code that implements this kind of functionality?
Your first approach may be the best one. I know that in Perl, handling quotation marks and multiple lines wouldn't be a problem. For example:
my $revision = ...;
my $log_message = ...;
system('rcs', "-m$revision:$log_message", $filename);
where $log_message
can contain any arbitrary text. Since the string doesn't go through the shell, newlines and other metacharacters won't be reinterpreted. I'm sure you can do the same thing in Python.
(As for your second approach, I wouldn't expect line endings to be a problem. If you have Unix-style \n
endings and Windows-style \r\n
endings, you can just treat the trailing \r
as part of the line, and everything should stay consistent. I'm making some assumptions here about the layout of ,v
files.)