Thursday, October 3, 2013

How to move a Project from one Subversion Repository to another?


         Moving a project from one SVN repository to another looks simple and once you start doing it you will see all kinds of issues. I spent hours reading multiple blogs on google to figure this out and nothing really helped me. I thought I have to share my experience and help anyone who is struggling to get this done..

Here is our project structure...
We have multiple projects setup under one respository called Test

Test
  project1
  project2
  project3

Project1
  Trunk
   Branches
    Tags
Branches
  B1
  B2
  B3

Lets say I want to move  project3 out of test repo to a new repository called 'internet'. Here is the procees you have to follow

This move is a 3 step process

1. Dump
2. Filter
3. Load

Dump is very simple and straigh forward. You will never get into issues

1.svnadmin dump <repopath>

Example :
svnadmin dump apps/tools/repositories/test > fulldump

Now that you took the dump of entire repository, filter it using svndumpfilter to include just the path of the project you wanted to move

2. svndumpfilter include PATH_PREFIX

Example:
svndumpfilter --drop-empty-revs --renumber-revs include trunk/project3 < fulldump > filtereddump

There is a high possibility of seeing an error at this point

Reason:
1. Renamed a file or folder and you are trying to move after the renaming is done
2. You might have created the files in branches and merged it back to trunk( Remember svn never makes a new copy it just have reference)

Invalid copy source path '/branches/folder1/folder2/ConsumerException.java'

When you see this error ... what it means is java file actual source was in branch ..so you have include that path in your filter to proceed with move
You have do this at root level.. which is including branch name and not the path of the file
I have 2 branches that got merged to trunk and i ended up adding both to make it work

now your svndumpfilter looks like this

svndumpfilter --drop-empty-revs --renumber-revs include branches/branch1 branches/branch2  trunk/project3 < fulldump >filtereddump

and fianlly once your filtering is done .. you could load that to a new repository

create a new repo
svnadmin create internet
Once the repository is created.. load the dump into it

3.  svnadmin load <repopath>
svnadmin load apps/tools/repositories/internet  < filtereddump

There are chances that load could fail with below error

svnadmin: E160013: File not found: transaction '8281-6e1', 

If you get to see this error, please create a branch in the new repository and you should be good to go

I hope this helps someone :)


Thanks
Bhargavi







No comments:

Post a Comment