planetmaker@openttd$ cat update-others.sh #!/bin/sh # Update both git and mercurial, by checking where the commit was, and updating those repos REV=$1 cd /var/repos/scripts changed=`./detect-branch-changed.sh $REV` for i in $changed; do ./safe-svn-to-others.sh "$i" done planetmaker@openttd$ cat safe-svn-to-others.sh #!/bin/sh flock --exclusive --nonblock svn-to-others.lock -c "./svn-to-others.sh \"$1\"" || touch svn-to-others.rerun planetmaker@openttd$ cat svn-to-others.sh #!/bin/sh if [ `whoami` = "root" ]; then echo "Please only execute this script under 'www-data' user" exit 1 fi rm -f svn-to-others.rerun umask 007 SVN_REPOS=file:///path/to/svn-repo # converted svn repositories CONVERT_DIR=/path/to/scripts/convert_storage HG_REPOS=/path/to/hg-repos GIT_REPOS=/path/to/git-repos HG=/usr/bin/hg GIT=/usr/bin/git process_only=$1 cd $CONVERT_DIR function convert { name=$1 dir=$2 repos_name=$3 if [ -n "$process_only" ] && [ "$dir$name" != "$process_only" ]; then return fi cd $CONVERT_DIR mkdir -p hg cd hg if [ -n "$dir" ]; then mkdir -p $dir cd $dir fi # Load HG from SVN, and GIT from HG $HG --encoding UTF8 convert --datesort --config convert.svn.branches= --config convert.svn.tags= --config convert.svn.trunk= $SVN_REPOS/$dir$name $repos_name.hg cd $repos_name.hg # Set description echo "[web] description=OpenTTD SVN - $dir$repos_name contact=OpenTTD allow_archive = bz2 gz zip allowpull = true style = gitweb " > .hg/hgrc # Set the 'last change' date of 'hgweb' correct date=`hg tip | grep date: | cut -b 14- | sed 's/ +0000//'` touch -d "$date" .hg/store/00changelog.i cd $CONVERT_DIR mkdir -p git cd git if [ -n "$dir" ]; then mkdir -p $dir cd $dir fi if [ ! -d "$repos_name.git" ]; then mkdir $repos_name.git cd $repos_name.git $GIT svn init --no-metadata $SVN_REPOS/$dir$name $GIT config core.sharedRepository group $GIT config gitweb.owner "OpenTTD" $GIT svn fetch --no-follow-parent $GIT update-ref refs/heads/master git-svn $GIT checkout -f master else cd $repos_name.git $GIT svn fetch $GIT reset -q --hard git-svn fi echo "OpenTTD SVN - $dir$repos_name" > .git/description cd .. # Link to our repos dirs if [ ! -d "$HG_REPOS/$dir$repos_name.hg" ]; then mkdir -p $HG_REPOS/$dir$repos_name.hg ln -s $CONVERT_DIR/hg/$dir$repos_name.hg/.hg $HG_REPOS/$dir$repos_name.hg/.hg fi if [ ! -L "$GIT_REPOS/$dir$repos_name.git" ]; then mkdir -p $GIT_REPOS/$repos_dir ln -s $CONVERT_DIR/git/$dir$repos_name.git/.git $GIT_REPOS/$dir$repos_name.git fi if [ "$dir$name" = "trunk" ]; then if [ ! -d "$CONVERT_DIR/github" ]; then cd $CONVERT_DIR/ $GIT clone $GIT_REPOS/trunk.git github cd github $GIT remote add github git@github.com:OpenTTD/OpenTTD.git fi cd $CONVERT_DIR/github $GIT pull origin $GIT push github master fi } convert "trunk" "" "trunk" for svndir in branches extra; do for i in `svn ls $SVN_REPOS/$svndir/ | cut -d/ -f1`; do convert "$i" "$svndir/" "$i" done done if [ -f "svn-to-others.rerun" ]; then sh $0 fi