#!/bin/bash ### Usage usage() { echo "Usage: `basename $0` [-u userName] [-e UserEmail] [-l userLogin] [-m svnLocation] [-r fromRevision] [-s] [-g gitname=cgal.git] [-v] [-h]" >&2 echo >&2 echo " -r gives revision to start from. Other options than a number: LAST, BASE" >&2 echo " -s skip fetch" >&2 echo " -v the version" >&2 echo " -h this info screen" >&2 echo >&2 } ### Config userName="Eric Berberich" userEmail=eric@mpi-inf.mpg.de userLogin=eric svnGforge=svn+ssh://$userLogin@scm.gforge.inria.fr/svn/cgal fromSvn=file://$HOME/CGAL/gforge/cgal-m #fromSvn=$svnGforge fromRev=63050 gitName=cgal.git skipFetch=0 # parse command line arguments while getopts u:e:l:r:m:g:sh OPT; do case "$OPT" in u) userName=$OPTARG ;; e) userEmail=$OPTARG ;; l) userLogin=$OPTARG ;; m) fromSvn=$OPTARG ;; r) fromRev=$OPTARG ;; s) skipFetch=1 ;; r) gitName=$OPTARG ;; h) usage exit 0 ;; v) echo "`basename $0` version 0.1" exit 0 ;; \?) # getopts issues an error message usage exit 1 ;; esac done #shift `expr $OPTIND - 1` ### Create repo echo "Create new directory $gitname" rm -fr $gitName mkdir $gitName cd $gitName echo # rewrite root rewriteRoot=--rewrite-root=$svnGforge rewriteRoot= # options to speedup # TODO internal-releases only >= 3.7 internalReleasesTags="--tags tags/internal-releases" internalReleasesTags= debianTags="--tags tags/debian" debianTags= CMD="git svn init $fromSvn $rewriteRoot --trunk branches/next --branches branches/features --branches branches/releases --tags tags/releases $internalReleasesTags $debianTags" echo "Init repository: $CMD" $CMD echo ### Modify repo/.git/config # rename remotes -> remotes/svn CMD="sed -e s|remotes|remotes/svn| < .git/config > .git/config.altered" echo "Rename 'remotes' to 'remotes/svn' in $gitName/.git/config: $CMD" sed -e 's|remotes|remotes/svn|' -e 's|svn/trunk|svn/next|' < .git/config > .git/config.altered echo # add 'stable' branch #CMD= echo "Add 'stable' branch to $gitName/.git/config" echo ' fetch = trunk:refs/remotes/svn/stable' >> .git/config.altered # TODO git branch --track release git-svn-release-branch? #$CMD echo CMD="mv -f .git/config.altered .git/config" #echo "Activate new config: $CMD" $CMD #echo # add author CMD="git config user.name \"$userName\"; git config user.email \"$userEmail\"" echo "Add author to $gitName/.git/config: $CMD" pwd #$CMD git config user.name "$userName" git config user.email "$userEmail" echo echo "Using config $gitName/.git/config:" cat .git/config ### Fetch if [ $skipFetch = 0 ]; then ### Authors file echo "Get authors file with svn" svn cat $fromSvn/branches/next/Maintenance/git/authors-file.txt > /tmp/cgal-authors-file.txt echo # fetch from svn server echo "Fetch from SVN repository: git svn fetch -r$fromRev:HEAD " if [ "$fromRev" = "LAST" ]; then # last revision on next fromRev=$(svn info $fromSvn/branches/next | grep "Last Changed Rev: " | tr -d 'Last Changed Rev: ') echo "Last Revision: $fromRev" fi git svn fetch --authors-file=/tmp/cgal-authors-file.txt -r$fromRev:HEAD # TODO fetch each branch from its creation-revision only echo rm -f /tmp/cgal-authors-files.txt ### Branch names # rename master next echo "Rename main branch to local/next" git branch -m master local/next fi # What about? ## git config svn-remote.svn.url $svncgal (or $svncgal/trunk if you are doing trunk only) ### http://translate.org.za/blogs/wynand/en/content/changing-your-svn-repository-address-git-svn-setup ## unhandled.log (which lists all svn properties, such as svn:eol, that has not been converted).