01 - Introduction to Version Control
-
Upload
sergii-shmarkatiuk -
Category
Technology
-
view
1.653 -
download
6
Transcript of 01 - Introduction to Version Control
INTRODUCTION TO VERSION CONTROL
2
PURPOSE OF CURRENT TRAINING
The basics
Making first steps
AND
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
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
5
VERSION CONTROL. SYNONYMS
Source code management
Source control
Revision control
~SCM = Software
configuration management
Files Numbers
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
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
8
VCS CLASSIFICATION(BY REPOSITORY MODEL)
• Subversion• CVS• VSS, TFS, Vault• ClearCase• AccuRev
Centralized (client-server model)
• Git• Mercurial• Bazzar• Perforce• BitKeeper
Distributed
9
CONCURRENCY MODELS
merge Release/lock
com
bin
ed
10
VCS CLASSIFICATION(BY CONCURRENCY MODEL)
• CVS• Git• Mercurial• Bazzar
Merge
• VSS• TFS• Vault
Release/lock
• Subversion• AccuRev• Perforce• ClearCase
Combined
11
DISTRIBUTED VS CENTRALIZED.
Centralized Distributed
12
CENTRALIZED MODEL
13
DISTRIBUTED MODEL
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
15
DISTRIBUTED MODEL.WORKFLOW #1
16
DISTRIBUTED MODEL.WORKFLOW #2
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
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
19
ANTI VSS CAMPAIGN
20
COPY-MODIFY-MERGE (#1)
21
COPY-MODIFY-MERGE (#2)
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
23
DOMAIN VOCABULARY.START WORKING WITH VCS
checkincommit pushadd
checkoutpulldelete update,fetch
TO REPOSITORY
FROM REPOSITORY
release lock
get lock
24
DOMAIN VOCABULARY.CVCS WORKFLOW EXAMPLE
WC (working copy) Repository
svn add
svn commit
svn update
25
DOMAIN VOCABULARY.DVCS WORKFLOW EXAMPLE
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
27
DOMAIN VOCABULARY.REPOSITORY LAYOUT
Mainline Tags directoryBranches directory
/trunk /branches /tags
/
Repository
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
29
Revisions
Working copy (WC)
DOMAIN VOCABULARY.REVISIONS
30
Tree snapshots
DOMAIN VOCABULARY.CHANGESET AND SNAPSHOT
changeset changeset changeset
31
DOMAIN VOCABULARY.PATCHING
WC (working copy)
patch
create patch
apply patch
svn diff > patchfile.patch
patch -p0 < patchfile.patch
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
33
WORKING COPY FILE STATUS
.svn
working revision
timestamp (last updated)
Unchanged, and current
Locally changed, and current
Unchanged, and out of date
Locally changed, and out of date
14 1814 = ~
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
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
36
WORKING TOOLS
Subversion client
Command line
GUI
TortoiseSVN
IDE
embedded support
IntelliJ IDEA
Netbeans
Plugins
AnkhSVN
Subclipse
Subversion server
37
VERSION CONTROL FORNON-PROGRAMMERS There are version control tools even for
designers:
There is version control functionality embedded in:
Adobe version cue PixelNovel Timeline
Microsoft Word OpenOffice.org Writer
38
ISN'T VERSION CONTROL TOOCOMPLEX?
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
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
48
RECOMMENDED READING
1. Version control with Subversion By Ben Collins-Sussman, Brian W. Fitzpatrick, C. Michael Pilato
49
RECOMMENDED READING
2. Version Control with Git by Jon Loeliger
50
RECOMMENDED READING
3. Pragmatic Version Control: Using Subversion, 2nd edition by Mike Mason
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