+ All Categories
Home > Technology > Version Control Basics

Version Control Basics

Date post: 06-May-2015
Category:
Upload: g-b-versiani
View: 922 times
Download: 0 times
Share this document with a friend
Description:
This presentation shows basic concepts about revision control systems, common to all tools available in the market. It doesn't enter in details in any specific technology, but concentrates only on the concepts involved in those. There are a section related to branching patterns and anti-patterns too.
58
Nymgo team Version Control Basics
Transcript
Page 1: Version Control Basics

Nymgo team

Version ControlBasics

Page 2: Version Control Basics

Version Control

Objectives

Understand basic elements and management of the version control, without

entering in details of a specific Version Control System.

Page 3: Version Control Basics

Version Control

Agenda (1h)

1.Basic vocabulary2.Parallel Worlds3.Branching Patterns4.Anti-Patterns

Page 4: Version Control Basics

BASIC VOCABULARYMain concepts

Page 5: Version Control Basics

Version Control

Environment

• RepositoryWhere files’ current and historical data are stored.

• ServerA machine serving the repository.

• ClientThe client machine connecting to the server.

• Working copyLocal copy where the developer changes the code.

Page 6: Version Control Basics

Version Control

Client

Environment

Server

Repository

Working copy

Page 7: Version Control Basics

Version Control

Basic operations

• AddMark a file or folder to be versioned

• ChangeCreate any changes in the local copy

• CommitSend changes to the repository

• RevertDiscard local changes and go back to the same last known revision from the repository

Page 8: Version Control Basics

Version Control

Basic operations

Foobar.txt Foobar.txt

Foobar.txt Foobar.txt

Add

Revert

Commit

Change

Commit

Delete

Revert

Commit

Page 9: Version Control Basics

Version Control

Basic artifacts

• RevisionSet of changes, state of the code in a point of time

• ChangelogSequential view of the changes done to the code, stored in the repository

Page 10: Version Control Basics

Version Control

Artefatos Básicos

1220

1221

1222

file1.txtfile3.txt

file2.txtfile4.txt

file1.txtfile2.txtfile4.txt

tom

dick

harry

Including feature A.

Including BUG B.

Refactoring of module C.

1219 file1.txtfile2.txtfile3.txtfile4.txt

fulanoFirst inclusion

Revision

Revision number

Revision author

Changed files

Description message

Changelog

Last revision (head)

Timelin

e

Page 11: Version Control Basics

Version Control

Synchronization

• UpdateSynchronize changes from the repository to the local copy

Page 12: Version Control Basics

Version Control

Synchronization

Tom

Server

Jerry

Commit

Update

1219 1220 1221 1222

1219 1220 1221

1222

1219 1220 1221 1222

Page 13: Version Control Basics

Version Control

Labels

• TagsComprehensive alias for existing revisions, marking an important snapshot in time

Page 14: Version Control Basics

Version Control

Labels

1220

1221

1222

1219

1.0.1

1.0.2

1220

1221

1222

file1.txtfile3.txt

file2.txtfile4.txt

file1.txtfile2.txtfile4.txt

dick

tom

harry

Including feature A.

Including BUG B.

Refactoring of module C.

1219 file1.txtfile2.txtfile3.txtfile4.txt

tomFirst inclusion.

Tags

Page 15: Version Control Basics

Version Control

Changes

• Diffs and PatchesThe comparison between two text files is done by an application diff-like that feeds an application patch-like capable of redo the changes from the originating state to the destination state.This operation of computing the differences is normally referred as diff, while the “file containing the differences”, that could be exchanged in e-mails and other eletronic media, is denominated patch.

Page 16: Version Control Basics

Version Control

Changes – Example

Page 17: Version Control Basics

Diff file or patch

Page 18: Version Control Basics

Diff file or patch

Page 19: Version Control Basics

Version Control

1219 1220 1221 1222

Changes

1218

diff 1 diff 2 diff 3 diff 4

Page 20: Version Control Basics

PARALLEL WORLDSConcepts of branching, merging and conflicts

Page 21: Version Control Basics

Version Control

Parallel WorldsPerhaps the most accessible way to think of branches is as parallel

universes. They're places where, for whatever reason, history didn't go quite the same way as it did in your universe. From that point forward,

that universe can be slightly different – or it can be radically and utterly transformed. Like the Marvel comic book series “What If?”,

branching lets you answer some interesting and possibly even dangerous "what if" questions with your software development.

Page 22: Version Control Basics

Version Control

Parallel Worlds

• Parallel universes offer unlimited possibilities.

• They also allow you to stay safely ensconced in the particular universe of your choice, completely isolated from any events in other alternate universes.

Page 23: Version Control Basics

Version Control

Parallel Worlds

• Branch is like a parallel world.• Changes done in one branch

doesn’t have effect over the another.

• Although branching offers the seductive appeal of multiple possibility with very little risk, it also brings along something far less desirable: increase of complexity.

Page 24: Version Control Basics

Version Control

Branches

X

Y

Z

W

Create branch

Create branch

Create branch

Page 25: Version Control Basics

Version Control

Merge

• In some point of the development, the code must be merged.

Page 26: Version Control Basics

Version Control

Merge

X

Y

Merge

Page 27: Version Control Basics

Version Control

Conflicts

• When the changes are done in the same source file lines, you can have conflicts.

Page 28: Version Control Basics

Version Control

How to solve conflicts?

Page 29: Version Control Basics

Version Control

How to solve conflicts?

Question:Is it possible to solve

these conflicts automatically?

Page 30: Version Control Basics

Version Control

How to solve conflicts?

Answer: No!!!Even when don’t have changes in

the same source line, you can still have semantic problems in

the code. So, always double check before to commit.

Page 31: Version Control Basics

Version Control

How to solve conflicts?

A note before continuing:

It is always better to avoid unnecessary

conflicts.Communicate your development, always include a description

in your committed revisions, ask for help if you don’t understand anything, etc.

Page 32: Version Control Basics

Version Control

How to solve conflicts?

Aworking base

Bworking copy

C = A + Boutput

A

B C

Two way merge

Page 33: Version Control Basics

Tools: KDiff3

Page 34: Version Control Basics

Version Control

How to solve conflicts?

B

C DA

Aorigin

Cbranch

#2

D = A + B + C

Bbranch #1

Create branch

Merge

Three way merge

Page 35: Version Control Basics

Tools: KDiff3

Page 36: Version Control Basics

Tools: choose one…

Notepad++

Araxis

DiffMerge

MeldUltracompare

tkmergexxdiff

TFS diffmerge

Guiffy SureMerge

Apple Filemerge

...

Page 37: Version Control Basics

Which one should I use?

Choose one that best fits your

team!

Page 38: Version Control Basics

BRANCHING PATTERNSHow to manage the branches during the software lifecycle

Page 39: Version Control Basics

Version Control

Mainline

1.0

1.1

1.2

2.0

branch

1.0.1

merge

branch

1.1.1

merge

branch

1.2.1

1.1.2

merge

1.2.2

merge

2.0.1

Page 40: Version Control Basics

Version Control

Mainline

Bring a fix from branch n to branch m require m-n

merges (linear complexity with the number of

branches).

Page 41: Version Control Basics

Version Control

Mainline

Learned lesson:

Perform merges the early and frequently as possible.

Page 42: Version Control Basics

Version Control

Mainline / Variant

mainline

1.1

1.2

2.0

branch

merge

1.1.1

branch

1.2.1

merge

1.2.2

merge

2.0.1

merge

branch

merge

3.0

branch

Page 43: Version Control Basics

Version Control

Scenario:

You just developed a stable version of the software and you

need to create a new version with new features and still

provide small fixes for the last stable version.

Page 44: Version Control Basics

Version Control

Parallel Maintenance / Development Lines

devel

1.1

2.0.1

1.1.1

merge

1.1.2

merge

branch1.0.0

Most used option

Page 45: Version Control Basics

Version Control

Parallel Maintenance / Development Lines

devel

1.1

2.0

branch

merge

1.1.1

2.0.1

merge

2.0.2

merge

merge

branch1.0.0

Note the internal branch

Page 46: Version Control Basics

Version Control

Scenario:

You need to develop two different features in a short

period of time.

(laughts)

Page 47: Version Control Basics

Version Control

Overlapping Release Lines

mainline

func_2

func_1

branch

merge merge

merge

branch

Page 48: Version Control Basics

Version Control

Scenario:

You allocated a new developer to work in a too risky code base and

you want to moderate his/her changes for a while.

Page 49: Version Control Basics

Version Control

Docking Line

devel

docking

line change,stabilize

change,stabilize

change,stabilize

sync sync sync

merge merge merge

moderador

desenvolvedor

Page 50: Version Control Basics

Version Control

Scenario:

Your development tasks need to progress in discrete levels of

maturity: (1) change proposals, (2) analysis, (3) review, (4) unit tests, (5) integration tests, (6)

system tests, etc.

Page 51: Version Control Basics

Version Control

Staged Integration Lines

devel

propostas

revisão

testes

(1)

(2)

(3)

Page 52: Version Control Basics

WHEN TO CREATE A BRANCH?Some most common patterns.

Page 53: Version Control Basics

Version Control

Branch per Delivery

Release 1

Release 2

1.0 1.1 1.2 1.3

2.0 2.1 2.2 2.3

Create branch Merge

Page 54: Version Control Basics

Version Control

Branch per Task

Devel

1.0 1.1 1.2

Task 1

Task 2

Page 55: Version Control Basics

Version Control

Branch per Component

Devel

1.0 1.1 1.2

Component A

Component B

Components A + B

Page 56: Version Control Basics

Version Control

Branch per Technology

Common

Android

iOS

1.1 1.2

1.1

1.1 1.2

Page 57: Version Control Basics

ANTI-PATTERNSWhat can happen if you don’t manage branching

Page 58: Version Control Basics

Anti-Pattern Description

Merge Paranoia avoiding merging at all cost, usually because of a fear of the consequences.

Merge Mania spending too much time merging software assets instead of developing them.

Big-Bang Merge deferring branch merging to the end of the development effort and attempting to merge all branches simultaneously.

Nerver-Ending Merge continuous merging activity because there is always more to merge.

Wrong-Way Merge merging a software asset version with an earlier version.

Branch Mania creating many branches for no apparent reason.

Cascading Branches branching but never merging back to the main line.

Mysterious Branches branching for no apparent reason.

Temporary Branches branching for changing reasons, so the branch becomes a permanent temporary workspace.

Volatile Branches branching with unstable software assets shared by other branches or merged into another branch.

Note   Branches are volatile most of the time while they exist as independent branches. That is the point of having them. The difference is that you should not share or merge branches while they are in an unstable state.

Development Freeze stopping all development activities while branching, merging, and building new base lines.

Berlin Wall using branches to divide the development team members, instead of dividing the work they are performing.


Recommended