This site will look much better in a browser that supports web standards, but is accessible to any browser or Internet device.
In Conversion to Subversion, Part I, I described the problems I found when I began converting my CVS repository to Subversion. In this article, I describe the work and surprises that came from the first project migration.
My first idea was to build the repository from the dump file and then fix the result using moves inside the repository. Unfortunately, that would have left the previous history in the wrong places in the hierarchy. Although this would not have prevented me from doing further development, looking at previous versions would be messier than I'd like.
So, obviously, I needed a was to make the repository right when projects were added for the first time. The section in Practical Subversion on importing from other systems suggested that the format was relatively easy to modify. Reviewing the relevant sections of Version Control with Subversion confirmed this information. If I could make the required changes to the dump file, then I could create a repository laid out the way I wanted it.
The first step in this process was to dump a particular project with its related tags and branches. Examining the projects I wanted to move gave me one that had neither tags nor branches. This would be about as simple a case as I could start with. To hide irrelevant details, let's call this project smallproject.
As I said in the previous article, the path for this project would have the form: trunk/Repository/smallproject
. To extract this project from the main dump file named cvs2svn-dump
, I used the following command:
svndumpfilter include trunk/Repository/smallproject \
--drop-empty-revs --renumber-revs \
< cvs2svn-dump > smallproject.dump
The --drop-empty-revs
option removed revisions that did not have any relation to the project I want. The --renumber-revs
option cleans up the numbering in the file. I found it more convenient to have contiguous revision numbers when examining the file.
Since I needed to do a relatively simple fixup to the new dump to change the path, I used a Perl one-liner to make the change:
perl -pe's!trunk/Repository/smallproject!smallproject/trunk!g;' \
smallproject.dump > smallproject2.dump
This just uses Perl's substitute operator (with '!' as a delimiter) to change the old path into the new path everywhere in the file. I put the output in a different file so I could compare them and make certain that there were no unexpected differences. After I verified that the paths in the file looked correct, I was ready to go.
One of the reasons I had picked this project was that I had decided that I wanted it in a different repository than the source code I had from my earlier experimentation. So I created a new repository using the command:
svnadmin create /home/svn/newrepos
where newrepos was actually the real name of this repository. But, we'll stick with this pseudonym for now. Then, I loaded the project with the following command:
svnadmin load /home/svn/newrepos < smallproject2.dump
This promptly failed with a message that smallproject/trunk was not found. Of course it wasn't found, I'm trying to create it.
After a bit more experimentation, I realized that the load was failing because the path /smallproject
did not exist in the repository yet, so load could not create a subdirectory. So I recreated the repository and prepared to begin again.
With a clean repository, I created the beginning of the project with the following command:
svn add file:///home/svn/newrepos/smallproject \
file:///home/svn/newrepos/smallproject/tags \
file:///home/svn/newrepos/smallproject/branches \
-m "Migrate smallproject project."
I have left off the creation of the trunk
subdirectory, otherwise the load would still fail when it attempted to create that directory. Then, I reran the load successfully. I used the svn tools to check out this project in the new repository and verify that everything appears to be as I expected.
The first actual migration worked. To simplify my work for later steps, I converted several of the command lines listed above into shell scripts to make running them a little less error prone. One other piece of insurance I started was to do a dump of any repository right before adding a new project to it. This gave me an easy way to recreate the previous state if/when something went wrong.
Next time, I'll explain how I dealt with a project with tags.
Thanks to Lars Mentrup for catching my cvsadmin/svnadmin goof. The text has been corrected.
Posted by GWade at January 29, 2005 10:13 PM. Email comments