mercurial - Script to adjust history in an RCS/CVS ,v file -
in preparation migration mercurial, make systematic changes many thousands of ,v files. (i'll editing copies of originals, hasten add.)
examples of sorts of changes i'm after:
- for each revision message begins text indicates known username (e.g.
[fred bloggs]), if username in comment matches author in ,v file, delete unnecessary username text commit message - if ,v contains useful description, append commit message revision 1.1 (cvs2hg ignores description - lots of our cvs files came rcs, easy put initial commit message description field mistake)
- for edits made shared user accounts, adjust author, depending on contents of commit message.
things i've considered:
- running 'cvs log' on each individual ,v file - parsing output, , using
rcs -mchange history. problems include:- there doesn't seem way pass text file
rcs -m- if revision message contained singled and/or or double quotes, or spanned multiple lines, quite challenge quoting correctly in script - i can't see rcs or cvs facility change author name associated revision
- less importantly, start huge number of processes - think slow
- there doesn't seem way pass text file
- writing python parse ,v file, , adjust contents. problems include:
- we have mixture of line-endings in our ,v files - including binary files should have been text, , vice-versa - great care needed not corrupt files
- care needed quoting of @ character in commit messages, if fell on start of line in multi-line comment
- care needed on revisions last line of committed file changed, , doesn't have newline - meaning ,v has @ @ end of line, instead of being preceded
\n
- clone version of cvs2hg using, , try adjust code make desired edits in-place
are there other approaches less work, or existing code implements kind of functionality?
your first approach may best one. know in perl, handling quotation marks , multiple lines wouldn't problem. example:
my $revision = ...; $log_message = ...; system('rcs', "-m$revision:$log_message", $filename); where $log_message can contain arbitrary text. since string doesn't go through shell, newlines , other metacharacters won't reinterpreted. i'm sure can same thing in python.
(as second approach, wouldn't expect line endings problem. if have unix-style \n endings , windows-style \r\n endings, can treat trailing \r part of line, , should stay consistent. i'm making assumptions here layout of ,v files.)
Comments
Post a Comment