Thursday, November 13, 2008

SVN - you amuse me....

After getting knee-deep in Git, I've struggled with questions about whether branching & merging with Git is truly better than SVN (well, we know it is because Mr. Torvalds' said so). My current project is something I had been planning on moving to Git. However, I didn't think since it's just me (a single developer) that the distributed qualities of Git would be enough to warrant the intellectual burden the next developer would have learning it. I had always planned on keeping a version of the codebase in SVN (via the bi-directional git-svn application). But a friend at OOPSLA swayed me to learn at just doing the branching & tagging with SVN.

I mean, I haven't experienced the pain of merging w/ SVN firsthand - so why not?

Here's one reason why: SVN has zero idea about branches.

A branch is a branch to you - but to SVN, it's just a copy operation.

How do you know when you branches off of the trunk (or another branch)? Well, you just look for the last copy operation! YUP!
$ svn log --verbose --stop-on-copy \
http://svn.example.com/repos/calc/branches/my-calc-branch

------------------------------------------------------------------------
r341 | user | 2002-11-03 15:27:56 -0600 (Thu, 07 Nov 2002) | 2 lines
Changed paths:
A /calc/branches/my-calc-branch (from /calc/trunk:340)

So - that's interesting. Yet, I can sort of accept it (though I feel like an idiot doing so). The kicker is this.... when you do a merge, "how do you know what you've merge?" Good question!

Say you have a long-life feature branch. You've done some development and merged the changes into the trunk (or mainline). Now, you're continuing to do development. How will you know where to merge from?

Interestingly enough, you don't know - unless you follow the branching/merging "best practice" of including your revision numbers for the branch when committing the merge (I'll let that sink in).

Now - I believe that you have full history with Git. So I need to go back now and see if that's true. But I believe you can even look at the merges with something like gitk and you can see the history. So there is no looking for the last copy operation or checking commit messages to see what revision to start merging from.

Oh - I am reading an older version of the SVN book (because we are using an old, out-of-date version of SVN). Perhaps there is a better way to do it now. But I just wanted to share my amusement.

source: http://svnbook.red-bean.com/en/1.2/svn-book.html#svn.branchmerge.commonuses.wholebr