Friday, August 17, 2007

Moving a Subversion Repository to a New Computer

I recently got one of the new iMacs, and I had to move my local Subversion repository to the new Mac. Getting the repository to the new Mac was a little tricky. Most of the Subversion tutorials on the Internet deal with creating a repository from scratch so I figured an article on moving a Subversion repository to a new computer would help people.

Moving the Repository

Moving a repository to a new computer requires three steps.
  1. Dump the repository's contents to a file.
  2. Create a repository on the new computer.
  3. Load the repository with the contents of the dumped file's contents.
Run the command svnadmin dump to dump the contents of a repository to a text file. Navigate to the directory above the repository, and run svndadmin dump.

svnadmin dump RepositoryName > DumpFile

Running svnadmin dump like I just did will write the contents of your repository to a file called DumpFile. Ideally you would dump the repository contents before you get your new computer and copy the dump file to your new computer. But I was able to copy my repository folder to the new computer and run svnadmin dump on the new computer.

After creating the dump file, run the command svnadmin create to create a new repository. Navigate to where you want the repository to reside and enter the following command:

svnadmin create RepositoryName

Now it's time to fill the newly created repository with the contents of the dump file. Run the command svnadmin load to fill the repository.

svnadmin load RepositoryName < DumpFile

Now you've managed to copy the repository over to the new computer.

Changing the Repository's Path

After recreating my old repository, I opened an Xcode project that was in the repository to see if the version control information was appearing in Xcode. The only information that was appearing was the files' local revision numbers. There was no information on previous versions of the project's files.

The cause of the problem was the repository path on the new computer did not match the path on the old computer. I needed to tell the files in the repository the new path to the repository.

The svn switch command accomplished this task. To tell the files the new repository path, move to the directory where the project's files reside and run the svn switch command using the --relocate option. When using the --relocate option, you first supply the old repository path, then the new path.

svn switch --relocate /Path/On/Old/Computer /Path/On/New/Computer

After running svn switch, all the version control information began to appear in Xcode.