01 - introduction to version control

44
INTRODUCTION TO VERSION CONTROL

Upload: sergii-shmarkatiuk

Post on 18-May-2015

1.653 views

Category:

Technology


6 download

TRANSCRIPT

Page 1: 01 - Introduction to Version Control

INTRODUCTION TO VERSION CONTROL

Page 2: 01 - Introduction to Version Control

2

PURPOSE OF CURRENT TRAINING

The basics

Making first steps

AND

Page 3: 01 - Introduction to Version Control

3

CONTENTS

What is version control History and evolution of version control Instruments and their classification Approaches Domain vocabulary What else you might want to know

Page 4: 01 - Introduction to Version Control

4

WHAT IS VERSION CONTROL

Place to store your source code

Historical record of what you have done over time

Approach which allows working together without getting in each others' way (allows to collaborate more effectively)

Another “trendy” word combination

Something that every software developer should deal with

Page 5: 01 - Introduction to Version Control

5

VERSION CONTROL. SYNONYMS

Source code management

Source control

Revision control

~SCM = Software

configuration management

Files Numbers

VERSION CONTROL

Page 6: 01 - Introduction to Version Control

6

NOT VERSION CONTROL

Asset management

Dependency management

Digital storage

Package management

Installations management

Simple documents, files, packages, tracked by filesystem

What exact versions of libraries are required

Music, pictures, drawings, books

Installation managers, package dependencies

Installation is not a version

Page 7: 01 - Introduction to Version Control

7

make utility (early 70's) Bell labs paper describing the

original diff algorithm (1972) CDC update tool (early 70's.

contained revision control, change sets, build management, file diffs)

SCCS source code control system (1972)

CCC version control system (1975)

RCS revision control system (1980)

patch utility (around 1988) CVS Concurrent Version System

(1986), CVSNT (1998) Subversion (started in 1999)

HISTORY AND EVOLUTION OF VERSION CONTROL

BitKeeper (1999) GNU Arch (2001) Monotone (2003) darcs (2003) git (2005) Mercurial (2005) Bazzar (2005)

ClearCase (1992) VSS (1994) Perforce (1995) Vault (2002) AccuRev (2002) TFS (2005)

dis

tribu

ted

pro

prie

tary

Page 8: 01 - Introduction to Version Control

8

VCS CLASSIFICATION(BY REPOSITORY MODEL)

• Subversion• CVS• VSS, TFS, Vault• ClearCase• AccuRev

Centralized (client-server model)

• Git• Mercurial• Bazzar• Perforce• BitKeeper

Distributed

Page 9: 01 - Introduction to Version Control

9

CONCURRENCY MODELS

merge Release/lock

com

bin

ed

Page 10: 01 - Introduction to Version Control

10

VCS CLASSIFICATION(BY CONCURRENCY MODEL)

• CVS• Git• Mercurial• Bazzar

Merge

• VSS• TFS• Vault

Release/lock

• Subversion• AccuRev• Perforce• ClearCase

Combined

Page 11: 01 - Introduction to Version Control

11

DISTRIBUTED VS CENTRALIZED.

Centralized Distributed

Page 12: 01 - Introduction to Version Control

12

CENTRALIZED MODEL

Page 13: 01 - Introduction to Version Control

13

DISTRIBUTED MODEL

Page 14: 01 - Introduction to Version Control

14

DISTRIBUTED VS CENTRALIZED.DIFFERENCES

Single repository Commit requires connection

(no staging area). Impossible to commit

changes to another user All history in one place Reintegrating the branch

might be a pain Considered to be not so fast

as DVCS Easy access management Chosen for enterprise

development

Multiple repositories Commit does not require

connection (due to staging area)

Possible to commit changes to another user

Impossible to get all history Easier branches management

(especially reintegration) Considered to be faster than

CVCS No access management Chosen for open source

development

Centralized Distributed

Page 15: 01 - Introduction to Version Control

15

DISTRIBUTED MODEL.WORKFLOW #1

Page 16: 01 - Introduction to Version Control

16

DISTRIBUTED MODEL.WORKFLOW #2

Page 17: 01 - Introduction to Version Control

17

CONCURRENCY MODELS.

Everything is read-only Need to edit?

1. Get lock2. Edit3. Release lock

Don’t forget to release lock Otherwise you screwed up Others would not be able

to edit locked files There is a good thing

though You won’t need to merge

You can edit everything Locally And commit changes later Everything will be fine Unless somebody edited the

same files Otherwise you’ll need some luck You are:

1. Lucky (source has been merged automatically)

2. Not lucky (conflict happened)

Conflicts require resolution But it has nothing to do with

conflictology This is about merging manually

Lock-unlock Merge

Page 18: 01 - Introduction to Version Control

18

LOCK-MODIFY-UNLOCK

1. GET LOCK

2. Read4. Locked!

3. Sally tries to edit

It’s impossible to edit until Harry releases the lock

5. Write (save)

6. RELEASE THE LOCK

7. GET LOCK

8. Read

Page 19: 01 - Introduction to Version Control

19

ANTI VSS CAMPAIGN

Page 20: 01 - Introduction to Version Control

20

COPY-MODIFY-MERGE (#1)

Page 21: 01 - Introduction to Version Control

21

COPY-MODIFY-MERGE (#2)

Page 22: 01 - Introduction to Version Control

22

PRACTICAL VERSION CONTROL

What VCS to start with? Subversion Why?

1. It’s most popular

2. Enterprise chooses it

3. EPAM has chosen it too

4. It has almost all what VCS should have

5. It’s possible to use svn and git together if you wish

Are you software developer? Most likely you would need

to deal with subversion

How to start working with subversion?

Get Subversion from official site and install it

Init new repository with svnadmin create command

Create initial project structure (/trunk, /tags/, /branches)

Check created project out to the directory with the source code

Add files with svn add command

Commit files with svn commit command

Page 23: 01 - Introduction to Version Control

23

DOMAIN VOCABULARY.START WORKING WITH VCS

checkincommit pushadd

checkoutpulldelete update,fetch

TO REPOSITORY

FROM REPOSITORY

release lock

get lock

Page 25: 01 - Introduction to Version Control

25

DOMAIN VOCABULARY.DVCS WORKFLOW EXAMPLE

Page 26: 01 - Introduction to Version Control

26

DOMAIN VOCABULARY.RESPOSITORY INVARIANT OPERATIONS

add delete move

rename

svn add, svn delete, svn rename, …

VCS is not able of flexible filesystem changes tracking It is preferably that instead of applying FS commands

corresponding VCS command be applied In other case files will be tracked by VCS as non-versioned or missing.

Subversion does not have specific commands for tags and branches creation, svn copy is used instead.

copy mkdir

Page 27: 01 - Introduction to Version Control

27

DOMAIN VOCABULARY.REPOSITORY LAYOUT

Mainline Tags directoryBranches directory

/trunk /branches /tags

/

Repository

Page 28: 01 - Introduction to Version Control

28

DOMAIN VOCABULARY.CHANGELISTS You have bunch of committed

files Which corresponds to the

standalone feature You might want to track this

fileset Then it’s time to use

changelists It is done by svn changelist

command It sets or unsets the changelist

association of a particular working copy file

You’ll be able to see changelists running svn status command

However, it has limitations

1. Changelists are applicable only to particular working copy

2. Changelists can be assigned only to files

3. At most one changelist assignment on one file

How could it be useful? It helps in logical

organization of files being committed

For example in case, when one large feature should be committed in several steps

Page 29: 01 - Introduction to Version Control

29

Revisions

Working copy (WC)

DOMAIN VOCABULARY.REVISIONS

Page 30: 01 - Introduction to Version Control

30

Tree snapshots

DOMAIN VOCABULARY.CHANGESET AND SNAPSHOT

changeset changeset changeset

Page 31: 01 - Introduction to Version Control

31

DOMAIN VOCABULARY.PATCHING

WC (working copy)

patch

create patch

apply patch

svn diff > patchfile.patch

patch -p0 < patchfile.patch

Page 32: 01 - Introduction to Version Control

32

DOMAIN VOCABULARY.METAINFO

working copyunder subversion

working copy under git

metainfo

WC under subversion has .svn folder in each directory

It allows tracking files status easily But has disadvantages

1. It takes too long to delete WC from FS

2. FTP upload is a headache

3. Web-application deployed together with .svn folders is a security threat

4. It is easy to delete standalone .svn folder and have some problems

Page 34: 01 - Introduction to Version Control

34

DOMAIN VOCABULARY.REVERT AND BLAME How to get rid of recent

changes in WC? Make revert Why not update? Update does not override

WC changes Revert will discard all

changes and return WC to the working revision

Unless you have committed your changes

Revert will not help in that case.

But svn merge –rHEAD:N will

Subversion tracks users committing changes

This could be very helpful sometimes

Because you want to find someone responsible

One can find who changed specific lines

By running svn blame It will show all user logins last

edited specific line of code Developer! Be aware Don’t commit buggy code They’ll find you anyway

Page 35: 01 - Introduction to Version Control

35

SUBVERSION VS CVS

Commits are atomic Renames and copies

are supported Changesets messaging

(per-commit message) Full permissions

support Difficulties with binary

files versioning

Commits are not atomic Renames and copies are

not supported Changes are file-specific

(per-file commit message)

Permissions via hooks

Easy binary files versioning

Subversion CVS

Page 36: 01 - Introduction to Version Control

36

WORKING TOOLS

Subversion client

Command line

GUI

TortoiseSVN

IDE

embedded support

IntelliJ IDEA

Netbeans

Plugins

AnkhSVN

Subclipse

Subversion server

Page 38: 01 - Introduction to Version Control

38

ISN'T VERSION CONTROL TOOCOMPLEX?

Page 39: 01 - Introduction to Version Control

39

ISN'T VERSION CONTROL TOOCOMPLEX?

You can avoid using version control But it can’t last long You will need to collaborate

eventually It might be tricky sometimes But you can avoid most problems Recommendations:

Stick to basic working cycle Learn basic working cycle

commands Practice on sandbox project Read “Version control with

subversion” book DVCSs have more steep learning

curve anyway

Update your working copy svn update

Make changes svn add svn delete svn copy svn move

Examine your changes svn status svn diff svn revert

Merge others' changes svn merge svn resolved

Commit your changes svn commit

Basic working cycle

Page 40: 01 - Introduction to Version Control

40

DOES SCM = VERSION CONTROL?

No Version control is just the main SCM

process What is SCM then? There are several cumbersome

definitions If you want it simple, it is just more

broad topic then just version control And it is one of the CMMI process

areas

Page 41: 01 - Introduction to Version Control

48

RECOMMENDED READING

1. Version control with Subversion By Ben Collins-Sussman, Brian W. Fitzpatrick, C. Michael Pilato

Page 42: 01 - Introduction to Version Control

49

RECOMMENDED READING

2. Version Control with Git by Jon Loeliger

Page 43: 01 - Introduction to Version Control

50

RECOMMENDED READING

3. Pragmatic Version Control: Using Subversion, 2nd edition by Mike Mason

Page 44: 01 - Introduction to Version Control

51

USEFUL LINKS

1. http://svnbook.red-bean.com/ - official subversion reference/book “Version Control with Subversion”

2. http://progit.org/ - book about git “Pro git”3. http://www.ericsink.com/ - one of the best blogs about

version control4. http://www.versioncontrolblog.com/ - another great blog

about version control5. http://better-scm.berlios.de/comparison/comparison.ht

ml - VCS comparison table

6. http://www.cmcrossroads.com/ - biggest resource about SCM

7. http://git-scm.org/course/svn.html - git for svn users