How to migrate CVS repositories to Plastic SCM
In this entry I will try to explain you how to migrate CVS repositories into Plastic SCM with two examples.
Things we need:
- A CVS repository
- Git installed
- Plastic SCM
First of all, we have to be sure CVSROOT environment variable points to the CVS repository directory. A good choice is:
setenv CVSROOT /usr/local/src/cvsroot
You may need to checkout a repository from your server or a collaborating web like Sourceforge :
cvs -d :pserver:email@example.com:/cvs checkout REPO
rsync -av rsync://gcgreatcode.cvs.sourceforge.net:/cvsroot/gcgreatcode/* gcode
Once we have the CVS repository in a local folder, we have to create a new folder in order to store the git repository.
mkdir gcode-git cd gcode-git
Now we are ready to execute the first import command which is “git cvsimport” . A “.git” folder will be generated.
git cvsimport -v -d :local:/home/plastic/Downloads/gcode GC
We need to provide the repository path and repository name. In the example the correct information is “/home/plastic/Downloads/gcode” for the path and “GC” for the repository name.
Now, if we execute the “git branch” command, we can check that all the branches are correctly exported to git.
We have now our repository inside git. At this point, we only have to create a git fast-export file, and import the file to Plastic SCM (same as we did with Mercurial migration), indicating the Plastic SCM server and repository name we want to create.
git fast-export --all -C repo.fe
cm fast-import myrepo@localhost:8087 repo.fe
cvs2svn/cvs2git is a tool that can be used to migrate CVS repositories to newer version control tools, including git. This tool is part of the cvs2svn project. Although cvs2git is considerably newer than cvs2svn, and much less well tested, it is believed that cvs2git can (cautiously) be used for production conversions.
We can download the lastest version from the http://cvs2svn.tigris.org/cvs2git.html webpage.To install cvs2git from a tarball, simply unpack the tarball into a directory on your conversion computer (cvs2git can be run directly from this directory).
Before executing the cvs2git tool we have to create a folder to store the results (e.g. cvs2git-tmp) and we also have to create two empty files (“git-blog.dat” and “git-dump.dat”). Those files will be used by the tool to store the result and the migration data. We execute cvs2git command indicating the CVS repository path:
cvs2git \ --blobfile=cvs2git-tmp/git-blob.dat \ --dumpfile=cvs2git-tmp/git-dump.dat \ --username=cvs2git \ /path/to/cvs/repo
This command will write in the two output files we created in the previous step. Next step, is to create an empty git repository in a new folder and initialize it:
mkdir myproject.git cd myproject.git git init –bare
This way we can load the dump files into the new git repository using the git fast-import command:
git fast-import --export-marks=../cvs2git-tmp/git-marks.dat < ../cvs2git-tmp/git-blob.dat git fast-import --import-marks=../cvs2git-tmp/git-marks.dat < ../cvs2git-tmp/git-dump.dat
On Linux/Unix this can be shortened to:
cat ../cvs2git-tmp/git-blob.dat ../cvs2git-tmp/git-dump.dat | git fast-import
Finally, as we saw in Option 1 example, we only have to create a git fast-export file and import it to Plastic:
git fast-export --all -C repo.fe cm fast-import myrepo@localhost:8087 repo.fe
And that's all! Now, it´s your turn to decide which option you prefer to migrate your repositories.