42
Subversion Day Using Subversion and Git Together June 14 th 2012, Berlin

Using Subversion and Git Together

Embed Size (px)

DESCRIPTION

SubGit is a server-side tool that helps to accomplish Svn to Git migration or Svn/Git synchronization task. This talk describes SubGit pros and cons and compares SubGit with its client-side Git-Svn alternative.

Citation preview

Page 1: Using Subversion and Git Together

Subversion DayUsing Subversion and Git Together

June 14th 2012, Berlin

Page 2: Using Subversion and Git Together

About Us

● TMate Software● We create VCS tools since year 2003● Products at pre-release stage

● SubGit (RC, self-hosting for 6 months)● HG4J (Beta)

● Our mature products:● SvnKit (1.7.4, 30% of the ASF requests)● SqlJet (1.1.2)

Page 3: Using Subversion and Git Together

Subversion and Git

● Subversion: ● Mature, well known and widely used● Centralized● Manager-friendly

● Git: ● Fast growing VCS● Distributed● Geek-friendly

Page 4: Using Subversion and Git Together

server

Subversion and Git

● Single repository at shared centralized server

● All branches and forks are in the same repository

● Many repositories

● Forks

● Delayed commits

Page 5: Using Subversion and Git Together

Subversion and Git

How is it possible to use both?!

Page 6: Using Subversion and Git Together

Two Approaches

Git-Svn or SubGit

Page 7: Using Subversion and Git Together

Git-Svn Approachoverview

server server

Page 8: Using Subversion and Git Together

Git-Svn Approachclient-side, partisan deployment

server

User 1 User 2

Page 9: Using Subversion and Git Together

Git-Svn Approachdouble translation, resulting in data loss

server

User 1 User 2

1. push: Git to Svn

2. pull: Svn to Git

Page 10: Using Subversion and Git Together

Git-Svn Approachcustom non-Git workflow

server

User 1

Git-Svn commands:

● fetch● dcommit● rebase● branch...

Page 11: Using Subversion and Git Together

Git-Svn Approachcustom non-Git workflow

- local commit

- remote commit

Standard Git push:

local state git pull, merge commit created

git push, new commits pushed

Page 12: Using Subversion and Git Together

Git-Svn Approachcustom non-Git workflow

Git-Svn dcommit:

local state git svn dcommit, requires rebase first

git svn dcommit, (commit)

git svn dcommit, (fetchback, sign)

Page 13: Using Subversion and Git Together

Git-Svn Approachsummary

● Client side● Each user needs to translate at least part of

the repository● Non-standard workflow● Part of standard Git package, but...● …git-svn is 5000 lines script of perl code

Page 14: Using Subversion and Git Together

SubGitoverview

server

subgit

Page 15: Using Subversion and Git Together

SubGitapproach details

● Installed into repository● Uses hooks● Translation is performed in the background

to minimize overhead

Page 16: Using Subversion and Git Together

SubGitdefault installation

svn pre-commit hook

git pre-receive hook

git post-receive hook

SubGit translation daemon

Git

Subversion

Server

Page 17: Using Subversion and Git Together

SubGitApache configuration example

<Location /svn> # http://repos.host.com/svn/project DAV Svn SVNParentPath /var/svn/repos

Require valid-user AuthType Basic AuthUserFile /var/svn/repos/passwords</Location>

<Location /git> # http://repos.host.com/git/project ScriptAlias /git/ … … Require valid-user AuthType Basic AuthUserFile /var/svn/repos/passwords</Location>

Page 18: Using Subversion and Git Together

SubGitasynchronous translation

svn subgit

pre-commit

post-commit

data transfer

translation scheduled

revision added to SubGit translation queue

revision installed

git

git commit created

Page 19: Using Subversion and Git Together

SubGitasynchronous translation

svnsubgit

pre-receive

post-receive

data transfer

translation scheduled

commit(s) added to SubGit translation queue

references updated

git

svn revision created

Page 20: Using Subversion and Git Together

SubGitasynchronous translation

subgitgit svn

Page 21: Using Subversion and Git Together

SubGitsummary

● Server side● One-time centralized deployment● Reuse of existing infrastructure● Pure Git/Subversion experience● Safe and smooth migration● Commercial quality tool

Page 22: Using Subversion and Git Together

SubGitsafe migration

subgit

Page 23: Using Subversion and Git Together

SubGitsmooth migration

VCS transparency

t“Clean cut”migration

Git adoption

VCS transparency

tSubGit smoothmigration

Page 24: Using Subversion and Git Together

Subversion<=>Git Translation

● Branches and Tags● Deltas● Special properties● Merge tracking info

● References● Trees● Special files● Commit parents

Page 25: Using Subversion and Git Together

Branches and Tagsoverview

/trunk

/branches/branches/1.0.x/branches/1.1.x

/tags/tags/1.0.0

--- r10M /branches/1.0.x/file.txt

master 1.1.x 1.0.x

1.0.0

Page 26: Using Subversion and Git Together

Branches and Tagsmapping

trunk = trunk:refs/heads/masterbranches = branches/*:refs/heads/*tags = tags/*:refs/tags/*

shelves = shelves/*:refs/shelves/*

Page 27: Using Subversion and Git Together

Branches and Tags

master

Which history line is a trunk?

And which is a branch?

Heuristics help!

Page 28: Using Subversion and Git Together

Branches and Tagsshelves

master

Unnamed Git branch

/shelves/author[_date]

--- r20M /shelves/alex/file.txt

Page 29: Using Subversion and Git Together

Branches and Tagsattic references

master branch master master

attic/branch

Page 30: Using Subversion and Git Together

Braches and Tags

● From Subversion to Git● Single Subversion revision might be

translated to multiple Git commits● From Git to Subversion

● Heuristics help to detect target branch in complex cases

● /shelves directory is used to store anonymous branches

Page 31: Using Subversion and Git Together

Deltas and Trees

● Subversion revision is a delta:--- r20

A /trunk/file.txt

M /trunk/dir/file.txt

A /trunk/dir/copy.txt

from /trunk/file.txt@r10

D /trunk/dir/old_file.txt

● Delta tracks copies● Git commit is always a full file tree

Page 32: Using Subversion and Git Together

Deltas and Trees

● From Subversion to Git● Relevant part of the delta is applied

to the parent commit tree

● From Git to Subversion● Renames and copies are detected at

translation time● Branches and tags creation uses

copy operation

Page 33: Using Subversion and Git Together

Special Properties

● properties:● svn:ignore

● svn:eol-style● svn:mime-type

● files:● .gitignore

● .gitattributes

file.txt svn:eol-style=native

.gitattributes * text=auto !eol

Page 34: Using Subversion and Git Together

Special Properties

● From Subversion to Git● svn:ignore; svn:mime-type and

svn:eol-style are translated● From Git to Subversion

● .gitignore and relevant values set in .gitattributes are translated

Page 35: Using Subversion and Git Together

Merge TrackingGit merge commits:

In Git merges are tracked by:

● Natural history

● Merge commits parents

● Merge unit is commit

Page 36: Using Subversion and Git Together

Merge Tracking

● Subversion tracks merges by● Natural history● Revisions ranges (including cherry-picks)

● Merge unit is file or a directory

/trunk@r100svn:mergeinfo=/branches/1.0.x:1-100,105

/trunk/file.txt@r100svn:mergeinfo=/branches/1.0.x/file.txt:102

Page 37: Using Subversion and Git Together

Merge Tracking

● From Subversion to Git● Branch-level merges are translated

to merge commits

● From Git to Subversion● Merge commits are represented with

svn:mergeinfo

Page 38: Using Subversion and Git Together

Not Yet Translated(in SubGit 1.0)

● Empty directories● Arbitrary properties● Revision properties● Externals references

Page 39: Using Subversion and Git Together

It Works!

$ svnadmin create repos

....

$ subgit install repos

$ git clone repos git-clone

....

$ svn co svn://host/repos wc

....

Page 40: Using Subversion and Git Together

SubGit Target Audience

● Managers who listen to their Geeks● Hosting providers● Safe and smooth migration

● Java 1.5 or newer is needed● Linux, OS X, Windows Server 2003

Page 41: Using Subversion and Git Together

On SubGit Availabilty

● SubGit 1.0 release: June 2012● SubGit is free for Open Source

and Start-Up Projects● Closed-source projects will have to register

SubGit (purchase a registration key)

● Dedicated technical support for SubGit

Page 42: Using Subversion and Git Together

Thank you!

● SubGit on Web: http://subgit.com/● SubGit on Twitter: @subgit● Page on Google+ (SubGit)● Blog: http://blog.subgit.com/

● Using Gerrit with Subversion

● Thank you! :)