YJ Park's profileYJParkPhotosBlogListsMore Tools Help

Blog


    12/11/2006

    Backup svn local modifications

    When we are working on a task, our local modifications are not in repository yet, so it's not safe, I don't want to make branch just for backup, so I wrote a script to backup local modifications, here is the script:

    backuptask

    #!/bin/bash

    if [ -f TASK ] ; then
        echo
    else
        echo There is not TASK file here, you must specify the task name in TASK
        exit -1
    fi

    export task=`cat TASK`
    echo Backup Task: $task

    # Create task dir if needed
    if [ -d ~/tasks/$task ] ; then
        echo
    else
        mkdir ~/tasks/$task
    fi

    svn info > svn.info

    datestr=`date "+%Y-%m-%d_%H_%M"`
    filename=${task}_${datestr}.tar
    list=`svn status`
    for line in $list; do
        if [ -f $line ]; then
            tar uvf $filename $line
        fi
    done

    gzip $filename
    filename=$filename.gz

    scp $filename yjpark@exobox:~/backup/tasks/
    cp $filename ~/tasks/$task/
    mv $filename ~/tasks/$task/current.tar.gz

    You need to have a file named as 'TASK' in your working directory, it has only one line with the task's name, I put my backups in '~/tasks/' , you can change it if you want, and I scp the backup file to yjpark@exobox, you need to change the user and host name.

    Use kompare for svn diff and code reviews

    Before commit, we need to read the diff, that is done by svn diff, while the result is not easy to read, using kompare, the diff is much easier to read, here is the script I use for this

    svndiff
    if [ $2 ] ; then
        svn diff --diff-cmd=diff -x "-u10000" -r$1:$2 | kompare -
    else
        svn diff | kompare -
    fi

    If provided two parameters, this command will show svn diff of two revisions, with 10000 lines context(I just want to see the whole file if there is diff, this is useful for doing code reviews), pipeline the output to kompare; otherwise, It will just use kompare to show the output of svn diff,