welcome to the brave new world of git-svn

Date Tags git / svn

I’m definitely fed up with the lack of feature of svn. I always end up making backup copies of files, committing the wrong patch set, being unable to cherry-pick what to commit, not to talk about branching, merging and other marry activities. So today I overcome my laziness and setup a git svn repository for dose3 (since it’s all there, go ahead, and be happy!).

The concept of git svn if pretty easy. You work with git, and from time to time, you commit in svn. Best of both worlds, and ppl won’t even notice that you are not using their pet SCM, apart for the happy look of your face :)

First let’s clone the svn repo :

git svn clone https://gforge.info.ucl.ac.be/svn/mancoosi/trunk/dose3

This will probably hangup if you have big files in the svn repo. I don’t think it’s a problem with svn itself, but more likely a problem with the forge at ucl.ac.be. Anyway, if this happen, just go in the dose3 directory and finish it up with a git svn fetch

Now it’s time to sync all you changes and test from your old svn tree. I choose to rsync everything away :

rsync -avz --exclude=.svn --exclude=_build ../mancoosi-public/trunk/dose3/ .

of course we want to exclude all the compilation leftovers and .svn directories …

Ahhhhhhh freedom. Now I can edit, stash away changes, commit, uncommit, rebase, cherry-pick… I feel home.

At the end of the day we have to check if somebody updated the svn repo with git svn rebase, maybe resolve a couple of conflicts and then I can commit all my work with git svn dcommit.

I’ve been working with git svn only for a couple of days now, but I feel it pretty stable and trustworthy.


sharing a svn repo

Date Tags svn

Recently I had few problems with a svn repository that is shared between multiple ssh users. I followed the instructions in the svn book and to solve the problem once for all I recreated the repo from scratch. Briefly:

svnadmin dump SVN > /tmp/dump
mv SVN SVN-old
svnadmin create SVN
chmod -R g+rw SVN
find SVN -type d -exec chmod g+s {} \;
chown -R root.cvs SVN
 svnadmin load SVN < /tmp/dump

hopefully this is gonna work. hopefully, otherwise I guess I missing something that is very basic !


svn db/current problem

Date Tags svn

A while ago one of my svn repositories became all the sudden inaccessible. It turned out that the file db/current got corrupted for some reason, leaving the repo in an inconsistent state. The file db/current in a svn repository (using the FSFS backend) contains the largest revision number and the next unique node and copy ids. Googling around I found this old message [1] explaining the problem, but not providing any satisfactory solution.

My first attempt was to dump the db using svnadmin and then load it back. This didn’t fix the problem. Then I tried again with svnadmin recover, to not aval.

This morning I found the solution. svnadmin recover is actually able to restore the db/current file, but only from svn version 1.5 (I was using ver 1.4). So after an update (thanks backports!) I successfully managed to recover the repo. This blog post [2] is definitely informative.

[1] http://svn.haxx.se/users/archive-2005-11/0435.shtml [2] http://www.farside.org.uk/200703/svnadmin_recover


SVN Snapshots script

Date Tags bash / svn

This is a small script to generate code snapshots from the svn repository.

#!/bin/bash
#
# MakeSvnSnapshot.sh
# Purpose: To make easily downloadable (clean) versions of a snapshot of code.
# Intended Use: Called as a daily/weekly/etc cron job
#
# Author: Colin Ross <cross@php.net>
# Modified Pietro Abate <pietro.abate@pps.jussieu.fr>
#
# License:
# This work is licensed under the
# Creative Commons Attribution-Share Alike 2.5 License.
# To view a copy of this license,
# visit http://creativecommons.org/licenses/by-sa/2.5/
# or send a letter to
# Creative Commons
# 543 Howard Street
# 5th Floor
# San Francisco, California, 94105, USA.
#
#

# Ex: MakeSnapshot.sh /tmp http://svn.cduce.org/cduce/trunk
: ${1?"Usage: $0 snapshot-dir svn-url"}

# Creates an up-to-date tgz of the latest svn snapshot
SNAP_DIR=$1
SVN_URI=$2
CUR_DATE=`date +%Y%m%d`

cd $SNAP_DIR

if [ -f .svn-snapshot-log ]; then
  rm .svn-snapshot-log
fi

#if this isn't a working copy
if [ ! -d .src/.svn ]; then
  svn co $SVN_URI .src >> .svn-snapshot-log # check it out
fi
svn cleanup .src

# just update the working copy
svn up .src >> .svn-snapshot-log
# and get the current revision
REV=`svn info .src | grep Revision | cut -f2 -d " "`

# if the REV has changed...
if [ ! -d cduce-svn-$REV ]; then
  #export it to get rid of .svn files
  svn export .src cduce-svn-$REV >> .svn-snapshot-log
  # tgz it up
  tar cvf - cduce-svn-$REV  | gzip > cduce-svn-$REV-$CUR_DATE.tar.gz

  #keep only the latest 10 snapshots
  n=`ls cduce-svn-*.tar.gz| wc -l`
  if [ $n -gt 10 ]; then
      find -ctime +10 -name "*.tgz" -exec mv {} /tmp \;
  fi

  # update the current symlink
  if [ -f cduce-svn-current.tar.gz ]
   then
     rm -f cduce-svn-current.tar.gz
  fi
  ln -s cduce-svn-$REV-$CUR_DATE.tar.gz cduce-svn-current.tar.gz
fi

cd -