This page is not available in 繁體中文, as a result the English (en_US) version is shown instead.
Website update

Finally did some web work this weekend. It's the first major update since around 2007 I think, and probably the first time I've had a separate landing page. One that will no doubt drive up the bounce rate :-)

by khc on Mon Mar 16 00:22:01 2009 Permlink
Tags: computer

What the hell?

(19:41:50) macondo_: khc: some contacts report that they receive my messages twice, and I didn't resend them

(19:42:35) khc: it's possible that your buddy already received the message but the switchboard connection died before we get an ACK

(19:42:56) macondo_: What the hell is this switchboard that can't work properly?

(19:43:20) darkrain42: heh, indeed

(19:43:26) khc: ya, what the hell indeed

by khc on Wed Feb 25 21:44:20 2009 Permlink
Tags: computer rant

Fetching svn branches with git-svn

Consider this a follow up of Tracking 2 branches in git-svn.

At work I've needed to pull other svn branches into my git-svn repository, and it happened often enough that I wrote a script to do it:

#!/bin/sh

CMD=$(basename $0)
SVNURL=svn://svn/mgmt

if [ $# != 2 ]; then
    echo "usage $CMD <svn branch> <rev spec>"
    exit 1
fi  

if [ ! -d .git ]; then
    echo "Not a git workspace"
    exit 1
fi  

BRANCH=$1
REV=$2
SVNURL="$SVNURL/$BRANCH"
SEP='------------------------------------------------------------------------'  

svn_find_rev()
{
    cut -f 1 '-d ' | sed -e 's/^r//'
}   

svn_find_first_rev()
{
    tail -n +2 | head -1 | svn_find_rev
}   

svn_find_last_rev()
{   
    SAWSEP=0
    LASTREV=
    while read line; do
        if [ $SAWSEP == 1 ]; then
            NEXTREV=$(echo $line | svn_find_rev)
            if [ "x$NEXTREV" != "x" ]; then
                LASTREV=$NEXTREV
            fi
            SAWSEP=0
        elif [ "$line" == "$SEP" ]; then
            SAWSEP=1
        fi
    done

    echo $LASTREV
}

if [ "$REV" = "HEAD" ]; then
    # let's find out the head revision
    REV=$(svn log -l 1 $SVNURL | svn_find_first_rev)
elif [ "$REV" = "PARENT" ]; then
    # find the first parent
    REV=$(svn log --stop-on-copy $SVNURL | svn_find_last_rev)
elif [ "$REV" = "ALL" ]; then
    # bad idea, not implemented
    false
fi

NREV=$(expr $REV + 0 2> /dev/null) # make sure we have a number
if [ "x$NREV" != "x" ]; then
    BRANCHPREFIX=$(basename $BRANCH | sed -e 's/_branch$//')
    if [ "$(fgrep "[svn-remote \"$BRANCHPREFIX\"]" .git/config)" != "" ]; then
        echo "$BRANCH is probably already in this git"
        exit 1
    fi

    echo "Registering $BRANCH with git"
    cat <<EOF >> .git/config
[svn-remote "$BRANCHPREFIX"]
        url = svn://svn/mgmt/$BRANCH
        fetch = :refs/remotes/git-$BRANCHPREFIX
EOF 

    echo "Fetching base revision $NREV"
    git svn fetch -R $BRANCHPREFIX -r $NREV || exit 1
    git branch --track $(basename $BRANCH) git-$BRANCHPREFIX || exit 1
    echo "Checking out $BRANCH"
    git checkout $(basename $BRANCH) || exit 1
    echo "Updating $BRANCH"
    git svn rebase || exit 1
    git gc --auto
else
    echo "Cannot resolve rev spec \`$REV'"
    exit 1
fi

It assumes that all your svn branches end with "_branch", which is the convention that we have at work. A quick look suggests that it should work even if that's not the case, but I've not tested it.

by khc on Wed Feb 18 00:07:34 2009 Permlink
Tags: computer

Back!

to reality...

(Before I forget, pictures are here.)

London was great. It was a bit cold, and the heaviest snowfall since 1991 didn't help. Good that it didn't start snowing until Sunday evening though, so I got most of my sightseeing stuff done. Mostly went to the touristy places in the city (Big Ben, London Eye, Tower Bridge, etc) and a couple museums (National Gallery Museum, Science Museum, British Museum). Also spent a disproportional amount of time on Trafalgar Square to people watch, and secretly hoping that someone will ask me to take a picture for them (so I can ask them to take a picture for me too!). Come to think of it, I probably also spent quite some time to wander around in Chinatown too.

I did learn a couple things about London while I was there. The snow pretty much made most public transportations useless. No buses on the road at all that day, and some train lines stopped. Many places closed down either because they anticipated few customers, or because their employees couldn't get to work. People say "cheers" a lot. Oh, and in Bonds movies people would say "after you" when they open doors for others, and it's quite funny to hear that in person, I guess because here people usually just say "go ahead" or say nothing at all.

Overall it was awesome, in an almost idealistic way. Partly because it's a work trip and I didn't spend all the time going around so it felt like real life instead of just a vacation. The fact that I lived this "real life" in a hotel and everything was paid for just made everything more enjoyable. Everyday I came back "home" everything was back to where it's supposed to be, bed was tidy and the room was clean. When we were hungry we just went on yelp to find the highest rated restaurant around the area to satisfy whatever we were craving for. Of course this is only possible because everything was paid for, as much as I try not to think about money in everyday life (I live with my parents so I have few expenses) it is a real factor. Oh and no one spoke around my ears at night or told me to do this do that... which unfortunately is one of the "reality" that I was referencing at the beginning of the post. Ah story for another time, maybe.

by khc on Tue Feb 17 23:49:24 2009 Permlink

London, UK from 1/26 - 2/5

I will be away for a week and a half. It's a work trip but I will be spending a weekend there as well, so expect some pictures. Email me your address if you want postcard!

by khc on Mon Jan 26 00:17:18 2009 Permlink
Older Posts