Branch management with SVK
Chia-liang KaoYAPC::EU 2008
Chia-liang Kao
高嘉良
CL
Best Practical
We Make RT
We Make SVK
We Make Prophet
Copenhagen is very special place for me
Back in 2000...
I came here andto the North
Copenhagen was my first stop
CPH.pm
Anywaysorted finally by
replacing the keyboard
Went to Lappland
Then I went to the Lappland
Inspired by...
Wrote a disconnectedBBS sync tool
That’s how I startedto want to be offline
And work offline
Then in 2003, I wrote SVK in...
Lofoten, Norway
Version Control:a fast recap
% date +%Y 1980
THE Version Control System
Backup
% cp -rf project project.1980-01-30
New feature
% cp -rf project project.newfeature
Revert
% cp ../project.0130/core.c .
Start from scratch
% rm -rf *
# oh no
% date +%Y 1982
RCS
% ci file% co file% rlog file
% rcsmerge -p -r2.8 -r3.4 file > merged
No Collaboration
% date +%Y 1992
CVS
CVS Problems
• non-atomic
• can’t manage directories
• can’t manage renames
• branching is expensive
• always requires network
cvs/src/server.c:
5878 goto i_hate_you; ... 5898 i_hate_you: 5899 printf ("I HATE YOU\n"); 5900 fflush (stdout);
% date +%Y 2002
Subversion
• Enterprise-standard for distributed development.
• Fixed CVS problems.
• Branch is easy.
Subversion Problems
• Centralised.
• No good merge support.
• somewhat improved in 1.5
No offline support
Then I went to the Lappland
If you are not a big fan of scenic places
The Internet
In March, 2007, pirates stole an 11-kilometre section of the T-V-H submarine cable that connected Thailand, Vietnam,
and Hong Kong, affecting Vietnam's Internet users with far slower speeds. The thieves attempted to sell the 100 tons
of illicit cargo as scrap.
And there can be...
Earthquakes
The 2006 Hengchun earthquake on December 26, 2006 rendered numerous cables near Taiwan inoperable.
The Subversion Motto
Network ! expensive
D!ks are cheap
We think
Network, D!ks, CPUs are cheap
Developers are expensive
SVK
• Works by mirroring your subversion repository (or others)
• you can choose to work offline or online
• svk cp http://your.server/svn/project
• svk push
• svk pull
% svk cp //mirror/project/trunk //mirror/project/branches/foo-refactor
% svk smerge //mirror/project/trunk //mirror/project/branches/foo-refactor
Now it’s even easier
Enter Branch Management
Available in SVK 2.2(beta1 on CPAN now)
Knowing where branches and tags are
for each project
% svk br --setup
% svk br --list
% svk br --create foo-refactor
% svk cp //mirror/project/trunk //mirror/project/branches/foo-refactor
% svk br --merge trunk foo-refactor
% svk br --create bar-refactor--switch
Two actions
% svk br --merge foo-refactor bar-fix trunk
Merging two branches
Feature-branch-based development
Now easy
Merge all branches under release-ready
% svk br --move foo-refactor release-ready/
% svk br --move bar-fix release-ready/
% svk br --create rc
% svk br --merge release-ready/* rc
Hand it off to the QA
Merge to trunk and release
% svk br --merge rc trunk
% svk br --remove release-ready/* rc
Feature-branch based development
• trunk always works
• trunk always releasable and can rollback
• Developers can focus on fixing one thing on one branch
Offline branches
% svk br --create cph-lhr --local --switch
% svk br --push
% svk br --online
% svk br --offline
Conflicts?
Conflicts were nightmares
>>> YOUR VERSION .... === ORIGINAL VERSION x .... === THEIR VERSION x .... <<< THEIR VERSION y
Even just whitespace changes!
conflicts are no longer nightmares
Interactive Conflict resolution
Conflict found on file foobar.c: (d)iff, (t)heirs, (y)ours, (m)erge, (e)dit, (s)kip ?
In svk:
Subversion now stole this from us :)
• irc.freenode.net #svk
Bonus
PushmiSubversion replication
When you have a distributed teams of
developers
The Solution
• Pushmi creates replicas of master repository in branch offices.
• Transparent to the users.
• NO change to existing infrastructure and process.
• Too good to be true?
Does Anyone see the obvious problem here?
FAQ: How do you handle simultaneous commits from different slaves and master?
We don't.
• The commits are relayed back to the master.
• It's essentially like users are committing directly, without going through replicas.
• And Subversion guards the transaction cleanness for us.
r5r10r11
r10
• Pushmi was released Aug 2007
• Available on http://code.bestpractical.com/
• Open source
• Deployed in wild
• 10+ offices around the world, 300+ repositores
• ... including Beijing, Saigon.
• Some with very limited internet connection.
• Large amount of graphical data.
• Users wait for "svn update" over slow and saturated network.
Case Study:A leading company in the game industry
Case Study (Cont.)
• Eliminated 200ms+ latency for read-only operations from places like Romania.
• Commit performance is only slightly slower.
• “The difference? It’s being able to work or not!”
What’s new?
Admin UI
Relayed locking support
Manual or auto divergenceand merge tool
Automatic failover for HA
Thank you!
http://lists.bestpractical.com/cgi-bin/mailman/listinfo/pushmi-users
http://code.bestpractical.com/project/Pushmi
Questions?