Monday, May 10, 2010

Converting a CVS repository to SVN

I've recently gone through this with an old CVS repository we have. We wanted to keep the history but not the CVS repository. I used cvs2svn from tigris.org with great success.

This converter actually converts from CVS to many different repositories including git. It offers many options for conversion - I created an SVN dumpfile but you can also convert directly into an existing or a new SVN repository.

I chose to use the options file to run my conversion - so I could play with the different options, do dry-runs, adjust what output I needed etc. Here are some of the settings I used from the cvs2svn-example.options file that comes with the converter

ctx.output_option = DumpfileOutputOption(
dumpfile_path=r'/cvs2svn-susan-output/cvs2svn-dump1', # Name of dumpfile to create
#author_transforms=author_transforms,
)
### to output conversion to a dump file

ctx.dry_run = False ### always a good idea to do a dry run!

ctx.trunk_only ####I decided not to bring over any branches and tags

run_options.add_project(
r'/cvs-copy', ##### to specify the repos project to be converted
trunk_path='trunk',
branches_path='branches',
tags_path='tags',
.........)

For my conversion I didn't need to use many of the other possible options such as mapping author names and symbol handling. I was confident that, as I had used JDeveloper to populate my CVS repository, this had been handled for me. For instance, I didn't need to do a lot of prepping of my CVS repository to ensure that my binary files had been correctly added to the repository. This can be a problem as CVS and SVN handle them differently. The documentation at Tigris and the options file are very detailed in how to handle these potential issues.

and that's really all there was - just run the converter and point to the options file
cvs2svn --options=MYOPTIONSFILE
I then created a new Remote Directory in my target SVN repository using JDeveloper's Versioning Navigator and ran the standard load utility on the command line to add my converted CVS repository to my existing SVN repository.
svnadmin load /svn/mySVNrepository/ --parent-dir mynewSVN_dir < /cvs2svn-dump1
A check that my workspaces checked out correctly and that I could see my image files and I was done (sorry to all my QA colleagues who want more testing mentioned than this!)

No comments: