8/6/2019 Subversion_Training - User - Tortoise
1/116
Polarion Software
SUBTRAIN
Subversion User Training
All SubTrain materials are published under the C reative Commons Attribution License and contain material from other works published under the same license. To view a copy of this license, visithttp://creativecommons.org/licenses/by/2.0/ or send a letter to Creative Commons, 559 Nathan AbbottWay, Stanford, California 94305, U SA. Special thanks to the authors of the comprehensive Subversion book book VersionControl 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.
Polarion Software
8/6/2019 Subversion_Training - User - Tortoise
2/116
Polarion Software Subtrain SVN User training www.polarion.com
software is hardDonald E. Knuth, Selected Papers on Computer Science
Preface
2
8/6/2019 Subversion_Training - User - Tortoise
3/116
Introduction
Architecture
Working cycle
Locking
SVN Properties
Managing versions
Branching strategies
MergingConfiguration
8/6/2019 Subversion_Training - User - Tortoise
4/116
Introduction
8/6/2019 Subversion_Training - User - Tortoise
5/116
Polarion Software Subtrain SVN User training www.polarion.com
Introduction What is Subversion?
5
You may be interested in
Subversion Training and
Consulting Services from
Polarion Software's
Subversion experts!
8/6/2019 Subversion_Training - User - Tortoise
6/116
Polarion Software Subtrain SVN User training www.polarion.com
Introduction Testimonials
6
http://svn.apache.org/repos/asf
Stuart Robertson of AbsoluteSystems, IncIn the last 4 months we havemigrated all of our internal productsource repositories from XXX toSVN []Our largest SVN repository is now3.7GB and currently has 68806
revisions. We are running SVN1.0.1 + Apache 2.0.48 on Linux. ...SVN is a superb piece of work, andit is a *huge* step forward fromXXX. To put things in perspective...previously we had 26 XXXdatabases for one product
More testimonials on:http://subversion.tigris.org/testimonials.html
Gustavo Niemeyer ofConectiva LinuxShortening the history a lot, 1year and 6 months ago, the firstrevision was committed into ourrepository.[...]Since then, 5 complete
Conectiva Linux distributionswere committed into therepository, and every singleupdate in the distribution is doneusing Subversion. We've alreadysurpassed 50000 revisions, in a30GB repository. Even thoughwe have had space, memory,and other kinds of problemsaround the repository, I'm proud
to say we have never lost asingle bit of information sincethen.
933300
Revisions
813637
8/6/2019 Subversion_Training - User - Tortoise
7/116
Architecture
8/6/2019 Subversion_Training - User - Tortoise
8/116
8/6/2019 Subversion_Training - User - Tortoise
9/116
Polarion Software Subtrain SVN User training www.polarion.com
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, encrypted TCP/IP access via custom protocol to an svn server.
Architecture Access URLs
9
8/6/2019 Subversion_Training - User - Tortoise
10/116
Polarion Software Subtrain SVN User training www.polarion.com
file://hostname/path/to/repos
On local machines the hostname part must either be absent orlocalhost.
This results in a path like this one:
file:///path/to/repos
On Windows you have to specify the drive where to find the repository:
file:///X:/path/to/repos
Architecture Access URLs
10
8/6/2019 Subversion_Training - User - Tortoise
11/116
Polarion Software Subtrain SVN User training www.polarion.com
Architecture The revision numbers
11
10
0 1 2 3 4
1
1
1
1
2
1
1
1
1
22
3
1
1
1
1
32
3
3
4
4
4
1
1
32
3
3
atomic commit gives
Subversion power to version
code, documents, requirements,
tests, graphics, ...
8/6/2019 Subversion_Training - User - Tortoise
12/116
Polarion Software Subtrain SVN User training www.polarion.com
Architecture The working copy
12
repositoryworking copy
Checking out creates a working copyof a specific revision of the repository
22
10
3
.svn
.svn
SVN's config data. Donot edit these folders!
8/6/2019 Subversion_Training - User - Tortoise
13/116
8/6/2019 Subversion_Training - User - Tortoise
14/116
Polarion Software Subtrain SVN User training www.polarion.com
Architecture Repository Layout 2/3
14
trunk/tags/branches on root;
each module will be tagged separately
checkout of all modules is possiblecommits can span multiple modulestags can not span multiple modules in single commit
(workaround by 3rd party tools)
8/6/2019 Subversion_Training - User - Tortoise
15/116
Polarion Software Subtrain SVN User training www.polarion.com
Architecture Repository Layout 3/3
15
trunk/tags/branches on root
all modules will be tagged
checkout of all modules is possiblecommits can span multiple modulestags can span multiple modules in single commitmaybe difficult to determine relevant modules of a tag
8/6/2019 Subversion_Training - User - Tortoise
16/116
8/6/2019 Subversion_Training - User - Tortoise
17/116
Polarion Software Subtrain SVN User training www.polarion.com
The Working Cycle -single person-
17
svn checkoutsvnupdate
get content
svnaddsvnmovesvndelete
Make changes
svn commit
Submit your changes
100 101
SubversionRepository
8/6/2019 Subversion_Training - User - Tortoise
18/116
Polarion Software Subtrain SVN User training www.polarion.com
The Working Cycle Check Out
18
A check out will transfer the projects contentfrom the repository serverto the client machine.
Repository ServerThe client machine
Check out a working copy
2
10
2
8/6/2019 Subversion_Training - User - Tortoise
19/116
Polarion Software Subtrain SVN User training www.polarion.com
The Working Cycle Check Out
19
sparse checkout
svn checkout file:///c:/subtrain/repo/trunk c:\subtrain\harry
8/6/2019 Subversion_Training - User - Tortoise
20/116
Polarion Software Subtrain SVN User training www.polarion.com
The Working Cycle Sparse Check Out
20
Fully recursive Immediate children,including folders
Only file children only this item
Important for restructuring repository (eg. /branches directory)!
8/6/2019 Subversion_Training - User - Tortoise
21/116
Polarion Software Subtrain SVN User training www.polarion.com
The Working Cycle TortoiseSVN Icon Overlays
21
normal
modified
added
non-versioned
read only
locked
ignored
deleted conflict
Where is Polar
Bear icon? :)
svnstatus c:\subtrain\harry
8/6/2019 Subversion_Training - User - Tortoise
22/116
Polarion Software Subtrain SVN User training www.polarion.com
The Working Cycle Adding and moving files
22
add folder/files via context menu to SVNmove or copy folder/files viadragging with right mouse button
svnadd c:\subtrain\harry\li bs svnmove
c:\subtrain\harry\library.txt
c:\subtrain\harry\libs\library.txt
8/6/2019 Subversion_Training - User - Tortoise
23/116
Polarion Software Subtrain SVN User training www.polarion.com
The Working Cycle Deleting files
23
files will immediately be removedfrom your working copyfolders will be marked as deleted
until commit
svndelete c:\subtrain\harry\file2del.txt
8/6/2019 Subversion_Training - User - Tortoise
24/116
Polarion Software Subtrain SVN User training www.polarion.com
The Working Cycle Comparing files
24
svndiff c:\subtrain\harry\libs\library.txt
8/6/2019 Subversion_Training - User - Tortoise
25/116
Polarion Software Subtrain SVN User training www.polarion.com
The Working Cycle Commit
25
A commit transfers the projects modified filesfrom the client machine to the repository server.
Repository ServerThe client machine
commit changes to repository
21
0
2
3
8/6/2019 Subversion_Training - User - Tortoise
26/116
Polarion Software Subtrain SVN User training www.polarion.com
The Working Cycle Commit
26
svn commit -m"initial project" c:\subtrain\harry
8/6/2019 Subversion_Training - User - Tortoise
27/116
Polarion Software Subtrain SVN User training www.polarion.com
The Working Cycle Show log / show history
27
svn log c:\subtrain\harry
8/6/2019 Subversion_Training - User - Tortoise
28/116
Polarion Software Subtrain SVN User training www.polarion.com
The Working Cycle Warning
28
WARNINGWARNING
Never move, delete, copy files orcreate directories without theSubversion commands:
svn move svn delete
svn copy
svn mkdir
Easy if using TortoiseSVN as it isintegrated directly in WindowsExplorer, or Subversive integratedinto Eclipse, or Polarion Track &Wiki
8/6/2019 Subversion_Training - User - Tortoise
29/116
8/6/2019 Subversion_Training - User - Tortoise
30/116
Polarion Software Subtrain SVN User training www.polarion.com
The Working Cycle Exercise II: restructuring files
30
rename main_e.txt into main.txt
create a folder named libs and add it to SVN
move library.txt into libs (modify main.txt accordingly!)
commit your changes as restructuring project
8/6/2019 Subversion_Training - User - Tortoise
31/116
8/6/2019 Subversion_Training - User - Tortoise
32/116
Polarion Software Subtrain SVN User training www.polarion.com
The working Cycle Teamwork
32
svn checkoutsvnupdate
get content
svnaddsvnmovesvndelete
Make changes
svnstatus -u
See what was changedin the repository in the meantime
svnupdate
Update your local copy
svndiffsvn resolved
Merge your changesResolve conflicts
svn commit
Submit your changes
105
100
106
SubversionRepository
8/6/2019 Subversion_Training - User - Tortoise
33/116
Polarion Software Subtrain SVN User training www.polarion.com
The working Cycle Teamwork 1/5
33
Harry and Sally both check out adirectory in their repository.
Both get the same revision of thisparticular directory copied to theirmachine.
Theirworking copy.
8/6/2019 Subversion_Training - User - Tortoise
34/116
Polarion Software Subtrain SVN User training www.polarion.com
The working Cycle Teamwork 2/5
34
Harry and Sally change
different lines in the same file.
Sally commits first and
creates revision 2.
8/6/2019 Subversion_Training - User - Tortoise
35/116
Polarion Software Subtrain SVN User training www.polarion.com
The working Cycle Teamwork 3/5
35
As Harry tries to commit hischanges, her receives an
error telling him that hisworking copy is probably outof date.
His commit fails.
Polarion Softwares integratedWiki removes the informationbarrier between tracker,collaboration tool, and VCS.
8/6/2019 Subversion_Training - User - Tortoise
36/116
Polarion Software Subtrain SVN User training www.polarion.com
The working Cycle Teamwork 4/5
36
Harry has to update his workingcopy and SVN integrates Sallies
changes into his working copy.
8/6/2019 Subversion_Training - User - Tortoise
37/116
Polarion Software Subtrain SVN User training www.polarion.com
The working Cycle Teamwork 5/5
37
Now Harry is ready to
commit his changes.
He creates revision 3.
8/6/2019 Subversion_Training - User - Tortoise
38/116
8/6/2019 Subversion_Training - User - Tortoise
39/116
Polarion Software Subtrain SVN User training www.polarion.com
The working Cycle Exercise III: teamwork
39
check out trunk a second time into a folder called Sally
change the third line in Harry's working copy
commit Harry's changes as Harry's 1st changes in our library
change the first line in Sally's working copy and try to commit
update Sally's working copy
commit Sally's changes as Sally's 1st changes added
'
'
8/6/2019 Subversion_Training - User - Tortoise
40/116
Polarion Software Subtrain SVN User training www.polarion.com
Teamwork Conflicts
40
How does a conflict evolve?
This is a good
question!
8/6/2019 Subversion_Training - User - Tortoise
41/116
Polarion Software Subtrain SVN User training www.polarion.com
Teamwork Conflicts 1/6
41
Harry and Sally check out
their repo again.
This time they change the
same lines in this particular file.
8/6/2019 Subversion_Training - User - Tortoise
42/116
8/6/2019 Subversion_Training - User - Tortoise
43/116
Polarion Software Subtrain SVN User training www.polarion.com
Teamwork Conflicts 3/6
43
As Harry tries to commit hischanges, he receives the well
known out-of-date-error and anadvice to update his working copy.
8/6/2019 Subversion_Training - User - Tortoise
44/116
Polarion Software Subtrain SVN User training www.polarion.com
Teamwork Conflicts 4/6
44
As both Harry and Sally had
changed the same lines, SVN
cannot decide how to merge
Harry's changes and the changes
from the repository.
So SVN raises a conflict which
must be resolved by Harry.
8/6/2019 Subversion_Training - User - Tortoise
45/116
Polarion Software Subtrain SVN User training www.polarion.com
Teamwork Conflicts 5/6
45
Harry cannot commit a file which
is in a conflicted state.
Harry has to resolve the conflict/s
and then notifies SVN viasvn resolved
8/6/2019 Subversion_Training - User - Tortoise
46/116
Polarion Software Subtrain SVN User training www.polarion.com
Teamwork Conflicts 6/6
46
Harry commits his changes andcreates a new revision.
8/6/2019 Subversion_Training - User - Tortoise
47/116
Polarion Software Subtrain SVN User training www.polarion.com
The Working Cycle Exercise IV: conflicts
47
update Harry's working copy to get Sally's last changes
change the fifth (last) line in Harry's working copy
commit Harry's changes as Harry's 2nd changes in our library
change the fifth (last) in Sally's working copy and try to commit
update Sally's working copy
edit and resolve the conflict:
commit Sally's changes as Sally's changes added
'
'
'
'
'
'
'
'
'
'
8/6/2019 Subversion_Training - User - Tortoise
48/116
Locking
8/6/2019 Subversion_Training - User - Tortoise
49/116
8/6/2019 Subversion_Training - User - Tortoise
50/116
O ti i ti L ki
8/6/2019 Subversion_Training - User - Tortoise
51/116
Polarion Software Subtrain SVN User training www.polarion.com
To lock a file just type the svn lock command with a particulardestination.
Use a descriptive lock message to tell your co-workers why youneed this lock
LockingOptimistic Locking:
How to lock a file
51
svn lock m I needto lock this file c:\subtrain\harry\main.txt
8/6/2019 Subversion_Training - User - Tortoise
52/116
8/6/2019 Subversion_Training - User - Tortoise
53/116
Polarion Software Subtrain SVN User training www.polarion.com
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 bemarked 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 property, the read-only reminder won't alwayswork. Sometimes applications misbehave and hijack theread-only file, silently allowing users to edit and save the fileanyway. Unfortunately there's not much Subversion can doabout this.
Locking Pessimistic Locking
53
8/6/2019 Subversion_Training - User - Tortoise
54/116
Polarion Software Subtrain SVN User training www.polarion.com
Locking Pessimistic Locking
54
svnpropsetsvn:needs-lock T c:\subtrain\harry\main.txt
8/6/2019 Subversion_Training - User - Tortoise
55/116
Polarion Software Subtrain SVN User training www.polarion.com
Locking Take a look on the server
55
svnstatus -uv c:\subtrain\harry
8/6/2019 Subversion_Training - User - Tortoise
56/116
Exercise VI:
8/6/2019 Subversion_Training - User - Tortoise
57/116
Polarion Software Subtrain SVN User training www.polarion.com
set property svn:needs-lock on main.txt in Sally's working copy
commit as "enabling pessimistic locking"
update Harry's working copy
try to change main.txt in Harry's working copy
get lock on main.txt in Sally's working copy
change Sally's main.txt
try to get lock on main.txt in Harry's working copy
commit Sally's working copy as new changes to locked file
remove svn:needs-lock and commit as disabling pessimistic locking
LockingExercise VI:
pessimistic locking
57
8/6/2019 Subversion_Training - User - Tortoise
58/116
SVN properties
8/6/2019 Subversion_Training - User - Tortoise
59/116
Polarion Software Subtrain SVN User training www.polarion.com
Subversion provides interfaces for adding, modifying, and removing
versioned metadata on each of your versioned directories and files.
We refer to this metadata as properties, which exist as two-column tables
that map property names to values attached to each item in your working
copy
The names and values of the properties can be whatever you want them to
be, with the constraint that the names must contain only ASCII characters
Properties are versioned just like the textual contents of your files.You can
modify, commit, and revert property changes
Every property-change must be committed just as the resources that exist
in your working copy
SVN properties Overview
59
8/6/2019 Subversion_Training - User - Tortoise
60/116
Polarion Software Subtrain SVN User training www.polarion.com
svn:eol-style
svn:executable
svn:externals
svn:ignore
svn:keywords
svn:needs-lock
svn:mime-type
svn:merge-info
SVN properties
60
do not edit this property!
Did you know?Polarion Software providessoftware and systemsdevelopment solutions toover 500,000 licensed endusers in over 65 countries.You may be interested inour solutions.
8/6/2019 Subversion_Training - User - Tortoise
61/116
Polarion Software Subtrain SVN User training www.polarion.com
Properties List Properties
61
You can get a list of properties using the following command:
svn proplist --verbose destinationdestination
1) The Subversion proplist-command.
2) Print out much information (verbose).
3) The file/directory.
8/6/2019 Subversion_Training - User - Tortoise
62/116
8/6/2019 Subversion_Training - User - Tortoise
63/116
Polarion Software Subtrain SVN User training www.polarion.com
Properties Set Properties
63
You can set a property using the following command:
svn propset propertynamepropertyname valuevalue destinationdestination
1) The Subversion propset-command.
2) The name of the property e.g. svn:ignore.
3) The value for the property.
4) The file/directory for which the property should be set.
8/6/2019 Subversion_Training - User - Tortoise
64/116
Polarion Software Subtrain SVN User training www.polarion.com
Properties Delete Properties
64
You can set a property using the following command:
svn propdel propertynamepropertyname destinationdestination
1) The Subversion propdel-command.
2) The name of the property e.g. svn:needs-lock.
3) The file/directory for which the property should be set.
8/6/2019 Subversion_Training - User - Tortoise
65/116
Polarion Software Subtrain SVN User training www.polarion.com
Properties TortoiseSVN Properties
65
Special SVN Properties:
8/6/2019 Subversion_Training - User - Tortoise
66/116
Polarion Software Subtrain SVN User training www.polarion.com
PropertiesSpecial SVN Properties:
ignore
66
svn:ignore
Tell Subversion which files and subdirectories to ignore Equivalent to CVSs .cvsignore file
You can define a special file/directory or patterns defining thefiles/directories which will be ignored.
You can suppress the exclusion if you use the --no-ignore flag for the svnstatus command.
Special SVN Properties:
8/6/2019 Subversion_Training - User - Tortoise
67/116
Polarion Software Subtrain SVN User training www.polarion.com
svn:keywords Keyword substitution in files.
The only available keyword substitutions are: LastChangedDate, LastChangedRevision LastChangedBy,HeadURL, Id, Header
Only keywords listed in the svn:keywords property value are replaced inthe file
$LastChangedDate: 2008-07-22 21:42:37 -0700 (Sun, 22 Jul 2008) $$LastChangedRevision: 14$$LastChangedBy: sally $$HeadURL: file:///c:/subtrain/repo/trunk/main.txt $$Id:main.txt 14 2008-07-28 21:30:43Z sally $$Header: file:///c:/subtrain/repo/trunk/main.txt 148
2008-07-28 21:30:43Z sally $
Special fixed width keyword substitutions:use $Author:: $ instead of $Author$
PropertiesSpecial SVN Properties:
keywords
67
Special SVN Properties:
8/6/2019 Subversion_Training - User - Tortoise
68/116
Polarion Software Subtrain SVN User training www.polarion.com
What is the format of timestamps in Subversion?
Subversion will always store timestamps inUTC(Coordinated Universal Time)
$Id:calc.c 148 2002-07-28 21:30:43Z sally $
On Wikipedia:The UTC time zone is sometimes denoted by the letterZ a
reference to the equivalent nautical time zone (GMT), whichhas been denoted by a Z since about 1950. The letter alsorefers to the "zone description" of zero hours, which hasbeen used since 1920 (see time zone history). Since the
NATO phonetic alphabet and amateur radio word for Z is"Zulu", UTC is sometimes known as Zulu time.
http://en.wikipedia.org/wiki/Coordinated_Universal_Time#Time_zones
PropertiesSpecial SVN Properties:
Timestamps in Subversion
68
Special SVN Properties:
8/6/2019 Subversion_Training - User - Tortoise
69/116
Polarion Software Subtrain SVN User training www.polarion.com
PropertiesSpecial SVN Properties:
executable
69
svn:executable
For files only, sets the executable bit
Useful for scripts and programs
The executable bit is set when the property is applied to the file, not when
the commit is performed The executable bit is removed when this property is removed from the file.
The property value does not matter, any value will do.
8/6/2019 Subversion_Training - User - Tortoise
70/116
Special SVN Properties:
8/6/2019 Subversion_Training - User - Tortoise
71/116
Polarion Software Subtrain SVN User training www.polarion.com
PropertiesSpecial SVN Properties:
externals
71
svn:externals If you use a library (source form) as part of your development
which is used in more than one project, you can make a kind
of a link to the repository for that library. This avoids redundant
copies of the librarys source code.
Advantages: Just a single point of development for 3rd party library or libraries at all.
Disadvantages:
No automatic commits etc. in directories which are created by svn:externals.
If you create a branch the externalized content will NOT be branched accordingly.
If you create a tag the externalized content will NOT be frozen.For example: you create a tag in revision 10. Six weeks later you export it to deliver itto a customer. As the externalized content was NOT frozen you get the latest (HEADrevision e.g. rev 24) externalized code and have therefore exported a source-codebundle which does not look the same as six weeks ago.
Special SVN Properties:
8/6/2019 Subversion_Training - User - Tortoise
72/116
Polarion Software Subtrain SVN User training www.polarion.com
PropertiesSpecial SVN Properties:
externals
72
Special SVN Properties:
8/6/2019 Subversion_Training - User - Tortoise
73/116
Polarion Software Subtrain SVN User training www.polarion.com
PropertiesSpecial SVN Properties:
externals
73
new svn:externals syntax
-r 1234 http://example.com/repos/foo bar-r HEAD ^/same/repo/libraries/common commons
-r 3456 //another_svr.net/repo/prj_a framework
Relative URLs:
../ parent directory^/ repository root
// url scheme/ servername
Special SVN Properties:
8/6/2019 Subversion_Training - User - Tortoise
74/116
Polarion Software Subtrain SVN User training www.polarion.com
PropertiesSpecial SVN Properties:
externals
74
Subversion 1.6 introduced external definitions for files.
File externals are configured just like externals for directoriesand appear as a versioned file in the working copy.
Limitations:Not all clients support svn 1.6 yet.Binary files are not supportedDeletion is not supportedOnly applicable if the file lies in the same repository
Special SVN Properties:
8/6/2019 Subversion_Training - User - Tortoise
75/116
Polarion Software Subtrain SVN User training www.polarion.com
PropertiesSpecial SVN Properties:
eol-style
75
svn:eol-style
Native
Convert all CR, CRLF and LFs to the systems native eol
CR
Convert all CRLF and LFs to CRs
CRLF
Convert all CR and LFs to CRLFs
LF
Convert all CR and CRLFs to LFs
Property not set, this is the default when a file is added.Do not change end of lines upon check in or update.
8/6/2019 Subversion_Training - User - Tortoise
76/116
Managing versions
T i Wh T i ?
8/6/2019 Subversion_Training - User - Tortoise
77/116
Polarion Software Subtrain SVN User training www.polarion.com
Why do we need tags? Mark a release state of a product.
Mark a snapshot of the current development.
Typical Release names:
Release 1.0.0, Release 2.3.1, PRODUCT 1.0.0RC1 etc.
A Tag name should be unique to mark all components of thegiven product (source code and documentation) and is used toreproduce the state of the tag in the future.
Tagging Why Tagging?
77
T i Wh T i ?
8/6/2019 Subversion_Training - User - Tortoise
78/116
Polarion Software Subtrain SVN User training www.polarion.com
If we take a look at the architecture chapter we really dont needa 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 morehandy.
But the question is:
Where to put the tag information in the repository?
Tagging Why Tagging?
78
T i T i b C
8/6/2019 Subversion_Training - User - Tortoise
79/116
Polarion Software Subtrain SVN User training www.polarion.com
Tagging Tagging by Copy
79
To create a release tag just copy
anyway you have the revisionnumber tags
Project 1
Root
Release 1
trunk
I'm a copy!
T i E i VII t i
8/6/2019 Subversion_Training - User - Tortoise
80/116
Polarion Software Subtrain SVN User training www.polarion.com
Tagging Exercise VII: tagging
80
create a tag named /tags/release_01 with
commit message
creatingtagafterlocking exercise
svn copy m creating release 01
file:///c:/subtrain/repo/trunk
file:///c:/subtrain/repo/tags/release_01
B h Wh b hi ?
8/6/2019 Subversion_Training - User - Tortoise
81/116
Polarion Software Subtrain SVN User training www.polarion.com
Branches Why branching?
81
Assume the following situation: You have implemented a piece of software and it has been delivered to
your customer.
Before you delivered the product you have created a tag, lets sayRelease 1.0.0
Your current development crew is working on Release 1.1.0 with newfeatures.
And now Murphys Law caught you:
Your customer calls you and reports that he has found a bug in yoursoftware.
8/6/2019 Subversion_Training - User - Tortoise
82/116
8/6/2019 Subversion_Training - User - Tortoise
83/116
BranchesCreating branches by
8/6/2019 Subversion_Training - User - Tortoise
84/116
Polarion Software Subtrain SVN User training www.polarion.com
Branchesg y
copy in repository
84
branches
trunk
Root
bugfix_release_01
tags
release_01
svn copy m creatingbranch for bugfixing..
file:///c:/subtrain/repo/tags/release_01
file:///c:/subtrain/repo/branches/bugfix_release_01
BranchesCreating branches from
8/6/2019 Subversion_Training - User - Tortoise
85/116
Polarion Software Subtrain SVN User training www.polarion.com
Branchesyour working copy
85
svn copy
c:\subtrain\harry\
file:///c:/subtrain/repo/branches/bugfix_release_01
Branches Creating branches
8/6/2019 Subversion_Training - User - Tortoise
86/116
Polarion Software Subtrain SVN User training www.polarion.com
Branches Creating branches
86
You can create a branch using the following command:
svn copy source destination
1) The Subversion copy-command.
2) The source of the operation may be the local working copy.
3) The destination of the operation. This means the nameof the Branch.
Branches Switching branches
8/6/2019 Subversion_Training - User - Tortoise
87/116
Polarion Software Subtrain SVN User training www.polarion.com
Branches Switching branches
87
If you want to work on a differentbranch, you can switch yourworking copy instead of a newcheckout.svn switch url path
1) The Subversion switch-command.
2) The url where your working copyshould point to.
3) The path of your working copy.
svnswitch
file:///c:/subtrain/repo/branches\bugfix_release_01
c:\subtrain\sally
Branches Exercise VIII: branching
8/6/2019 Subversion_Training - User - Tortoise
88/116
Polarion Software Subtrain SVN User training www.polarion.com
Branches Exercise VIII: branching
88
create a branch named /branches/bugfix_release_01 with
commit message
creatingbranch for bugfixing
Switch Sally's working copy to this new branch
add a line in Harry's main.txt and commit it as making progress in trunk
change Sally's main.txt and libs/library.txt:
commit Sally's changes as bugfixing on branch
'
'
'
8/6/2019 Subversion_Training - User - Tortoise
89/116
Branching strategies
Branching Strategies Developer Branches
8/6/2019 Subversion_Training - User - Tortoise
90/116
Polarion Software Subtrain SVN User training www.polarion.com
Branching Strategies Developer Branches
90
Separation of team members can be realized with branches.
One branch per team member or several members on a branch - the decisionis based on the size of the teams.
Member 2
Main line
Member 1
Branching Strategies Developer Branches
8/6/2019 Subversion_Training - User - Tortoise
91/116
Polarion Software Subtrain SVN User training www.polarion.com
Advantages using branches for team work: No changes during development on the main line needed => Code
stability.
Every team member can work in their own environment.
Disadvantages:
Sometimes the mainline and the branch will diverge if the branchlives too long.
large merge effort for maintainer of trunk
Branching Strategies Developer Branches
91
Polarion ApplicationLifecycle Management(ALM) helps you solve thechallenges of branchingand merging
Branching Strategies Feature Branches
8/6/2019 Subversion_Training - User - Tortoise
92/116
Polarion Software
Subtrain SVN User training www.polarion.com
Branching Strategies Feature Branches
92
Separation by features (one branch each).
Branch will be obsolete after merge
trunk will progress inatomic features
Feature 2(multilingualism
)
Main line
Feature 1(new UI)
Branching Strategies Platform Branches
8/6/2019 Subversion_Training - User - Tortoise
93/116
Polarion Software
Subtrain SVN User training www.polarion.com
branches will live as longas the platform is supported
Branching Strategies Platform Branches
93
Platform 2(Windows)
Main line
Platform 1(UNIX)
Branching Strategies Vendor Branches
8/6/2019 Subversion_Training - User - Tortoise
94/116
Polarion Software
Subtrain SVN User training www.polarion.com
Branching Strategies Vendor Branches
94
Important, if you get distributions of 3rd party sourcecode which contains your own modifications:
1. new versions of source code will be placed into abranch and replaces the old versionsvn_load_dirs.pl will help to keep track of filemovements/additions/deletions
2. changes between versions will be merged into/trunk/vendor_dev
trunk
tags
vendor_branch
vendor_1.1
vendor_1.0
vendor_1.2
vendor_dev
svn_load_dirs.pl1.
2.
8/6/2019 Subversion_Training - User - Tortoise
95/116
Merging
Merging Merging from a branch
8/6/2019 Subversion_Training - User - Tortoise
96/116
Polarion Software
Subtrain SVN User training www.polarion.com
Merging Merging from a branch
96
Whats with the bug you've fixed on the bug-fix-branch?
What about your current development?
You have to merge thechanges made in the branchback to the main line.
RELEASE 1.0.0
BUGFIX_BRANCH
Merge back
MergingMerging means: applying
8/6/2019 Subversion_Training - User - Tortoise
97/116
Polarion Software
Subtrain SVN User training www.polarion.com
Merginga patch to your wc
97
3
4 6 7
5 8
(4
(5
(6
trunk (wc)
branch
(8
a merge will always apply a patch to a working copy
a patch is always a difference between two versions/trees
in this sample below we create the patch between revision 4 and 7
Merging Best Practices
8/6/2019 Subversion_Training - User - Tortoise
98/116
Polarion Software
Subtrain SVN User training www.polarion.com
If you need to create a branch, you should do it from a completelycommitted working copy. This prevents you from becoming confused.
If you merge check out a clean copy into another directory.
Otherwise you can't go back using svn revert.
After you've merged commit the changes and provide a log message with
information on which revision/branch you have merged (merge tracking). You can first test the merge using the --dry-run flag of the merge command.
Merging Best Practices
98
Merging
8/6/2019 Subversion_Training - User - Tortoise
99/116
Polarion Software
Subtrain SVN User training www.polarion.com
Merging
99
reintegrate branch
Merging Reintegrate branch
8/6/2019 Subversion_Training - User - Tortoise
100/116
Polarion Software
Subtrain SVN User training www.polarion.com
Merging Reintegrate branch
100
3
4 6 8
5 11
(4
(5
(
trunk (wc)
featurebranch
(
9 10(
(
7
reintegrate branch keeps track of all previous merged revisions and willnot try to merge them again
conditions which must apply:no switched working copyyou cannot skip any revision for merging from trunk into branch(so example below will not work if only 7 is merged to branch, and not 5)
Merging
8/6/2019 Subversion_Training - User - Tortoise
101/116
Polarion Software
Subtrain SVN User training www.polarion.com
Merging
101
merge a range of revisions reintegrate a branch
svnmerge c 14
file:///c:/subtrain/repo/branches\bugfix_release_01
c:\subtrain\sally
8/6/2019 Subversion_Training - User - Tortoise
102/116
Merging Merge tracking in svn log
8/6/2019 Subversion_Training - User - Tortoise
103/116
Polarion Software
Subtrain SVN User training www.polarion.com
Merging Merge tracking in svn log
103
merge tracking
svn log use-merge-history c:\subtrain\sally
Merging Exercise IX: merging
8/6/2019 Subversion_Training - User - Tortoise
104/116
Polarion Software
Subtrain SVN User training www.polarion.com
Switch Sally's working copy back to /trunk
merge the appropriate revision(s) from /branches/bugfix_release_01/ intoSally's working copy
check if the merge add the bugfix into the trunk
commit Sally's changes as:
merged bugfix from branches/bugfix_release_01 rev13:14 intotrunk
as this you have some kind of human readable merge tracking
control the merge tracking with TortoiseSVNs show log
g g g g
104
8/6/2019 Subversion_Training - User - Tortoise
105/116
Subversion Configuration
Subversion Configuration
8/6/2019 Subversion_Training - User - Tortoise
106/116
Polarion Software
Subtrain SVN User training www.polarion.com
Under Linux you will find the configuration under: /home/UsernameUsername/.subversion/config
Under Windows you will find the configuration under:
%APPDATA%/subversion/
In the config file [config.txt] you can change the behaviour of partsof Subversion.
in the server configuration file [servers] you can setup proxy-serversettings and ssl authorities
g
106
Subversion Configuration
8/6/2019 Subversion_Training - User - Tortoise
107/116
Polarion Software
Subtrain SVN User training www.polarion.com
g
107
Subversion Configuration auto-properties
8/6/2019 Subversion_Training - User - Tortoise
108/116
Polarion Software
Subtrain SVN User training www.polarion.com
Auto-properties can be useful if you like to set Word/Excel filesto read-only.
You have to turn on enable-auto-props which means set it toyes.
After that you can set svn:needs-lock for particular file types.
g p p
108
8/6/2019 Subversion_Training - User - Tortoise
109/116
Subversion Configuration global-ignore
8/6/2019 Subversion_Training - User - Tortoise
110/116
Polarion Software
Subtrain SVN User training www.polarion.com
g g g
110
You can put whatever file extension into
global-ignores to globally ignore files of a particular type.
[miscellany]### Set global-ignores to a set of whitespace-delimited globs### which Subversion will ignore in its 'status' output.# global-ignores = *.o *.lo *.la #*# .*.rej *.rej .*~ *~ .#* .DS_Store
Subversion Configuration commit-times
8/6/2019 Subversion_Training - User - Tortoise
111/116
Polarion Software
Subtrain SVN User training www.polarion.com
g
111
Sometimes you need to have the changed time to be set on thecommit-time instead of the created local time. This is often used inrelationship with Make-files.
You can simply uncomment the line with use-commit-times = yes.
After that every check out will set the time stamp to commit time andnot to the check out time.
### Set use-commit-times to make check out/update/switch/revert### put last-committed timestamps on every file touched.
# use-commit-times = yes
Additional Links
and SVN info Sources
8/6/2019 Subversion_Training - User - Tortoise
112/116
Polarion Software
Subtrain SVN User training www.polarion.com
Subtrain online: http://subtrain.tigris.org
Book: Version Control with Subversion:
http://svnbook.red-bean.com/
Subversion Developer Portal and
downloads:
http://subversion.apache.org/
Subversion Wiki:
http://www.subversionary.org
Subversion Free Tools:
http://www.polarion.org
Subversion Forums:
http://www.svnforum.org/
Subversion News
http://svn.haxx.se/
and SVN info Sources
112
Do not forget to visit www.POLARION.COM for
FREE and Open Source Tools & Solutions forSubversion like:
Subversive - SVN Provider for Eclipse
WebClient for SVN- free Subversion web
client
Importer for SVN - migrate data fast, safely,
and FREE
8/6/2019 Subversion_Training - User - Tortoise
113/116
8/6/2019 Subversion_Training - User - Tortoise
114/116
8/6/2019 Subversion_Training - User - Tortoise
115/116
8/6/2019 Subversion_Training - User - Tortoise
116/116
You'll find the latest version of SubTrain & FREESubversion tools at:
Thank You!
www.polarion.com