0

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?

Jagmal
  • 5,726
  • 9
  • 35
  • 35
  • Do you want to keep the history? – Bruno Sep 03 '10 at 15:52
  • Couldn't you just simply check out the CVS repository and the SVN repository, then copy the file to the SVN repository and check it in? Maybe I am misunderstanding the question. – Nate Pinchot Sep 03 '10 at 15:53
  • As Bruno said I want to keep the history. I thought that was obvious but now I will update the question explicitly. – Jagmal Sep 04 '10 at 05:15

1 Answers1

2

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
  • 2,687
  • 18
  • 13
  • 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 Sep 06 '10 at 10:45
  • 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 Sep 10 '10 at 07:05