Date post: | 06-May-2015 |
Category: |
Technology |
Upload: | g-b-versiani |
View: | 922 times |
Download: | 0 times |
Nymgo team
Version ControlBasics
Version Control
Objectives
Understand basic elements and management of the version control, without
entering in details of a specific Version Control System.
Version Control
Agenda (1h)
1.Basic vocabulary2.Parallel Worlds3.Branching Patterns4.Anti-Patterns
BASIC VOCABULARYMain concepts
Version Control
Environment
• RepositoryWhere files’ current and historical data are stored.
• ServerA machine serving the repository.
• ClientThe client machine connecting to the server.
• Working copyLocal copy where the developer changes the code.
Version Control
Client
Environment
Server
Repository
Working copy
Version Control
Basic operations
• AddMark a file or folder to be versioned
• ChangeCreate any changes in the local copy
• CommitSend changes to the repository
• RevertDiscard local changes and go back to the same last known revision from the repository
Version Control
Basic operations
Foobar.txt Foobar.txt
Foobar.txt Foobar.txt
Add
Revert
Commit
Change
Commit
Delete
Revert
Commit
Version Control
Basic artifacts
• RevisionSet of changes, state of the code in a point of time
• ChangelogSequential view of the changes done to the code, stored in the repository
Version Control
Artefatos Básicos
1220
1221
1222
file1.txtfile3.txt
file2.txtfile4.txt
file1.txtfile2.txtfile4.txt
tom
dick
harry
Including feature A.
Including BUG B.
Refactoring of module C.
1219 file1.txtfile2.txtfile3.txtfile4.txt
fulanoFirst inclusion
Revision
Revision number
Revision author
Changed files
Description message
Changelog
Last revision (head)
Timelin
e
Version Control
Synchronization
• UpdateSynchronize changes from the repository to the local copy
Version Control
Synchronization
Tom
Server
Jerry
Commit
Update
1219 1220 1221 1222
1219 1220 1221
1222
1219 1220 1221 1222
Version Control
Labels
• TagsComprehensive alias for existing revisions, marking an important snapshot in time
Version Control
Labels
1220
1221
1222
1219
1.0.1
1.0.2
1220
1221
1222
file1.txtfile3.txt
file2.txtfile4.txt
file1.txtfile2.txtfile4.txt
dick
tom
harry
Including feature A.
Including BUG B.
Refactoring of module C.
1219 file1.txtfile2.txtfile3.txtfile4.txt
tomFirst inclusion.
Tags
Version Control
Changes
• Diffs and PatchesThe comparison between two text files is done by an application diff-like that feeds an application patch-like capable of redo the changes from the originating state to the destination state.This operation of computing the differences is normally referred as diff, while the “file containing the differences”, that could be exchanged in e-mails and other eletronic media, is denominated patch.
Version Control
Changes – Example
Diff file or patch
Diff file or patch
Version Control
1219 1220 1221 1222
Changes
1218
diff 1 diff 2 diff 3 diff 4
PARALLEL WORLDSConcepts of branching, merging and conflicts
Version Control
Parallel WorldsPerhaps the most accessible way to think of branches is as parallel
universes. They're places where, for whatever reason, history didn't go quite the same way as it did in your universe. From that point forward,
that universe can be slightly different – or it can be radically and utterly transformed. Like the Marvel comic book series “What If?”,
branching lets you answer some interesting and possibly even dangerous "what if" questions with your software development.
Version Control
Parallel Worlds
• Parallel universes offer unlimited possibilities.
• They also allow you to stay safely ensconced in the particular universe of your choice, completely isolated from any events in other alternate universes.
Version Control
Parallel Worlds
• Branch is like a parallel world.• Changes done in one branch
doesn’t have effect over the another.
• Although branching offers the seductive appeal of multiple possibility with very little risk, it also brings along something far less desirable: increase of complexity.
Version Control
Branches
X
Y
Z
W
Create branch
Create branch
Create branch
Version Control
Merge
• In some point of the development, the code must be merged.
Version Control
Merge
X
Y
Merge
Version Control
Conflicts
• When the changes are done in the same source file lines, you can have conflicts.
Version Control
How to solve conflicts?
Version Control
How to solve conflicts?
Question:Is it possible to solve
these conflicts automatically?
Version Control
How to solve conflicts?
Answer: No!!!Even when don’t have changes in
the same source line, you can still have semantic problems in
the code. So, always double check before to commit.
Version Control
How to solve conflicts?
A note before continuing:
It is always better to avoid unnecessary
conflicts.Communicate your development, always include a description
in your committed revisions, ask for help if you don’t understand anything, etc.
Version Control
How to solve conflicts?
Aworking base
Bworking copy
C = A + Boutput
A
B C
Two way merge
Tools: KDiff3
Version Control
How to solve conflicts?
B
C DA
Aorigin
Cbranch
#2
D = A + B + C
Bbranch #1
Create branch
Merge
Three way merge
Tools: KDiff3
Tools: choose one…
Notepad++
Araxis
DiffMerge
MeldUltracompare
tkmergexxdiff
TFS diffmerge
Guiffy SureMerge
Apple Filemerge
...
Which one should I use?
Choose one that best fits your
team!
BRANCHING PATTERNSHow to manage the branches during the software lifecycle
Version Control
Mainline
1.0
1.1
1.2
2.0
branch
1.0.1
merge
branch
1.1.1
merge
branch
1.2.1
1.1.2
merge
1.2.2
merge
2.0.1
Version Control
Mainline
Bring a fix from branch n to branch m require m-n
merges (linear complexity with the number of
branches).
Version Control
Mainline
Learned lesson:
Perform merges the early and frequently as possible.
Version Control
Mainline / Variant
mainline
1.1
1.2
2.0
branch
merge
1.1.1
branch
1.2.1
merge
1.2.2
merge
2.0.1
merge
branch
merge
3.0
branch
Version Control
Scenario:
You just developed a stable version of the software and you
need to create a new version with new features and still
provide small fixes for the last stable version.
Version Control
Parallel Maintenance / Development Lines
devel
1.1
2.0.1
1.1.1
merge
1.1.2
merge
branch1.0.0
Most used option
Version Control
Parallel Maintenance / Development Lines
devel
1.1
2.0
branch
merge
1.1.1
2.0.1
merge
2.0.2
merge
merge
branch1.0.0
Note the internal branch
Version Control
Scenario:
You need to develop two different features in a short
period of time.
(laughts)
Version Control
Overlapping Release Lines
mainline
func_2
func_1
branch
merge merge
merge
branch
Version Control
Scenario:
You allocated a new developer to work in a too risky code base and
you want to moderate his/her changes for a while.
Version Control
Docking Line
devel
docking
line change,stabilize
change,stabilize
change,stabilize
sync sync sync
merge merge merge
moderador
desenvolvedor
Version Control
Scenario:
Your development tasks need to progress in discrete levels of
maturity: (1) change proposals, (2) analysis, (3) review, (4) unit tests, (5) integration tests, (6)
system tests, etc.
Version Control
Staged Integration Lines
devel
propostas
revisão
testes
(1)
(2)
(3)
WHEN TO CREATE A BRANCH?Some most common patterns.
Version Control
Branch per Delivery
Release 1
Release 2
1.0 1.1 1.2 1.3
2.0 2.1 2.2 2.3
Create branch Merge
Version Control
Branch per Task
Devel
1.0 1.1 1.2
Task 1
Task 2
Version Control
Branch per Component
Devel
1.0 1.1 1.2
Component A
Component B
Components A + B
Version Control
Branch per Technology
Common
Android
iOS
1.1 1.2
1.1
1.1 1.2
ANTI-PATTERNSWhat can happen if you don’t manage branching
Anti-Pattern Description
Merge Paranoia avoiding merging at all cost, usually because of a fear of the consequences.
Merge Mania spending too much time merging software assets instead of developing them.
Big-Bang Merge deferring branch merging to the end of the development effort and attempting to merge all branches simultaneously.
Nerver-Ending Merge continuous merging activity because there is always more to merge.
Wrong-Way Merge merging a software asset version with an earlier version.
Branch Mania creating many branches for no apparent reason.
Cascading Branches branching but never merging back to the main line.
Mysterious Branches branching for no apparent reason.
Temporary Branches branching for changing reasons, so the branch becomes a permanent temporary workspace.
Volatile Branches branching with unstable software assets shared by other branches or merged into another branch.
Note Branches are volatile most of the time while they exist as independent branches. That is the point of having them. The difference is that you should not share or merge branches while they are in an unstable state.
Development Freeze stopping all development activities while branching, merging, and building new base lines.
Berlin Wall using branches to divide the development team members, instead of dividing the work they are performing.