# taken from: # http://mercurial.selenic.com/wiki/SubversionToMercurialSync # # Usage: # svn co http://svn.my-project.com my-project-readonly # svn2hg_up my-project-readonly # hg clone my-project-readonly my-project # # To update from svn # svn2hg_up my-project-readonly # cd my-project; hg pull ../my-project-readonly # # Updates a mercurial tree from corresponding patches in a subversion # repository. Currently this is used to keep a read-only local mercurial # tree in sync with the global Python repository. # Set up... cd $1 export LANG="C" export LC_ALL="C" # Make some globals for easier maintenance. svncurrev=.svn2hg_currev svncurlog=.svn2hg_curlog # Set up mercurial. test -d .hg || hg init echo -e ".svn\n$svncurrev\n$svncurlog" > .hgignore # Get current revisions... new_rev=`svn up | tail -n1 | egrep -o "[0-9]+"` test -f $svncurrev && cur_rev=`cat $svncurrev` || cur_rev="" # Check whether we actually have a new revision at the moment... if [ R${new_rev}R != R${cur_rev}R ] then echo "Updated repository from svn: $cur_rev -> $new_rev" > $svncurlog if [ R${cur_rev}R = RR ] then cur_rev=$new_rev else cur_rev=`expr $cur_rev + 1` fi svn log -v -r $new_rev:$cur_rev >> $svncurlog echo $new_rev > $svncurrev hg commit -A -l $svncurlog > /dev/null 2>&1 fi