JavaEdge 2008: Your next version control system

56
1 Gilad Garon Your next Version Control System December 18th 2008

description

The next generation of VCS has a clear target ahead of them: making branching and merging easier. Until recently, Subversion was dominating the world of Version Control Systems, but now, Distributed Version Control Systems are growing in popularity and everywhere you go you hear about Git or Mercurial, and how they make branching and merging a breeze. But the Subversion team isn't going down quietly, they have a new weapon: the 1.5 version. Learn about the next generation of Version Control Systems is planning to solve your problems.

Transcript of JavaEdge 2008: Your next version control system

Page 1: JavaEdge 2008: Your next version control system

1

Gilad Garon

Your next

Version Control System

December 18th 2008

Page 2: JavaEdge 2008: Your next version control system

Agenda

• Introduction

• Branching

• Merging

• Subversion 1.5

• Distributed Version Control

2

Page 3: JavaEdge 2008: Your next version control system

Introduction

• What’s every VCS user worst nightmare?

• Nope. It’s…3

Page 4: JavaEdge 2008: Your next version control system

Agenda

• Introduction

• Branching

• Merging

• Subversion 1.5

• Distributed Version Control

4

Page 5: JavaEdge 2008: Your next version control system

Development Cycle

• Our repository layout should behave like our development cycle:

• Development Phase

• Testing Phase

• Release Final Product

• Our VCS should accommodate us and not the other way, no matter what’s our development process.

5

Page 6: JavaEdge 2008: Your next version control system

Single Development Line

• One branch holds all phases of the develop cycle.

6

Page 7: JavaEdge 2008: Your next version control system

Development Line with Support Line

7

Simple Denies ability to support production code

Stops development during testing phase

Pros Con

s

Page 8: JavaEdge 2008: Your next version control system

Development Line with Support Line

• One branch holds our development code.

• A second branch holds our production code for continued support.

8

Page 9: JavaEdge 2008: Your next version control system

Development Line with Support Line

9

Simple Stops development during testing phase

Allows support of production code

Bug fixing on production branch

Pros Con

s

Page 10: JavaEdge 2008: Your next version control system

Three Level Build

• A classic layout for a three phase development cycle.

• Release candidates are for the testing phase and support phase.

• The production branch is sterile.

10

Page 11: JavaEdge 2008: Your next version control system

Development Line with Support Line

11

Robust Complex projects can collide on development line

Continue developing while testing the next version

Merging

Pros Con

s

Page 12: JavaEdge 2008: Your next version control system

Multiple Feature Support Build #1

• Feature branches allow for even more code separation on complex projects

12

Page 13: JavaEdge 2008: Your next version control system

Multiple Feature Support Build #2

13

• Release Candidates can be closed when development cycle is complete

Page 14: JavaEdge 2008: Your next version control system

Development Line with Support Line

14

Robust Complex Merging

Supports large project

Pros Con

s

Page 15: JavaEdge 2008: Your next version control system

Branching is good for you

• Branches are great for code separation.

• Branches are cheap

• Branches are easy to create

So, what’s the catch?

15

Page 16: JavaEdge 2008: Your next version control system

Agenda

• Introduction

• Branching

• Merging

• Subversion 1.5

• Distributed Version Control

16

Page 17: JavaEdge 2008: Your next version control system

Merging

Seems Familiar?

Override everythin

g!

What the?!

17

Page 18: JavaEdge 2008: Your next version control system

Why merges are hard?

• Requires knowledge of the code

• Resolving conflicts by hand takes time

• Large projects require some planning

• Can cause logical bugs which aren’t easily detected

18

Page 19: JavaEdge 2008: Your next version control system

Making merges easier

• Merge daily!

• Let the VCS do the merge for you

• Don’t merge at the last minute, allocate merging time in your time table.

• Keep tabs on your code, keep notes on your changes.

19

Page 20: JavaEdge 2008: Your next version control system

Merge Tracking

• Merge tracking means that the VCS remembers what was merged and when.

• No more revision calculations

• Cherry Pick your changes

• See incoming changes

• Refactor code without fear

My Hero!

20

Page 21: JavaEdge 2008: Your next version control system

Common Myths

• Branching is easy?

• Merges are hard?

• Daily merges helps?

• Automatic merges are dangerous?

• Merging takes days of preparation?

21

Page 22: JavaEdge 2008: Your next version control system

Agenda

• Introduction

• Branching

• Merging

• Subversion 1.5

• Distributed Version Control

22

Page 23: JavaEdge 2008: Your next version control system

What’s New?

• Merge tracking

• Sparse checkouts

• Interactive conflict resolution

• Changelist support

• Speed improvements, cancellation response improvements

• Bug Fixes

23

Page 24: JavaEdge 2008: Your next version control system

Merge Tracking

• Create a branch

• Work on your branch

• Update your branch with trunk’s changes

svn copy http://yourserver.com/svn/project-x/trunk http://yourserver.com/svn/project-x/branches/feature-z -m "Creating a feature branch of /project-x/trunk."

svn checkout http://yourserver.com/svn/project-x/branches/feature-z… work …svn commit - m “committing my work."

svn merge http://yourserver.com/svn/project-x/trunk --- Merging r20 through r45 into '.': U GridView.java

24

Page 25: JavaEdge 2008: Your next version control system

Merge Tracking

• What has been merged so far?

• Which changes are available from trunk?

svn propget svn:mergeinfo . /trunk:20-45

# or

svn mergeinfo http://yourserver.com/svn/project-x/trunk r20r21…r44r45

svn mergeinfo http://yourserver.com/svn/project-x/trunk --show-revs eligible r46r47

25

Page 26: JavaEdge 2008: Your next version control system

Merge Tracking

Merging back your branch:

What’s the catch?

• No support for renames \ moves

• Mergeinfo is sometimes generated when no merge was done

$ cd /workspace/project-x/trunk$ svn merge --reintegrate http://yourserver.com/svn/project-x/branches/feature-z--- Merging differences between repository URLs into '.': … changes list …# build, test, verify, ... $ svn commit -m “Merging feature-z back into trunk!"

26

Page 27: JavaEdge 2008: Your next version control system

More New Features

• Sparse checkouts

• Interactive conflict resolution

• Changelist support

$ svn checkout URI --depth=[empty,files,immediates,infinity]# command support - checkout, switch, update, status, info

$ svn up U project-x/trunk/GridView.javaConflict discovered in 'project-x/trunk/GridView.java'.Select: (p) postpone, (df) diff-full, (e) edit, (s) show all options:

$ svn changelist bug-fix-1 GridView.javaPath 'GridView.java' is now a member of changelist 'bug-fix-1'.$ svn status --- Changelist ‘bug-fix-1': M GridView.java

27

Page 28: JavaEdge 2008: Your next version control system

Upgrading to Subversion 1.5 Server

1. Backup everything

2. Install Subversion 1.5 Server

3. Upgrade existing repositories with:

4. Populate indexes (Optional):

5. Upgrade clients

6. Pray to god 28

$ svnadmin upgrade REPOS_PATH

$ svn-populate-node-origins-index REPOS-PATH

Page 29: JavaEdge 2008: Your next version control system

TortoiseSVN 1.5

29

• TortoiseSVN is upgraded to support Subversion 1.5

• The Merge process is simplified and merge tracking is supported

• The repository now more resembles the Windows explorer

• Changelist support is supported

• Hook Scripts and Issue Trackers are supported

Page 30: JavaEdge 2008: Your next version control system

TortoiseSVN 1.5 Merge

30

Page 31: JavaEdge 2008: Your next version control system

New Feature Compatibility Table

New Feature Minimum

Client

Minimum Server

Minimum Repositor

y

Merge tracking 1.5 1.5 1.5

Sparse checkouts 1.5 any any

Interactive conflict resolution 1.5 any any

Changelist support 1.5 any any

Relative URLs, peg revisions in svn:externals 1.5 any any

Improvements to copy and move 1.5 any*, 1.5 any

Speed improvements, cancellation response improvements 1.5 any any

31

Page 32: JavaEdge 2008: Your next version control system

Agenda

• Introduction

• Branching

• Merging

• Subversion 1.5

• Distributed Version Control

32

Page 33: JavaEdge 2008: Your next version control system

What is DVCS?

• Distributed VCS does NOT mean the physical distribution of the repository over several machines.

• Distributed VCS means the repository is located on your machine.

33

Page 34: JavaEdge 2008: Your next version control system

Terminology

In DVCS we…

• Do not check out from the repository, we clone the repository.

• Do not update our working copy, we pull changes from other repositories.

• Do not check in our changes,we push changes to other repositories.

34

Page 35: JavaEdge 2008: Your next version control system

Advantages

You are the repository

• Performance, no network overhead.

• Work offline, work where ever you want.

• Experiment, no commit rights required.

• Local Commits, the repository is in your workspace.

• Flexible repository topology

35

Page 36: JavaEdge 2008: Your next version control system

Disadvantages

But…

• Sparse checkouts are not fully supported if at all.

• Most vendors do not support branching, you must clone.

• Merge Tracking needs to mature a bit.

• More suited to Open Source projects than commercial.

36

Page 37: JavaEdge 2008: Your next version control system

Centralized Workflow

37

Page 38: JavaEdge 2008: Your next version control system

Decentralized Workflow

38

Page 39: JavaEdge 2008: Your next version control system

Decentralized with shared mainlineWorkflow

39

Page 40: JavaEdge 2008: Your next version control system

Decentralized with GatekeeperWorkflow

40

Page 41: JavaEdge 2008: Your next version control system

Git

• Project started on April 2005

• Invented by Linus Torvalds to replace BitKeeper

• Toolkit design

• Used in - Linux Kernel, VLC, Ruby On Rails, Fedora, Android

• IDE Support - Eclipse, NetBeansIntelliJ (Native)

Subversion is the devil,

use Git.

41

Page 42: JavaEdge 2008: Your next version control system

Git Shell

42

Page 43: JavaEdge 2008: Your next version control system

Gitk

43

Page 44: JavaEdge 2008: Your next version control system

Git Pros & Cons

44

Fast Limited Windows Support

Gitk Over 150 Commands

Supports Branching The repository requires periodic optimization with git-gc

Pros Con

s

Page 45: JavaEdge 2008: Your next version control system

Bazaar

• Project started on March 2005

• Started as a branch of Arch

• Sponsored by Canonical (Ubuntu)

• Used in - Ubuntu, MySQL, Drupal, APT, Linux Foundation

• IDE Support - Eclipse, IntelliJ (Native)

45

Page 46: JavaEdge 2008: Your next version control system

Tortoise Bazaar

46

Page 47: JavaEdge 2008: Your next version control system

Bazaar Pros & Cons

47

Good support for workflows

Slower than Git and Mercurial

Good plug-ins Smallest user base

Version directories No NetBeans support

Shared Repositories

Pros Con

s

Page 48: JavaEdge 2008: Your next version control system

Mercurial

• Project started on April 2005

• Very Similar to Subversion

• Adopted by Sun Microsystems

• Used in - Mozilla, NetBeans, OpenJDK, OpenSolaris

• IDE Support - Eclipse, NetBeans,IntelliJ

48

Page 49: JavaEdge 2008: Your next version control system

Mercurial Serve

49

Page 50: JavaEdge 2008: Your next version control system

Tortoise Mercurial

50

Page 51: JavaEdge 2008: Your next version control system

Mercurial Pros & Cons

51

Very similar to Subversion

Slower than Git

TortoiseHG Does not version directories

Simple No local branches, must clone

HG Serve

Pros Con

s

Page 52: JavaEdge 2008: Your next version control system

Comparison

Rename Support Poor Yes Yes Yes

Merge Tracking Needs work Yes Yes Yes

Version Directories

Yes No No Yes

Partial Checkout Yes No No No

IDE Plugins IntelliJ, Eclipse, NetBeans

IntelliJ, Eclipse, NetBeans

IntelliJ, Eclipse, NetBeans

IntelliJ, Eclipse

Platforms Cross Platform Poor Windows Support

Cross Platform Cross Platform

UI Windows TortoiseSVN, VisualSVN

MIA TortoiseHG TortoiseBzr

UI Linux RapidSVN, KdeSVN, eSVN

gitk, git-gui TortoiseHG bzr-gtk, BzrLog

Documentation Good Good Good Good

52

Page 53: JavaEdge 2008: Your next version control system

Conclusion

And the Winner is?

• Experiment with the tools

• Choose the tool which works with your workflow

53

Page 54: JavaEdge 2008: Your next version control system

References

• Subversion

• Home Page: http://subversion.tigris.org/

• Tortoise: http://tortoisesvn.tigris.org/

• SVNKit: http://svnkit.com/

• Eclipse Plug-in: http://subclipse.tigris.org/

• NetBeans Plug-in: http://subversion.netbeans.org/

• Git

• Home Page: http://git.or.cz/

• msysgit (Git Windows) : http://code.google.com/p/msysgit/

• Eclipse Plug-in: http://git.or.cz/gitwiki/EclipsePlugin

• NetBeans Plug-in: http://code.google.com/p/nbgit/54

Page 55: JavaEdge 2008: Your next version control system

References

• Mercurial

• Home Page: http://www.selenic.com/mercurial/wiki/

• TortoiseHG: http://www.selenic.com/mercurial/wiki/index.cgi/TortoiseHg

• Eclipse Plug-in: http://www.vectrace.com/mercurialeclipse

• Bazaar

• Home Page: http://bazaar-vcs.org/

• IDE Plug-ins: http://bazaar-vcs.org/IDEIntegration

55

Page 56: JavaEdge 2008: Your next version control system

Thank You !

56