Friday, November 4, 2011

Subversion repository running out of space? All projects in same repo ?

If you host many projects on single subversion repository & keep going for many years repo will grow for TBs & difficult to manage, Developers in each project may experience slowness. To avoid that we can use git to extract subversion projects separately and host again on subversion with repos for each project.

Here is the example....

Figure 1

Figure 2

MURALI & SANATH are servers that host Old subversion repository & New Subversion repository respectively as in Figure 2.

All commands should run on server SANATH
SANATH should contain following directory paths...

LDAP authentication used for each Legacy & New servers

Step 1
Make a copy of single project from Legacy subversion repository in to SANATH
> cd /data/gitrepo
> git svn clone

This will create a folder /data/gitrepo/Zain with version information.

Step 2
Now the tricky backward engineering goes...
Create subversion repository on SANATH

> cd /data/newsvnrepo
> svnadmin create Zain

Host on Apache


<Location /Zain>

   DAV svn
   SVNPath /data/newsvnrepo/Zain
      AuthType Basic
      AuthName \"LDAP's Authorization\"
      AuthUserFile /data/passwd
      AuthzSVNAccessFile /data/svn.access
      Require valid-user


 Set permission
chown -R apache.apache  /data/newsvnrepo/Zain

Now you should be able to browse the newly hosted svn repo on SANATH.

Follow the steps given below to accomplish the migration

> cd /data/git2svn
> git svn clone --username <New repo User>
> cd Zain
> git fetch /data/gitrepo/Zain
> git branch tmp $(cut -b -40 .git/FETCH_HEAD)
> git tag -a -m "Last fetch" last tmp
> INIT_COMMIT=$(git log tmp --pretty=format:%H | tail -1)
> git checkout $INIT_COMMIT .
> git commit -C $INIT_COMMIT
> git rebase master tmp
> git branch -M tmp master
> git svn dcommit

Now you are done.

Cheers with following page.

There are few pros & cons...
Revision numbers are totally different from original source & User history gone.
But worth to have diffs.

Appreciate your input on this...

(Wrote a script for handle many projects, will upload near future...)