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:

  1. 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
  2. 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)
  3. for edits made shared user accounts, adjust author, depending on contents of commit message.

things i've considered:

  1. running 'cvs log' on each individual ,v file - parsing output, , using rcs -m change 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
  2. 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
  3. 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

Popular posts from this blog

java - Play! framework 2.0: How to display multiple image? -

gmail - Is there any documentation for read-only access to the Google Contacts API? -

php - Controller/JToolBar not working in Joomla 2.5 -