Thursday, October 25, 2012

Moving from svn to hg on Sourceforge

The following details steps one can take to change the version control system for their Sourceforge project from subversion to mercurial. The steps are mainly based on http://www.alteridem.net/2010/07/28/migrating-from-subversion-to-mercurial/  

Prerequisites
Tortoisesvn
TortoiseHg  

Versions used
Tortoisesvn 1.7.1
TortoiseHg 2.5.1

Steps
  • Create a directory to hold a local copy of your svn repository e.g. c:\svnrepo Create the local svn repository in the newly created directory e.g
svnadmin create c:\svnrepo
  • This process will create a number of directories and files in the c:\svnrepo directory
  • Create an empty file named pre-revprop-change.bat in the c:\svnrepo\hooks directory
  • Initialize the local svn repository for syncing with the remote repository e.g.
svnsync init file:///c:/svnrepo http://svn.code.sf.net/p/myproject/code
  • Sync the repositories
svnsync sync file:///c:/svnrepo
  • This will copy/download files from the remote repository to the local one so it may take some time and bandwidth depending on the size of the remote repository
  • Make some configurations to TortoiseHg. Open windows explorer, right click on any directory and select the TortoiseHg > Global Settings menu. Select Commit in the left hand pane and enter a username. The conventional format is firstname lastname <email>. Select the Extensions option on the left hand pane and tick the convert extension. Click on OK to save these settings 
  • Create a directory to hold a local copy of your hg repository e.g. c:\hgrepo 
  • Create the local hg repository in the newly created directory e.g
hg init c:\hgrepo
  • Convert the local svn repo to hg, putting the results in the local hg repository
hg convert c:/svnrepo c:/hgrepo
  • Push your local hg repository to the remote hg repository
cd c:\hgrepo
hg push ssh://myusername@hg.code.sf.net/p/myproject/mymountpoint
  • This will upload the project files to the remote repository and may take a considerable amount of time depending on the size of the repository and upload speeds.

Java: Split string by newline

String lines[] = currentValue.split("\\r?\\n");