svk br yapceu2008

110
Branch management with SVK Chia-liang Kao YAPC::EU 2008

Upload: clkao

Post on 06-May-2015

708 views

Category:

Documents


5 download

TRANSCRIPT

Page 1: Svk Br Yapceu2008

Branch management with SVK

Chia-liang KaoYAPC::EU 2008

Page 2: Svk Br Yapceu2008

Chia-liang Kao

Page 3: Svk Br Yapceu2008

高嘉良

Page 4: Svk Br Yapceu2008

CL

Page 5: Svk Br Yapceu2008

Best Practical

Page 6: Svk Br Yapceu2008

We Make RT

Page 7: Svk Br Yapceu2008

We Make SVK

Page 8: Svk Br Yapceu2008

We Make Prophet

Page 9: Svk Br Yapceu2008

Copenhagen is very special place for me

Page 10: Svk Br Yapceu2008

Back in 2000...

Page 11: Svk Br Yapceu2008

I came here andto the North

Page 12: Svk Br Yapceu2008

Copenhagen was my first stop

Page 13: Svk Br Yapceu2008

CPH.pm

Page 14: Svk Br Yapceu2008
Page 15: Svk Br Yapceu2008
Page 16: Svk Br Yapceu2008
Page 17: Svk Br Yapceu2008

Anywaysorted finally by

replacing the keyboard

Page 18: Svk Br Yapceu2008

Went to Lappland

Page 19: Svk Br Yapceu2008

Then I went to the Lappland

Page 20: Svk Br Yapceu2008

Inspired by...

Page 21: Svk Br Yapceu2008
Page 22: Svk Br Yapceu2008

Wrote a disconnectedBBS sync tool

Page 23: Svk Br Yapceu2008

That’s how I startedto want to be offline

Page 24: Svk Br Yapceu2008

And work offline

Page 25: Svk Br Yapceu2008

Then in 2003, I wrote SVK in...

Page 26: Svk Br Yapceu2008

Lofoten, Norway

Page 27: Svk Br Yapceu2008

Version Control:a fast recap

Page 28: Svk Br Yapceu2008

% date +%Y 1980

Page 29: Svk Br Yapceu2008

THE Version Control System

Page 30: Svk Br Yapceu2008

Backup

% cp -rf project project.1980-01-30

Page 31: Svk Br Yapceu2008

New feature

% cp -rf project project.newfeature

Page 32: Svk Br Yapceu2008

Revert

% cp ../project.0130/core.c .

Page 33: Svk Br Yapceu2008

Start from scratch

% rm -rf *

# oh no

Page 34: Svk Br Yapceu2008

% date +%Y 1982

Page 35: Svk Br Yapceu2008

RCS

Page 36: Svk Br Yapceu2008

% ci file% co file% rlog file

Page 37: Svk Br Yapceu2008

% rcsmerge -p -r2.8 -r3.4 file > merged

Page 38: Svk Br Yapceu2008

No Collaboration

Page 39: Svk Br Yapceu2008

% date +%Y 1992

Page 40: Svk Br Yapceu2008

CVS

Page 41: Svk Br Yapceu2008
Page 42: Svk Br Yapceu2008

CVS Problems

• non-atomic

• can’t manage directories

• can’t manage renames

• branching is expensive

• always requires network

Page 43: Svk Br Yapceu2008

cvs/src/server.c:

5878 goto i_hate_you; ... 5898 i_hate_you: 5899 printf ("I HATE YOU\n"); 5900 fflush (stdout);

Page 44: Svk Br Yapceu2008

% date +%Y 2002

Page 45: Svk Br Yapceu2008

Subversion

• Enterprise-standard for distributed development.

• Fixed CVS problems.

• Branch is easy.

Page 46: Svk Br Yapceu2008

Subversion Problems

• Centralised.

• No good merge support.

• somewhat improved in 1.5

Page 47: Svk Br Yapceu2008

No offline support

Page 48: Svk Br Yapceu2008

Then I went to the Lappland

Page 49: Svk Br Yapceu2008

If you are not a big fan of scenic places

Page 50: Svk Br Yapceu2008

The Internet

Page 51: Svk Br Yapceu2008
Page 52: Svk Br Yapceu2008
Page 53: Svk Br Yapceu2008
Page 54: Svk Br Yapceu2008

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.

Page 55: Svk Br Yapceu2008

And there can be...

Page 56: Svk Br Yapceu2008

Earthquakes

Page 57: Svk Br Yapceu2008

The 2006 Hengchun earthquake on December 26, 2006 rendered numerous cables near Taiwan inoperable.

Page 58: Svk Br Yapceu2008

The Subversion Motto

Network ! expensive

D!ks are cheap

Page 59: Svk Br Yapceu2008

We think

Network, D!ks, CPUs are cheap

Developers are expensive

Page 60: Svk Br Yapceu2008

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

Page 61: Svk Br Yapceu2008
Page 62: Svk Br Yapceu2008

% svk cp //mirror/project/trunk //mirror/project/branches/foo-refactor

% svk smerge //mirror/project/trunk //mirror/project/branches/foo-refactor

Page 63: Svk Br Yapceu2008

Now it’s even easier

Page 64: Svk Br Yapceu2008

Enter Branch Management

Page 65: Svk Br Yapceu2008

Available in SVK 2.2(beta1 on CPAN now)

Page 66: Svk Br Yapceu2008

Knowing where branches and tags are

for each project

Page 67: Svk Br Yapceu2008

% svk br --setup

Page 68: Svk Br Yapceu2008

% svk br --list

Page 69: Svk Br Yapceu2008

% svk br --create foo-refactor

% svk cp //mirror/project/trunk //mirror/project/branches/foo-refactor

Page 70: Svk Br Yapceu2008

% svk br --merge trunk foo-refactor

Page 71: Svk Br Yapceu2008

% svk br --create bar-refactor--switch

Two actions

Page 72: Svk Br Yapceu2008

% svk br --merge foo-refactor bar-fix trunk

Merging two branches

Page 73: Svk Br Yapceu2008

Feature-branch-based development

Page 74: Svk Br Yapceu2008

Now easy

Page 75: Svk Br Yapceu2008
Page 76: Svk Br Yapceu2008

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

Page 77: Svk Br Yapceu2008

Hand it off to the QA

Page 78: Svk Br Yapceu2008

Merge to trunk and release

% svk br --merge rc trunk

% svk br --remove release-ready/* rc

Page 79: Svk Br Yapceu2008

Feature-branch based development

• trunk always works

• trunk always releasable and can rollback

• Developers can focus on fixing one thing on one branch

Page 80: Svk Br Yapceu2008
Page 81: Svk Br Yapceu2008

Offline branches

% svk br --create cph-lhr --local --switch

% svk br --push

% svk br --online

% svk br --offline

Page 82: Svk Br Yapceu2008

Conflicts?

Page 83: Svk Br Yapceu2008

Conflicts were nightmares

Page 84: Svk Br Yapceu2008

>>> YOUR VERSION .... === ORIGINAL VERSION x .... === THEIR VERSION x .... <<< THEIR VERSION y

Page 85: Svk Br Yapceu2008

Even just whitespace changes!

Page 86: Svk Br Yapceu2008

conflicts are no longer nightmares

Page 87: Svk Br Yapceu2008

Interactive Conflict resolution

Page 88: Svk Br Yapceu2008

Conflict found on file foobar.c: (d)iff, (t)heirs, (y)ours, (m)erge, (e)dit, (s)kip ?

In svk:

Page 89: Svk Br Yapceu2008

Subversion now stole this from us :)

Page 91: Svk Br Yapceu2008
Page 92: Svk Br Yapceu2008

Bonus

Page 93: Svk Br Yapceu2008

PushmiSubversion replication

Page 94: Svk Br Yapceu2008

When you have a distributed teams of

developers

Page 95: Svk Br Yapceu2008

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?

Page 96: Svk Br Yapceu2008

Does Anyone see the obvious problem here?

Page 97: Svk Br Yapceu2008

FAQ: How do you handle simultaneous commits from different slaves and master?

Page 98: Svk Br Yapceu2008

We don't.

Page 99: Svk Br Yapceu2008

• 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.

Page 100: Svk Br Yapceu2008

r5r10r11

r10

Page 101: Svk Br Yapceu2008

• Pushmi was released Aug 2007

• Available on http://code.bestpractical.com/

• Open source

• Deployed in wild

Page 102: Svk Br Yapceu2008

• 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

Page 103: Svk Br Yapceu2008

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!”

Page 104: Svk Br Yapceu2008

What’s new?

Page 105: Svk Br Yapceu2008

Admin UI

Page 106: Svk Br Yapceu2008

Relayed locking support

Page 107: Svk Br Yapceu2008

Manual or auto divergenceand merge tool

Page 108: Svk Br Yapceu2008

Automatic failover for HA

Page 110: Svk Br Yapceu2008

Questions?