tags:

views:

24

answers:

1

There is a file sitting in CVS repository of a project now, which needs to be moved to another project using SVN. And I want to keep the history of the commits.

Is there a way to do so?

+1  A: 

If this is to be a new Subversion repository, then it is trivial: just create a fake CVS repository containing the single file (as described below) and convert it using cvs2svn.

If the Subversion repository already exists, and the new file is to be the start of a new subproject in that repository, then you can do a conversion to a Subversion dumpfile (using cvs2svn's --dumpfile option), then load it into the existing repository using

$ svnadmin load --parent-dir=/newproject /path/to/svnrepo <dumpfile.out

This will create a new subproject in Subversion including directories /newproject/trunk, /newproject/branches, and /newproject/tags and (for example) the trunk version of your file will be located at /newproject/trunk/myfile.

Please be aware that the history of the new file will be migrated as a single series of Subversion commits on top of the commits that are already in your Subversion repository. Thus the Subversion commits will probably not be in chronological order, which breaks date-based searching in the Subversion repository.

Either way, you will need to start by creating a fake CVS repository containing the single file:

$ CVSREPO=$HOME/fakecvs
$ mkdir $CVSREPO
$ mkdir $CVSREPO/CVSROOT    # This directory is needed by cvs2svn but can be empty
$ mkdir $CVSREPO/proj
$ cp /path/to/myfile,v $CVSREPO/proj/

Then convert from the path $CVSREPO/proj using cvs2svn:

$ cvs2svn [options...] $CVSREPO/proj
mhagger
That was a really helpful post. Thank you very much!! But, I need to migrate one file to an already existing SVN project. Any suggestions on how may I do that (I know I can't keep the dates correct anyway)?
Jagmal
That's not so easy, especially if the one file has branches and/or tags. I suggest that you convert it as a separate project as described above, then after the import (in the HEAD revision) "svn mv" the current version of the file from its own project directory to the place where it should be located in the main project. (This will retain the file's history.) If there are multiple branches/tags, then you might have to "svn mv" and/or "svn cp" each branch/tag version of the file to the corresponding branch/tag of the main project.
mhagger