Thu 7 Sep 2006
After migrating my company from a CVSNT server which ran on Windows to a CVS server that runs on Linux, and thinking everything went fine, I suddenly received a complaint about binary files checking out as ascii, which cause them to break.
after an investiation, I found that CVSNT has a slightly differnt repository version than the what CVS is using.
specifically, CVSNT uses “kopt b” to specify a binary file, while CVS is using “expand @b@;”.
once this was clear, I wrote this little script, that fixes all the “broken” files (files that have kopen b and does not have expand @b”), and add the “expand @b@” line to the.
before you use it, backup your repository.
for each “file,v” the script is modifying, a new backup file named “file,v.bak” is created, and the original file is fixed.
after you fix your repository make sure to tell your users to update all the binary files.
find . -not -name "*,v.bak" -exec grep -q "kopt.*b" \{\} \; -not -exec grep -q "expand.*@b@;" \{\} \; -print0 | xargs -0 -i sh -c "echo conv {};cp \"{}\" \"{}.bak\";cat \"{}.bak\" | sed 2a\"expand @b@;\" > \"{}\""
September 7th, 2006 at 11:45 pm
Of course, you could have simply ran cvsnt on your linux box (instead of running vanilla cvs) and therefore have saved yourself from the differences in the repository formats.
September 8th, 2006 at 12:30 am
of course, but I chose not to.
September 8th, 2006 at 7:57 pm
Any particular reason why you chose not to? I’ve been running cvsnt on my linux box for a couple of years without any problems.
September 8th, 2006 at 8:01 pm
it was quite an emergency, and I didn’t want to take the risk of trying a new thing to solve an urgent problem (new to me).
I will evaluate cvsnt at some point, and maybe shift to it.
September 8th, 2006 at 8:02 pm
I see you are involved with the cvsnt project, do you have any comment on my method to convert to repository?
September 9th, 2006 at 9:36 pm
Yeah, I’m involved on the periphery, doing things like cvssproxy and checkcvswrappers (although I have been known to commit changes/fixes to the cvsnt core).
If your script works, good for you… although I would have simply made a backup of your repository (so you could recover files if they broke during your processing) and not bothered with the bak files.
Its a pity that the repositoiries aren’t compatible with each other… they originally were but over time have slowly drifted apart (which is, IMHO, a bad thing… it means that you are in the situation where you are getting vendor-lock-in - even if the vendors are both open source!)
September 9th, 2006 at 10:00 pm
that’s very true, I totally agree.
the reason I relased the script here was to help locked people.
I know cvsnt can import a cvs repotitory.
with this script, the other way around is also true.
(or, at least so I hope).
December 11th, 2007 at 11:12 am
Well, this script works great!
However, if you copy that directly to putty, some of the backslashes and quotes get removed. So the best way is to type it yourself.
Also, note that print0 | xargs -0 is actually zeros, not letters o.
Thanks for the script!
December 13th, 2007 at 11:59 pm
Sonic, glad it helped.
I fixed the post so it will be possible to copy paste the script.
June 6th, 2008 at 10:15 pm
Thank you for the script. This was one of the many problems that I am having after I tried to switch to cvsnt.
My cvs repository is in a very scary state after I switched over to cvsnt. They make it sound like you should make the switch because cvsnt is better than cvs and it is all compatible, but it is not.