Slide 1

Slide 1 text

DCVS Distributed Concurrent Versions Systems Ilja Hämäläinen 2014

Slide 2

Slide 2 text

Disclaimer 1: I don’t intend to force you to migrate to any other DCVS system

Slide 3

Slide 3 text

Disclaimer 2: This is my own opinion. Current presentation is not based on any other article.

Slide 4

Slide 4 text

Today we will compare Git and Hg

Slide 5

Slide 5 text

Main features of an CVS 1. Changing history a. Rollout b. Code review c. Logical bombs 2. Merge code from several developers a. Merging 3. Backup

Slide 6

Slide 6 text

No content

Slide 7

Slide 7 text

CVS vs DCVS CVS DCVS Commit/revision copy of a file node in the changeset tree Branch copy of a folder link to another node Update/Checkout network call applying changesets locally Merging painful the part of its core

Slide 8

Slide 8 text

Git and Mercurial

Slide 9

Slide 9 text

Cloning Git: $ git clone Mercurial: $ hg clone

Slide 10

Slide 10 text

Commit Git: $ git add . $ git commit -m “Commit message” or $ git commit -am “Commit message” Mercurial: $ hg commit -m “Commit message”

Slide 11

Slide 11 text

Amend to a previous commit Git: $ git commit --amend Mercurial: $ hg commit --amend Note, it works only if you have not pushed you code yet!

Slide 12

Slide 12 text

Switch between revisions Git: $ git checkout $ git checkout e2b6c376c Mercurial: $ hg update $ hg update 957b22

Slide 13

Slide 13 text

Pull and push Git: $ git pull origin master $ git push origin master Mercurial: $ hg pull $ hg push

Slide 14

Slide 14 text

Several repositories in Git ● But Git allows you to work with several repos ● You have always to specify where exactly you want to pull/push: ○ $ git push origin master ○ $ git pull oleg-repo master

Slide 15

Slide 15 text

Branching

Slide 16

Slide 16 text

Create new branch Git (local): $ git checkout -b issue53 Mercurial: $ hg branch issue53

Slide 17

Slide 17 text

On which branch I am? Git: $ git branch output: master * issue53 feature47 Mercurial: $ hg branch output: issue53 or: $ hg branches

Slide 18

Slide 18 text

Switch between branches Git: $ git checkout master output: Switched to branch 'master' Your branch is up-to-date with 'origin/master'. Mercurial: $ hg update default output: 0 files updated, 0 files merged, 0 files removed, 0 files unresolved

Slide 19

Slide 19 text

Local and remote branches in Git

Slide 20

Slide 20 text

The list of remote branches (Git) The list of all the remote branches: $ git branch -r output: origin/HEAD -> origin/master origin/master origin/refactor-services-with-standard-interfaces

Slide 21

Slide 21 text

The list of local branches in Git Without parameters it lists only local branches: $ git branch output: master * refactor-services-with-standard-interfaces but -a parameter prints all the branches: $ git branch -a

Slide 22

Slide 22 text

Clone remote branch in Git $ git checkout -b feature-add-logging origin/feature-add-logging

Slide 23

Slide 23 text

Merging Git: $ git merge hotfix Mercurial: $ hg merge hotfix

Slide 24

Slide 24 text

Fast Forward in Git When you try to merge one commit with a commit that can be reached by following the first commit’s history, Git simplifies things by moving the pointer forward because there is no divergent work to merge together — this is called a "fast forward".

Slide 25

Slide 25 text

Fast Forward in Git

Slide 26

Slide 26 text

Bookmarks in Mercurial “Bookmark - is local reference to commits that can be automatically updated when new commits are made.” Bookmarks in Hg is like local branches in Git. The main difference is you can push local branch in Git, but bookmark in Hg always remains local.

Slide 27

Slide 27 text

Rebase Merging brings two lines of development together while preserving the ancestry of each commit history. In contrast, rebasing unifies the lines of development by re-writing changes from the source branch so that they appear as children of the destination branch – effectively pretending that those commits were written on top of the destination branch all along.

Slide 28

Slide 28 text

Rebase

Slide 29

Slide 29 text

Summary about branching Git Mercurial local branches + bookmarks only remote branches + - rebase + + fast-forward + -

Slide 30

Slide 30 text

Other useful features

Slide 31

Slide 31 text

Hooks both Git and Mercurial: language agnostic, but the most popular is Python and shell

Slide 32

Slide 32 text

Bisect - debugging with CVS Find by binary search the change that introduced a bug

Slide 33

Slide 33 text

Bisect in Git $ git bisect $ git bisect bad $ git bisect good v1.0 Bisecting: 6 revisions left to test after this [ecb6e1bc347ccecc5f9350d878ce677feb13d3b2] error handling on repo ... $ git bisect good Bisecting: 3 revisions left to test after this [b047b02ea83310a70fd603dc8cd7a6cd13d15c04] secure this thing $ git bisect bad Bisecting: 1 revisions left to test after this [f71ce38690acf49c1f3c9bea38e09d82a5ce6014] drop exceptions table $ git bisect reset

Slide 34

Slide 34 text

Bisect in Mercurial $ hg bisect --bad $ hg update -r -100 89 files updated, 0 files merged, 30 files removed, 0 files unresolved $ hg bisect --good Testing changeset 11964:79bd860b8eb7 (81 changesets remaining, ~6 tests) 36 files updated, 0 files merged, 22 files removed, 0 files unresolved $ hg bisect --good Testing changeset 11985:81edef14922e (41 changesets remaining, ~5 tests) 23 files updated, 0 files merged, 26 files removed, 0 files unresolved … $ hg bisect --bad The first bad revision is: changeset: 11981:518b90d66fad … $ hg bisect --reset

Slide 35

Slide 35 text

Stash Hides uncommitted changes and saves it locally. Git: $ git shash Mercurial: $ hg shelve

Slide 36

Slide 36 text

Web server: Git Requires lighttpd installed in a system $ git instaweb

Slide 37

Slide 37 text

Web server: Mercurial There a lot of choices, but the simplest is: $ hg serve

Slide 38

Slide 38 text

Different features

Slide 39

Slide 39 text

Git: pull-request $ git request-pull origin/master myfork The following changes since commit 1edee6b1d61823a2de3b09c160d7080b8d1b3a40: John Smith (1): added a new function are available in the git repository at: git://githost/simplegit.git featureA Jessica Smith (2): add limit to log function change log output to 30 from 25 lib/simplegit.rb | 10 +++++++++- 1 files changed, 9 insertions(+), 1 deletions(-)

Slide 40

Slide 40 text

Git: send patches by email (1) $ git format-patch -M origin/master 0001-add-limit-to-log-function.patch 0002-changed-log-output-to-30-from-25.patch

Slide 41

Slide 41 text

Git: send patches by email (2) $ cat 0001-add-limit-to-log-function.patch From 330090432754092d704da8e76ca5c05c198e71a8 Mon Sep 17 00:00:00 2001 From: Jessica Smith Date: Sun, 6 Apr 2008 10:17:23 -0700 Subject: [PATCH 1/2] add limit to log function Limit log functionality to the first 20 --- lib/simplegit.rb | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diff --git a/lib/simplegit.rb b/lib/simplegit.rb index 76f47bc..f9815f1 100644 --- a/lib/simplegit.rb +++ b/lib/simplegit.rb ...

Slide 42

Slide 42 text

Git: send patches by email (3) $ git send-email *.patch 0001-added-limit-to-log-function.patch 0002-changed-log-output-to-30-from-25.patch Who should the emails appear to be from? [Jessica Smith ] Emails will be sent from: Jessica Smith Who should the emails be sent to? [email protected] Message-ID to be used as In-Reply-To for the first email? y

Slide 43

Slide 43 text

How many commits are ready to go? Git: git log origin/dev..dev Mercurial: hg outgoing hg out

Slide 44

Slide 44 text

Print incoming commits Git: git log dev..origin/dev Mercurial: hg incoming hg in

Slide 45

Slide 45 text

Diff between revisions Git: git diff ecba4662..6bfc611a git diff ecba4662..HEAD Mercurial: hg diff -r 10 -r 20 hg diff -r 10

Slide 46

Slide 46 text

Tools:

Slide 47

Slide 47 text

Tools: Tower 2

Slide 48

Slide 48 text

Tools: SmartGit

Slide 49

Slide 49 text

Tools:

Slide 50

Slide 50 text

Hostings Git Mercurial Gitorious ✔ GitLab ✔ GitHub ✔ Codeplex ✔ ✔ Codeplane ✔ Codebase ✔ ✔ Google Code ✔ ✔ BitBucket ✔ ✔ SourceForge ✔ ✔ Kenai ✔ java.net ✔ ✔ Assembla ✔ ✔ Kiln ✔ ✔ http://www.wikivs.com/wiki/Git_vs_Mercurial

Slide 51

Slide 51 text

Let’s compare* Git Mercurial remote branches + - local branches + + pull/push to several branches + - send patches by email + - GUI tools for all the platform - + fast forward + - * this is the most common differences that an user might face during everyday practise

Slide 52

Slide 52 text

but... All these differences are related to the branch management and dealing with patches. That means, Git better works with a sources, where you don’t trust to a collaborators. Reach tools allows you to manage repositories with a different roles of developers.

Slide 53

Slide 53 text

The conclusion is... The Git is the best for Open source projects The Mercurial is ideal for small teams with the same roles and access rights

Slide 54

Slide 54 text

Global VS remote/local branches ● Global branches allows you to keep track of your colleagues work ● Global branches allows you to observe whole project, to see all the features ● You don’t have to clone each branch every time ● You don’t have to specify the branch name in pull/push operation ● Clean history ● Easy to learn ● Low chance for a mistake

Slide 55

Slide 55 text

Two sides of a coin Git: flexible ⇔ difficult to learn, more parameters Mercurial: only basic functionality ⇔ simple The main difference is the branch model and multi- repository work in Git. Other functionality (about 90%) is almost the same.

Slide 56

Slide 56 text

If you need to go to a local shop to buy a milk and eggs? Git ✓ Mercurial ● Understandable ● Simple ● Unified, robust

Slide 57

Slide 57 text

If you need to deliver parcels to several distributors? ✓ Git Mercurial ● Local/Remote branches ● A lot of extensions ● Big community

Slide 58

Slide 58 text

Community http://habrahabr.ru/post/233935/ What CVS do you use at work?

Slide 59

Slide 59 text

Community http://habrahabr.ru/post/233935/ What CVS do you use at home?

Slide 60

Slide 60 text

No content

Slide 61

Slide 61 text

No content

Slide 62

Slide 62 text

Drink a coffee, make a Java! Thank you!

Slide 63

Slide 63 text

“Never select a technology for just the sake of a technology, have a reason!” Someone in the Internet