1. Planning and Managing Software Projects 2011-12
Revision control systems
Emanuele Della Valle, Lecturer: Daniele DellâAglio
http://emanueledellavalle.org
2. Outline
â Why revision control
â Main concepts
â Basic operations
â Checkout
â Commit
â Update
â Branches and tags
Planning and Managing Software Projects â Emanuele Della Valle
3. Motivations
ď§ When working alone
⢠Backup copy Repository
⢠We donât want to
lose the history of
our F F F
code/documents/etc. r5 r4 r3
...
F
r5
Planning and Managing Software Projects â Emanuele Della Valle
4. Motivations
ď§ When working alone
⢠Backup copy Repository
⢠We donât want to
lose the history of
our F F F
code/documents/etc. r5 r4 r3
...
ď§ When working in
team F
⢠Share modifications F r5
easily r5
⢠Support for
cooperative code F
development r5
Planning and Managing Software Projects â Emanuele Della Valle
5. SVN
ď§ There are several version control systems (both open
and closed source)
⢠CVS
⢠SVN
⢠Perforce
ď§ In the following we will consider SVN
⢠The main concept are similar in the other systems
ď§ Several GUIs for SVN are available
⢠TortoiseSVN (Windows)
⢠RabbitVCS (Linux)
⢠Subclipse/Subversive (Eclipse plug-ins)
⢠...
Planning and Managing Software Projects â Emanuele Della Valle
6. Some definitions
Repository
Repository
(the location
where files
are stored)
F F F ...
r5 r4 r3
F
r5
Planning and Managing Software Projects â Emanuele Della Valle
7. Some definitions
Repository
Repository
F F F ...
r5 r4 r3
Revision
F
(Version)
r5
(an identifier
associated to
each version of
the file)
Planning and Managing Software Projects â Emanuele Della Valle
8. Some definitions
Repository
Repository
Head
(the most
recent version F F F ...
of the files) r5 r4 r3
Revision
F
(Version)
r5
Planning and Managing Software Projects â Emanuele Della Valle
9. Some definitions
Repository
Repository
Head
F F F ...
r5 r4 r3
Revision
F
(Version)
r5
Working copy
(copy of the
files on the
local machine)
Planning and Managing Software Projects â Emanuele Della Valle
10. Main operations
ď§ Check-out: initial Repository
creation of the working
copy from the repository
F F F ...
r5 r4 r3
F
r5
svn checkout <URL>
Planning and Managing Software Projects â Emanuele Della Valle
11. Main operations
ď§ Check-out: initial Repository
creation of the working
copy from the repository
F F F ...
r5 r4 r3
F
r5
Planning and Managing Software Projects â Emanuele Della Valle
12. Main operations
ď§ Check-out: initial Repository
creation of the working
copy from the repository
F F F ...
r5 r4 r3
F
r5*
Planning and Managing Software Projects â Emanuele Della Valle
13. Main operations
ď§ Check-out: initial creation Repository
of the working copy from
the repository
ď§ Check-in (Commit): F F F ...
r5 r4 r3
update of the HEAD
revision with the working
copy F
r5*
F
r5*
svn commit
Planning and Managing Software Projects â Emanuele Della Valle
14. Main operations
ď§ Check-out: initial creation Repository
of the working copy from
the repository
ď§ Check-in (Commit): F F F ...
r6 r5 r4
update of the HEAD
revision with the working
copy
F
r6
svn commit
Planning and Managing Software Projects â Emanuele Della Valle
15. Main operations
ď§ Check-out: initial creation Repository
of the working copy from
the repository
ď§ Check-in (Commit): F F F ...
r6 r5 r4
update of the HEAD
revision with the working
copy
F
r6*
Planning and Managing Software Projects â Emanuele Della Valle
16. Main operations
ď§ Check-out: initial creation Repository
of the working copy from
the repository
ď§ Check-in (Commit): F F F ...
r6 r5 r4
update of the HEAD
revision with the working
copy F
r6
ď§ Revert: drop the
modification on the F
working copy and reset r6*
the files to HEAD
svn revert <file>
Planning and Managing Software Projects â Emanuele Della Valle
17. Main operations
ď§ Check-out: initial creation Repository
of the working copy from
the repository
ď§ Check-in (Commit): F F F ...
r6 r5 r4
update of the HEAD
revision with the working
copy
ď§ Revert: drop the
modification on the F
working copy and reset r6
the files to HEAD
Planning and Managing Software Projects â Emanuele Della Valle
18. Main operations
ď§ Check-out: initial creation Repository
of the working copy from
the repository
ď§ Check-in (Commit): F F F ...
r6 r5 r4
update of the HEAD
revision with the working
copy
ď§ Revert: drop the
modification on the F
working copy and reset r6*
the files to HEAD
Planning and Managing Software Projects â Emanuele Della Valle
19. Main operations
ď§ Check-out: initial creation Repository
of the working copy from
the repository
ď§ Check-in (Commit): F F F ...
r9 r8 r7
update of the HEAD
revision with the working
copy
ď§ Revert: drop the
modification on the F
working copy and reset r6*
the files to HEAD
Planning and Managing Software Projects â Emanuele Della Valle
20. Main operations
ď§ Check-out: initial creation Repository
of the working copy from
the repository
ď§ Check-in (Commit): F F F ...
r9 r8 r7
update of the HEAD
revision with the working
copy F
r9
ď§ Revert: drop the
modification on the F
working copy and reset r6*
the files to HEAD
ď§ Update: merge HEAD svn update
and the working copy
Planning and Managing Software Projects â Emanuele Della Valle
21. Main operations
ď§ Check-out: initial creation Repository
of the working copy from
the repository
ď§ Check-in (Commit): F F F ...
r9 r8 r7
update of the HEAD
revision with the working
copy
ď§ Revert: drop the
modification on the F
working copy and reset r9*
the files to HEAD
ď§ Update: merge HEAD
and the working copy
Planning and Managing Software Projects â Emanuele Della Valle
22. Main operations
ď§ The main commands we see in the previous slides are
⢠svn checkout <URL>
⢠svn commit
⢠svn revert <file>
⢠svn update
ď§ Two additional important commands are:
⢠svn add <file> [<file>...]
⢠svn delete <file> [<file>...]
ď§ add and delete respectively adds and removes
files in/from the working copy
⢠Those operations should then be confirmed (with a
commit) or cancelled (through a revert)
Planning and Managing Software Projects â Emanuele Della Valle
23. Conflicts
ď§ A conflict occours when the system is unable to
automatically merge a working copy with the HEAD
revision
ď§ Usually this issue can be found when developing in
team
ď§ Example:
⢠Two users check-out the same release
⢠They both modify the same files in their working copy
⢠The first user commits his working copy
⢠The second one tries to commit and the system is
unable to merge
ď§ Best practice: before committing, do an update and
resolve the conflict locally!
Planning and Managing Software Projects â Emanuele Della Valle
24. Branches
ď§ A branch is a copy of the project
⢠The original is stored in the Trunk
ď§ It is maintained separately
Trunk
Branch 2
Branch 1
ď§ There is only one trunk, while there are zero or more
branches
⢠Example: team works in separated branches to include
new features
ď§ SVN doesnât have a dedicated command to create
branches:
svn copy <from> <to>
Planning and Managing Software Projects â Emanuele Della Valle
25. Merges
ď§ Modifications done in the branches should then be
applied to the trunk/other branches
ď§ In general, merge in SVN:
⢠Compares two different trees
⢠Extract the differences between the two trees
⢠Differences are applied to the working copy
ď§ The merge command is
svn merge âr<from>:<to> <url>
ď§ As other operations, merge is done locally
⢠It should be committed (or reverted)
Planning and Managing Software Projects â Emanuele Della Valle
26. Tags
ď§ Tags identify relevant revisions
ď§ Each tag is a label associated to a revision
ď§ Tags can be used to identify
⢠Milestones
⢠Software releases
Repository
release-1.1 release-1.0
F
FF F
FF F
FF F
FF F
FF F
FF ...
r9
r8
r8 r8
r8
r8 r7
r8
r8 r6
r8
r8 r5
r8
r8 r4
r8
r8
Planning and Managing Software Projects â Emanuele Della Valle
27. Distributed version control systems
ď§ Distributed version control systems are an alternative
to che (centralized) version control systems
ď§ They adopt a peer to peer approach instead of a
server-client one
⢠Several distributed repositories
ď§ Examples of distributed version control systems
⢠Git
⢠Mercurial
⢠Baazar
Planning and Managing Software Projects â Emanuele Della Valle
28. Useful links
ď§ Version Control with Subversion http://svnbook.red-
bean.com/
ď§ A Visual Guide to Version Control
http://betterexplained.com/articles/a-visual-guide-to-
version-control/
ď§ Pro Git http://git-scm.com/book
Planning and Managing Software Projects â Emanuele Della Valle