User Training
Adjusted for the VU Software Configuration Management course
All SubTrain materials are published under the Creative Commons Attribution License and contain material from other works published under the same
license. To view a copy of this license, visit http://creativecommons.org/licenses/by/2.0/ or send a letter to Creative Commons, 559 Nathan
AbbottWay, Stanford, California 94305, USA. Special thanks to the authors of the comprehensive subversion book book Version Control with
Subversion by Ben Collins-Sussman, Brian W. Fitzpatrick, and C. Michael Pilato. You are free to adjust the materials to your needs. Please respect
our work by adding the SubTrain logo to your slides.
Agenda
1. Part I
a)
b)
c)
Architecture of Subversion
The working cycle
Dos and don'ts
2. Part II
a)
b)
c)
Team Work I
Locking
Tagging
3. Part III
a)
b)
c)
Branching
Merging
Team Work II
References
Part I
Architecture of Subversion
The working cycle
Dos and don'ts
Subversion Architecture
Architectural Overview
Repository Layout
Global Revisions
Subversion Architecture
Overview
Client Interface
Repository Interface
FSFS
Apache
mod_dav
GUI client
apps
Repository
access
mod_dav_svn
DAV
Internet
Client
Library
svnserve
SVN
Commandline
client apps
Subversion
Repository
Local
Working Copy
Management
Library
Berkley DB
Subversion Architecture
Access URLs
file://
Direct repository access to local or network drive.)
http://
Access via WebDAV protocol to Subversion-aware Apache server.)
https://
Same as http://, but with SSL encryption.
svn://
Unauthenticated TCP/IP access via custom protocol to an svnserve server.
svn+ssh://
Authenticated, encrytped TCP/IP access via custom protocol to an svnserve server.
Subversion Architecture
Access URLs
file://hostname/path/to/repos
file:///path/to/repos
On Windows you have to specify the drive where to find the
repository:
file:///X:/path/to/repos
Subversion Architecture
Repository Layout
Root
Root
trunk
Project 1
trunk
Project 1
tags
Project 2
branches
tags
Project 1
Project 2
Project 2
trunk
branches
tags
branches
Project 1
Project 2
Subversion Architecture
Repository Layout
Root
Project 1
trunk
tags
Releases
Preparation of releases, bug fixing
branches
Project 2
trunk
tags
branches
10
Subversion Architecture
The revision numbers
0
11
Subversion Architecture
The revision numbers
Every commit produces a new unique revision number.
The revision numbers are unique per repository.
A commit in Subversion is atomic just like a database transaction
(technically there is no difference).
12
svn commit
svn checkout
svn update
106
100
Merge your changes
Resolve conflicts
Make changes
svn diff
svn resolved
Subversion
Repository
svn add
svn move
svn delete
105
svn status -u
14
Repository Server
15
16
17
Repository Server
18
19
20
Status normal
Locked
Added file/directory
Modified
deleted file/directory
Read only
21
22
23
24
25
26
27
If you use the right mouse button you will see the context menu for
moving and and copying files.
28
29
move
delete
copy
mkdir
30
add
remove
copy
delete
mkdir
31
33
Removed line 4
Inserted line 10 in file etc.
The above is the job of Subversion not yours ;-)
Often Log messages have to follow policies given by the company. Pay
attention to yours.
34
Exercises
Each person creates a repository
The groupaccount is \\solo\pracscm
Use your id as repository name
Practice the discussed SubVersion concepts
Part II
Team Work I
Locking
Tagging
Team Work I
Multiple Working Copies
Managing Conflicts
Team Work I
Multiple Working Copies
38
Team Work I
Multiple Working Copies
Check out the actual state of the project from the repository. (WC
working copy)
39
Team Work I
Conflicts
Sally and Harry check out the same project from the repository.
checkout
p1
checkout p1
Harry
Sally
40
Team Work I
Conflicts
Both begin to edit the same file in their copies and their changes
overlap.
Harry
Sally
41
Team Work I
Conflicts
Sally changes the README file.
42
Team Work I
Conflicts
Sally commits her work first.
commit
Harry
Sally
43
3 Team work I
Conflicts
Harry has changed the README file as well.
44
Team Work I
Conflicts
Harry tries to commit his work after Sally.
Commit will show a message:
Out of date...
Harry
Sally
45
Team Work I
Conflicts
Harry has to update his local working copy to get Sallys changes.
Harry
Sally
46
Team Work I
Conflicts
How to solve a conflict?
No tool is able to handle the conflict.
Only humans are capable of understanding and making the
necessary intelligent choices.
The two members (in the example) have to discuss the conflict as
well as possible solutions.
47
Team Work I
Conflicts
2. filename.rOLDREV
This is the file that was the BASE revision before you updated your working copy.
That is, the file that you checked out before you made your latest edits.
3. filename.rNEWREV
This is the file that your Subversion client just received from the server when you
updated your working copy. This file corresponds to the HEAD revision of the
repository.
48
Team Work I
Conflicts
Edit-Conflict of TortoiseSVN (accessible via context menu):
49
Team Work I
Conflicts
Conflict has been solved by a human being. It is clear now which part
of the code or documentation is the right one.
Before you can check in the merged file you have to tell Subversion
that the conflict has been solved.
50
Team Work I
Conflicts
You have to tell Subversion that you solved the conflict with:
If you want to go through a whole directory of files, use the -recursive flag.
51
Team Work I
Conflicts
Harry can now commit his changes and the merged files.
commit
Harry
Sally
52
Team Work I
Conflicts
In the last step Sally has to update her local working copy.
update
Harry
Sally
53
Team Work I
Conflicts
Reasons for Conflicts:
Two members of a team work on the same files and overlapping areas.
In the end it can be reduced to one critical factor:
User communication.
It must be clear who is working on what.
54
Locking
Locking Models
Optimistic Locking
Pessimistic Locking
Locking
Copy-Edit-Merge Model
This means:
But there are situations in which this model might cause problems.
56
Locking
The Two Models
You cant use the copy-modify-merge model with files like Word or
Excel (this applies for other types too) because you cant merge those
files.
So you have to go another way. There are two possible solutions:
The first one is to explicit lock the file before you start to edit a file of the
above type (called optimistic locking).
57
Locking
Optimistic Locking
Before you start working on a non-mergeable file (like Word etc.) you
Advantages:
Its simple.
Its error-prone.
Disadvantages:
You miss to unlock a file e.g. before you are going on vacation etc.
58
Locking
Optimistic Locking
59
Locking
Optimistic Locking
60
Locking
Optimistic Locking
61
Locking
Optimistic Locking
Try to lock an already locked file with TortoiseSVN:
62
Locking
Optimistic Locking
Check if a file has been locked on the server:
63
Locking
Optimistic Locking
To unlock a file just type the svn unlock command with a particular
destination.
Or it will be unlocked automatically if you commit your changes back
to the repository.
64
Locking
Pessimistic Locking
Pessimistic-Locking:
You can put a special property to a file svn:needs-lock with any value.
The result is if you check out a file with the property set, the file will be
marked as read-only.
Advantage:
The application you use with this type of file will give you a reminder about
the read-only state.
Disadvantage:
The system isn't flawless, either. It's possible that even when a file has the
65
Tagging
Why Tagging
Tagging by Copy
Tagging
Why Tagging?
Why do we need tags?
67
Tagging
Why Tagging?
If we take a look at the architecture chapter we really dont need a
special tag. We only need to write down the revision number.
But human beings have other requirements.
They like to have self-explanatory tag names which are more handy.
But the question is:
68
Tagging
Tagging by Copy
Root
Project 1
trunk
69
Tagging
Tagging by Copy via TortoiseSVN
Create a tag for the trunk development via TortoiseSVN:
70
Tagging
Tagging by Copy via TortoiseSVN
Create a tag for the trunk development via TortoiseSVN:
71
Exercises
Work in groups of 2 persons on a single repository
Practice the discussed SubVersion concepts
Part III
Branching
Merging
Team Work II
Branching
Why Branching
Creating Branches
Using Branches
Branches
Why Branching?
Assume the following situation:
You have created a great product and it has been delivered to your
customer.
Before you delivered the product you have created a tag, let us name it
Release 1.0.0
Your current development crew is working on Release 1.1.0 with new
features.
Your customer calls you and reports that he has found a bug in your
software.
75
Branches
Why Branching?
The development has continued after the release of RELEASE 1.0.0
You want to fix the bug
to satisfy your customer!
In your current development
RELEASE 1.0.0
you have enhanced many of
the products functions
but you dont want to deliver
a product with more
features and you havent
finished testing yet.
How to solve this situation?
Main line of development
76
Branches
Why Branching?
Based on the tag youve created during the delivery you can check out
the exact state of the delivery.
You create a Branch to
fix the bug in the software.
RELEASE 1.0.0
After you have fixed the bug
you can tag the Branch and
BUGFIX_BRANCH
deliver another version to the
customer.
Your customer is satisfied
RELEASE
that you fixed the bug
1.0.1
so fast.
You havent disturbed the
current development.
77
Branches
Creating Branches
Root
Calc
trunk
branches
my-calc branch
Paint
trunk
branches
Polarion Software 2007
78
Branches
Using Branches
branches/release-candidates
branches/sub-projects
branches/user-branches
79
Branches
Using Branches
You would like to work on the branch to fix the bug.
You can do it in two ways:
RELEASE 1.0.0
BUGFIX_BRANCH
RELEASE
1.0.1
80
Branches
Using Branches
Create a branch from a release tag via TortoiseSVN:
81
Branches
Using Branches
82
Branches
Using Branches
83
Branches
Using Branches
Fix the bug through doing the necessary modifications and finally
commit the changes to the branch.
After having fixed the bug on the branch create a tag to mark the
new release which can be delivered to the customer.
84
Merging
Merging from a Branch
Merge Tracking
Best Practices
Merging
Merging From a Branch
Whats with the bug you've fixed on the bug-fix-branch?
What about your current development?
You have to merge the
changes made in the branch
back to the main line.
RELEASE 1.0.0
BUGFIX_BRANCH
267
RELEASE
1.0.1
Merge back
86
Merging
Merging From a Branch via
TortoiseSVN
87
Merging
Merging From a Branch via
TortoiseSVN
88
Merging
Merging From a Branch via
TortoiseSVN
89
Merging
Merge Tracking
Merge tracking:
Subversion does not have any function to track merges which have been
done e.g. to prevent you to merge a branch a second time
90
Merging
Merge Tracking
Best Practices:
91
Merging
Warning
WARNING:
WARNING
From the technical view a branch and a tag are the same.
BUT:
92
Team Work II
Developer Branches
Feature Branches
Team Work II
Developer Branches
Main line
Member 2
Member 1
94
Team Work II
Developer Branches
stability.
Every team member can work in its own environment.
Disadvantages:
Sometimes the mainline and the branch will diverge if the branch lives
too long.
95
Team Work II
Feature Branches
Main line
Feature 2
Feature 1
96
Exercises
Work in groups of 4 persons on a single repository
Practice the discussed SubVersion concepts