comparing apples to oranges subversion, git, and mercurial · comparing apples to oranges...
TRANSCRIPT
![Page 1: Comparing Apples to Oranges Subversion, Git, and Mercurial · Comparing Apples to Oranges –Subversion, Git, and Mercurial - - ©elego Software Solutions GmbH1 Comparing Apples to](https://reader034.vdocuments.mx/reader034/viewer/2022043010/5fa139da9e3281513d0ad3b2/html5/thumbnails/1.jpg)
1Comparing Apples to Oranges – Subversion, Git, and Mercurial - - © elego Software Solutions GmbH
Comparing Apples to Oranges
Subversion, Git, and Mercurial
SubConf 2009
Stefan Sperling <[email protected]>
Stephen Butler <[email protected]>
![Page 2: Comparing Apples to Oranges Subversion, Git, and Mercurial · Comparing Apples to Oranges –Subversion, Git, and Mercurial - - ©elego Software Solutions GmbH1 Comparing Apples to](https://reader034.vdocuments.mx/reader034/viewer/2022043010/5fa139da9e3281513d0ad3b2/html5/thumbnails/2.jpg)
2
Is there SCM tool convergence?
![Page 3: Comparing Apples to Oranges Subversion, Git, and Mercurial · Comparing Apples to Oranges –Subversion, Git, and Mercurial - - ©elego Software Solutions GmbH1 Comparing Apples to](https://reader034.vdocuments.mx/reader034/viewer/2022043010/5fa139da9e3281513d0ad3b2/html5/thumbnails/3.jpg)
3
Real-life situations
1. Reserving a file for editing
– Centralized vs distributed
2. Merging a text edit to a renamed file
– How is tree history modeled?
3. Merging a file move
– Distinguishing file move from directory rename
4. Cherry-picking a revision
– Fine-grained merge tracking
![Page 4: Comparing Apples to Oranges Subversion, Git, and Mercurial · Comparing Apples to Oranges –Subversion, Git, and Mercurial - - ©elego Software Solutions GmbH1 Comparing Apples to](https://reader034.vdocuments.mx/reader034/viewer/2022043010/5fa139da9e3281513d0ad3b2/html5/thumbnails/4.jpg)
4
Real-life situations
1. Reserving a file for editing
– Centralised vs distributed
![Page 5: Comparing Apples to Oranges Subversion, Git, and Mercurial · Comparing Apples to Oranges –Subversion, Git, and Mercurial - - ©elego Software Solutions GmbH1 Comparing Apples to](https://reader034.vdocuments.mx/reader034/viewer/2022043010/5fa139da9e3281513d0ad3b2/html5/thumbnails/5.jpg)
5
Centralised design
![Page 6: Comparing Apples to Oranges Subversion, Git, and Mercurial · Comparing Apples to Oranges –Subversion, Git, and Mercurial - - ©elego Software Solutions GmbH1 Comparing Apples to](https://reader034.vdocuments.mx/reader034/viewer/2022043010/5fa139da9e3281513d0ad3b2/html5/thumbnails/6.jpg)
6
Distributed design
![Page 7: Comparing Apples to Oranges Subversion, Git, and Mercurial · Comparing Apples to Oranges –Subversion, Git, and Mercurial - - ©elego Software Solutions GmbH1 Comparing Apples to](https://reader034.vdocuments.mx/reader034/viewer/2022043010/5fa139da9e3281513d0ad3b2/html5/thumbnails/7.jpg)
7
Distributed design with a central server
![Page 8: Comparing Apples to Oranges Subversion, Git, and Mercurial · Comparing Apples to Oranges –Subversion, Git, and Mercurial - - ©elego Software Solutions GmbH1 Comparing Apples to](https://reader034.vdocuments.mx/reader034/viewer/2022043010/5fa139da9e3281513d0ad3b2/html5/thumbnails/8.jpg)
8
Real-life situations
1. Reserving a file for editing
– Centralised vs distributed
2. Merging a text edit to a renamed file
– How is tree history modeled?
![Page 9: Comparing Apples to Oranges Subversion, Git, and Mercurial · Comparing Apples to Oranges –Subversion, Git, and Mercurial - - ©elego Software Solutions GmbH1 Comparing Apples to](https://reader034.vdocuments.mx/reader034/viewer/2022043010/5fa139da9e3281513d0ad3b2/html5/thumbnails/9.jpg)
9
Merging a text edit to a renamed file
� Edit the text of file foo.c in branch A:
--- foo.c+++ foo.c@@ -1,4 +1,4 @@#include <stdio.h>void main() {- printf("Hello world!\n");+ printf("Goodbye world!\n");}
� Rename file foo.c to bar.c in branch B
� Merge the text change from branch A to branch B
![Page 10: Comparing Apples to Oranges Subversion, Git, and Mercurial · Comparing Apples to Oranges –Subversion, Git, and Mercurial - - ©elego Software Solutions GmbH1 Comparing Apples to](https://reader034.vdocuments.mx/reader034/viewer/2022043010/5fa139da9e3281513d0ad3b2/html5/thumbnails/10.jpg)
10
Merging a text edit to a renamed file
� Subversion:
$ svn merge ^/A
--- Merging r3 through r5 into '.':
C foo.c
Summary of conflicts:
Tree conflicts: 1
$ svn status
M .
! C foo.c
> local missing, incoming edit upon merge
$ svn merge ^/A/foo.c@2 ^/A/foo.c@5 bar.c
--- Merging r3 through r5 into 'bar.c':
U bar.c
$ cat bar.c
#include <stdio.h>
int main() {
printf("Goodbye world!\n");
}
$ svn resolved foo.c
![Page 11: Comparing Apples to Oranges Subversion, Git, and Mercurial · Comparing Apples to Oranges –Subversion, Git, and Mercurial - - ©elego Software Solutions GmbH1 Comparing Apples to](https://reader034.vdocuments.mx/reader034/viewer/2022043010/5fa139da9e3281513d0ad3b2/html5/thumbnails/11.jpg)
11
Subversion 3D tree
![Page 12: Comparing Apples to Oranges Subversion, Git, and Mercurial · Comparing Apples to Oranges –Subversion, Git, and Mercurial - - ©elego Software Solutions GmbH1 Comparing Apples to](https://reader034.vdocuments.mx/reader034/viewer/2022043010/5fa139da9e3281513d0ad3b2/html5/thumbnails/12.jpg)
12
Subversion 3D tree
![Page 13: Comparing Apples to Oranges Subversion, Git, and Mercurial · Comparing Apples to Oranges –Subversion, Git, and Mercurial - - ©elego Software Solutions GmbH1 Comparing Apples to](https://reader034.vdocuments.mx/reader034/viewer/2022043010/5fa139da9e3281513d0ad3b2/html5/thumbnails/13.jpg)
13
Subversion 3D tree
![Page 14: Comparing Apples to Oranges Subversion, Git, and Mercurial · Comparing Apples to Oranges –Subversion, Git, and Mercurial - - ©elego Software Solutions GmbH1 Comparing Apples to](https://reader034.vdocuments.mx/reader034/viewer/2022043010/5fa139da9e3281513d0ad3b2/html5/thumbnails/14.jpg)
14Comparing Apples to Oranges – Subversion, Git, and Mercurial - - © elego Software Solutions GmbH
Merging a text edit to a renamed file
� Mercurial:
$ hg pull ../A
pulling from ../A
searching for changes
adding changesets
adding manifests
adding file changes
added 1 changesets with 1 changes to 1 files (+1 heads)
(run 'hg heads' to see heads, 'hg merge' to merge)
$ hg merge
merging bar.c and foo.c to bar.c
0 files updated, 1 files merged, 0 files removed, 0 files unresolved
(branch merge, don't forget to commit)
$ cat bar.c
#include <stdio.h>
void main() {
printf("Goodbye world!\n");
}
$
![Page 15: Comparing Apples to Oranges Subversion, Git, and Mercurial · Comparing Apples to Oranges –Subversion, Git, and Mercurial - - ©elego Software Solutions GmbH1 Comparing Apples to](https://reader034.vdocuments.mx/reader034/viewer/2022043010/5fa139da9e3281513d0ad3b2/html5/thumbnails/15.jpg)
15
Mercurial: Revlog data structure
![Page 16: Comparing Apples to Oranges Subversion, Git, and Mercurial · Comparing Apples to Oranges –Subversion, Git, and Mercurial - - ©elego Software Solutions GmbH1 Comparing Apples to](https://reader034.vdocuments.mx/reader034/viewer/2022043010/5fa139da9e3281513d0ad3b2/html5/thumbnails/16.jpg)
16
Mercurial: Filelog
![Page 17: Comparing Apples to Oranges Subversion, Git, and Mercurial · Comparing Apples to Oranges –Subversion, Git, and Mercurial - - ©elego Software Solutions GmbH1 Comparing Apples to](https://reader034.vdocuments.mx/reader034/viewer/2022043010/5fa139da9e3281513d0ad3b2/html5/thumbnails/17.jpg)
17
Mercurial: Filelog
![Page 18: Comparing Apples to Oranges Subversion, Git, and Mercurial · Comparing Apples to Oranges –Subversion, Git, and Mercurial - - ©elego Software Solutions GmbH1 Comparing Apples to](https://reader034.vdocuments.mx/reader034/viewer/2022043010/5fa139da9e3281513d0ad3b2/html5/thumbnails/18.jpg)
18
Mercurial: Changeset calculation
![Page 19: Comparing Apples to Oranges Subversion, Git, and Mercurial · Comparing Apples to Oranges –Subversion, Git, and Mercurial - - ©elego Software Solutions GmbH1 Comparing Apples to](https://reader034.vdocuments.mx/reader034/viewer/2022043010/5fa139da9e3281513d0ad3b2/html5/thumbnails/19.jpg)
19
Mercurial: Manifest & changelog
![Page 20: Comparing Apples to Oranges Subversion, Git, and Mercurial · Comparing Apples to Oranges –Subversion, Git, and Mercurial - - ©elego Software Solutions GmbH1 Comparing Apples to](https://reader034.vdocuments.mx/reader034/viewer/2022043010/5fa139da9e3281513d0ad3b2/html5/thumbnails/20.jpg)
20
Merging a text edit to a renamed file
� Git:
$ git pull ../A master
remote: Counting objects: 5, done.
remote: Compressing objects: 100% (2/2), done.
remote: Total 3 (delta 0), reused 0 (delta 0)
Unpacking objects: 100% (3/3), done.
From ../A
* branch master -> FETCH_HEAD
Merge made by recursive.
bar.c | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
$ cat bar.c
#include <stdio.h>
void main() {
printf("Goodbye world!\n");
}
$
![Page 21: Comparing Apples to Oranges Subversion, Git, and Mercurial · Comparing Apples to Oranges –Subversion, Git, and Mercurial - - ©elego Software Solutions GmbH1 Comparing Apples to](https://reader034.vdocuments.mx/reader034/viewer/2022043010/5fa139da9e3281513d0ad3b2/html5/thumbnails/21.jpg)
21
Git: Blob object stores file content
![Page 22: Comparing Apples to Oranges Subversion, Git, and Mercurial · Comparing Apples to Oranges –Subversion, Git, and Mercurial - - ©elego Software Solutions GmbH1 Comparing Apples to](https://reader034.vdocuments.mx/reader034/viewer/2022043010/5fa139da9e3281513d0ad3b2/html5/thumbnails/22.jpg)
22
Git: Every revision of a file creates a new blob
![Page 23: Comparing Apples to Oranges Subversion, Git, and Mercurial · Comparing Apples to Oranges –Subversion, Git, and Mercurial - - ©elego Software Solutions GmbH1 Comparing Apples to](https://reader034.vdocuments.mx/reader034/viewer/2022043010/5fa139da9e3281513d0ad3b2/html5/thumbnails/23.jpg)
23
Git: All file blobs are stored together
![Page 24: Comparing Apples to Oranges Subversion, Git, and Mercurial · Comparing Apples to Oranges –Subversion, Git, and Mercurial - - ©elego Software Solutions GmbH1 Comparing Apples to](https://reader034.vdocuments.mx/reader034/viewer/2022043010/5fa139da9e3281513d0ad3b2/html5/thumbnails/24.jpg)
24
Git: Tree objects represent directories
![Page 25: Comparing Apples to Oranges Subversion, Git, and Mercurial · Comparing Apples to Oranges –Subversion, Git, and Mercurial - - ©elego Software Solutions GmbH1 Comparing Apples to](https://reader034.vdocuments.mx/reader034/viewer/2022043010/5fa139da9e3281513d0ad3b2/html5/thumbnails/25.jpg)
25
Git: Tree objects form a hierarchy
![Page 26: Comparing Apples to Oranges Subversion, Git, and Mercurial · Comparing Apples to Oranges –Subversion, Git, and Mercurial - - ©elego Software Solutions GmbH1 Comparing Apples to](https://reader034.vdocuments.mx/reader034/viewer/2022043010/5fa139da9e3281513d0ad3b2/html5/thumbnails/26.jpg)
26
Git: Commit object refers to a tree root
![Page 27: Comparing Apples to Oranges Subversion, Git, and Mercurial · Comparing Apples to Oranges –Subversion, Git, and Mercurial - - ©elego Software Solutions GmbH1 Comparing Apples to](https://reader034.vdocuments.mx/reader034/viewer/2022043010/5fa139da9e3281513d0ad3b2/html5/thumbnails/27.jpg)
27
Real-life situations
1. Reserving a file for editing
– Centralised vs distributed
2. Merging a text edit to a renamed file
– How is tree history modeled?
3. Merging a file move
– Distinguishing a file move from a directory rename
![Page 28: Comparing Apples to Oranges Subversion, Git, and Mercurial · Comparing Apples to Oranges –Subversion, Git, and Mercurial - - ©elego Software Solutions GmbH1 Comparing Apples to](https://reader034.vdocuments.mx/reader034/viewer/2022043010/5fa139da9e3281513d0ad3b2/html5/thumbnails/28.jpg)
28
Merging a file move
� Developers! Developers! Developers!
� They like to refactor their code
– Renaming files
– Renaming directories
nach Software Configuration Management Patterns Berczuk/Appelton
![Page 29: Comparing Apples to Oranges Subversion, Git, and Mercurial · Comparing Apples to Oranges –Subversion, Git, and Mercurial - - ©elego Software Solutions GmbH1 Comparing Apples to](https://reader034.vdocuments.mx/reader034/viewer/2022043010/5fa139da9e3281513d0ad3b2/html5/thumbnails/29.jpg)
29
Merging a file move
� A project starts out as:
fruit/Color.java
fruit/Taste.java
fruit/citrus/Apple.java
� On branch A, add a file to the "citrus" package:
fruit/Color.java
fruit/Taste.java
fruit/citrus/Apple.java
fruit/citrus/Orange.java
� On branch B, move Apple.java to the "pome" package:
fruit/Color.java
fruit/Taste.java
fruit/citrus/
fruit/pome/Apple.java
� Merge the change from branch A to branch B
![Page 30: Comparing Apples to Oranges Subversion, Git, and Mercurial · Comparing Apples to Oranges –Subversion, Git, and Mercurial - - ©elego Software Solutions GmbH1 Comparing Apples to](https://reader034.vdocuments.mx/reader034/viewer/2022043010/5fa139da9e3281513d0ad3b2/html5/thumbnails/30.jpg)
30
Merging a file move
� Subversion:
$ svn merge ^/A
--- Merging r3 through r5 into '.':
A fruit/citrus/Orange.java
$ svn status
M .
A + fruit/citrus/Orange.java
$ ls fruit/ fruit/citrus/ fruit/pome/
Color.java Taste.java citrus/ pome/
fruit/citrus:
Orange.java
fruit/pome:
Apple.java
![Page 31: Comparing Apples to Oranges Subversion, Git, and Mercurial · Comparing Apples to Oranges –Subversion, Git, and Mercurial - - ©elego Software Solutions GmbH1 Comparing Apples to](https://reader034.vdocuments.mx/reader034/viewer/2022043010/5fa139da9e3281513d0ad3b2/html5/thumbnails/31.jpg)
31
Subversion records the source of a copy
![Page 32: Comparing Apples to Oranges Subversion, Git, and Mercurial · Comparing Apples to Oranges –Subversion, Git, and Mercurial - - ©elego Software Solutions GmbH1 Comparing Apples to](https://reader034.vdocuments.mx/reader034/viewer/2022043010/5fa139da9e3281513d0ad3b2/html5/thumbnails/32.jpg)
32
Subversion records the source of a copy
![Page 33: Comparing Apples to Oranges Subversion, Git, and Mercurial · Comparing Apples to Oranges –Subversion, Git, and Mercurial - - ©elego Software Solutions GmbH1 Comparing Apples to](https://reader034.vdocuments.mx/reader034/viewer/2022043010/5fa139da9e3281513d0ad3b2/html5/thumbnails/33.jpg)
33
Merging a file move
� Mercurial:
$ hg pull ../A
pulling from ../A
searching for changes
adding changesets
adding manifests
adding file changes
added 1 changesets with 1 changes to 1 files (+1 heads)
(run 'hg heads' to see heads, 'hg merge' to merge)
$ hg merge
1 files updated, 0 files merged, 0 files removed, 0 files unresolved
(branch merge, don't forget to commit)
$ ls -R fruit/
Color.java Taste.java pome/
fruit/pome:
Apple.java Orange.java
![Page 34: Comparing Apples to Oranges Subversion, Git, and Mercurial · Comparing Apples to Oranges –Subversion, Git, and Mercurial - - ©elego Software Solutions GmbH1 Comparing Apples to](https://reader034.vdocuments.mx/reader034/viewer/2022043010/5fa139da9e3281513d0ad3b2/html5/thumbnails/34.jpg)
34Comparing Apples to Oranges – Subversion, Git, and Mercurial - - © elego Software Solutions GmbH
Merging a file move
� Git:
$ git pull ../A master
remote: Counting objects: 8, done.
remote: Compressing objects: 100% (4/4), done.
remote: Total 5 (delta 1), reused 0 (delta 0)
Unpacking objects: 100% (5/5), done.
From ../A
* branch master -> FETCH_HEAD
Merge made by recursive.
fruit/citrus/Orange.java | 20 ++++++++++++++++++++
1 files changed, 20 insertions(+), 0 deletions(-)
create mode 100644 fruit/citrus/Orange.java
$ ls -R fruit/
Color.java Taste.java citrus/ pome/
fruit/citrus:
Orange.java
fruit/pome:
Apple.java
$
![Page 35: Comparing Apples to Oranges Subversion, Git, and Mercurial · Comparing Apples to Oranges –Subversion, Git, and Mercurial - - ©elego Software Solutions GmbH1 Comparing Apples to](https://reader034.vdocuments.mx/reader034/viewer/2022043010/5fa139da9e3281513d0ad3b2/html5/thumbnails/35.jpg)
35
Real-life situations
1. Reserving a file for editing
– Centralised vs distributed
2. Merging a text edit to a renamed file
– How is tree history modeled?
3. Merging a file move
– Distinguishing file move from directory rename
4. Cherry-picking a revision
– Fine-grained merge tracking
![Page 36: Comparing Apples to Oranges Subversion, Git, and Mercurial · Comparing Apples to Oranges –Subversion, Git, and Mercurial - - ©elego Software Solutions GmbH1 Comparing Apples to](https://reader034.vdocuments.mx/reader034/viewer/2022043010/5fa139da9e3281513d0ad3b2/html5/thumbnails/36.jpg)
36
Cherry-picking a revision
� Pick a revision from a branch's history and merge it to the HEADof another branch.
L. Wingard 2005 - Flow of Change
![Page 37: Comparing Apples to Oranges Subversion, Git, and Mercurial · Comparing Apples to Oranges –Subversion, Git, and Mercurial - - ©elego Software Solutions GmbH1 Comparing Apples to](https://reader034.vdocuments.mx/reader034/viewer/2022043010/5fa139da9e3281513d0ad3b2/html5/thumbnails/37.jpg)
37
Cherry-picking a revision
� Release branches need to receive bug fixes
� Two approaches:
– Make fix in main line, then merge into release branch
– Make fix in release branch, then merge into main line
� Ideally, the merge should be tracked
� Which approach works best for
– Subversion?
– Mercurial?
– Git?
![Page 38: Comparing Apples to Oranges Subversion, Git, and Mercurial · Comparing Apples to Oranges –Subversion, Git, and Mercurial - - ©elego Software Solutions GmbH1 Comparing Apples to](https://reader034.vdocuments.mx/reader034/viewer/2022043010/5fa139da9e3281513d0ad3b2/html5/thumbnails/38.jpg)
38
Why should I care about the design of my SCM tool?
� Design defines constraints
� Your development process must adapt to constraints
� Fixing bugs is easy, fixing design is hard
![Page 39: Comparing Apples to Oranges Subversion, Git, and Mercurial · Comparing Apples to Oranges –Subversion, Git, and Mercurial - - ©elego Software Solutions GmbH1 Comparing Apples to](https://reader034.vdocuments.mx/reader034/viewer/2022043010/5fa139da9e3281513d0ad3b2/html5/thumbnails/39.jpg)
39Comparing Apples to Oranges – Subversion, Git, and Mercurial - - © elego Software Solutions GmbH
Thank you!
Questions?