You are on page 1of 38

COMP SCI 2XB3/ SOFT ENG 2XB3

Practice and Experience: Binding Theory to Practice

Lecture 4 – Software Revisions and Version Control


Dr. Reza Samavi
Teaching Assistant : Aida Motamer

PowerPoint slides (mainly) from James Brucker

Reza Samavi COMP SCI 2XB3/ SOFT ENG 2XB3 Lecture 4


Outline

• What is Version Control System?


• Apache Subversion (SVN)
• Tags and Branches
• Which version control system is right for your
project?

Reza Samavi COMP SCI 2XB3/ SOFT ENG 2XB3 Lecture 4


What is Version Control System?

• Helps software developers to work together


• Allows developers to work simultaneously.
• Does not allow overwriting each other’s changes.
• Maintains a complete history of every version - multiple versions
of every file
• Manage documents over time

• avoid conflicts ...and help resolve them


• permissions: authenticate and control access to files
• show differences between versions of a file
• document changes -- reason for change
Reza Samavi COMP SCI 2XB3/ SOFT ENG 2XB3 Lecture 4
Main features of a Version Control System
• Backup and Restore
- you can jump to any moment in time
• Synchronization
- stay up-to-date with the latest version
• Short-term undo
• Long-term undo
• Track Changes
- make it is easy to see how a file is evolving
• Track Ownership
- blamestorming! giving credit
• Sandboxing
- making temporary changes in an isolated area
• Branching and merging

Reza Samavi COMP SCI 2XB3/ SOFT ENG 2XB3 Lecture 4


Types of VCS
• Centralized version control system (CVCS)

It uses a central server to store all files and enables team collaboration. But
the major drawback of CVCS is its single point of failure, i.e., failure of the
central server.

• Distributed/Decentralized Version Control System


(DVCS)

DVCS clients not only check out the latest snapshot of the directory but they
also fully mirror the repository. If the server goes down, then the repository
from any client can be copied back to the server to restore it.

You should take time to look for an example or two of how one
or the other is best suited to your enterprise or workflow,
To get the right VCS for your needs.

Reza Samavi COMP SCI 2XB3/ SOFT ENG 2XB3 Lecture 4


Different Version Control Solutions
• Concurrent Versions System (CVS)
• Apache Subversion (SVN)
Subversion falls under centralized version control system, meaning that it
uses central server to store all files and enables team collaboration.
• Git
Git falls under distributed version control system.

SVN workflow Git workflow

Reza Samavi COMP SCI 2XB3/ SOFT ENG 2XB3 Lecture 4


Apache Subversion (SVN)

• SVN is a software versioning and revision control


system distributed under an open source
licensed by Apache Software Foundation
• It is a product of CollabNet designed in 2000
• Part of a rich community of developers
and users
• It is mostly compatible with the widely used
Concurrent Versions System (CVS)

Reza Samavi COMP SCI 2XB3/ SOFT ENG 2XB3 Lecture 4


Subversion Architecture

Client Interface Repository Interface


FSFS
Apache
GUI Access mod_dav
clients Protocol mod_dav
_svn
DAV
Client Intranetwork svnserve
Library
Cmd line SVN
clients sshd
SSH Subversion
Repository

Working Copy Local


Management "file" protocol
Library
Berkley
DB
Reza Samavi COMP SCI 2XB3/ SOFT ENG 2XB3 Lecture 4
The Work Cycle
Apply changes from
working copy to
Create/update the Repository
working copy
svn commit
svn checkout Subversion 106
svn update Repository
100
Resolve conflicts
(Merge your changes)
Make changes
svn merge
svn add svn resolved
svn delete
svn move 105
svn rename
Fix Mistakes
Review Changes
throw away the
svn status svn revert changes in
svn diff working copy
'status' operation is used to list the pending change-list
Reza Samavi but not the details
COMPabout them.
SCI 2XB3/ SOFT ENG 2XB3 Lecture 4
Properties of a Repository

• History of all changes to files and directories.


- you can recover any previous version of a file
- remembers "moved" and "deleted" files
• Access Control
- Read / write permission for users and groups
- Permissions can apply to repo, directory, or file
• Logging
- author of the change
- date of the change
- reason for the change

Reza Samavi COMP SCI 2XB3/ SOFT ENG 2XB3 Lecture 4


Logging a Revision

Content what has changed?


Date when did it change? SVN does this

Author who changed it?


Reason why has it changed? you enter this

Reza Samavi COMP SCI 2XB3/ SOFT ENG 2XB3 Lecture 4


How to Contact a Subversion Server

checkout (first time)

client server

1. You need the URL of repository.


e.g., https://rsamavi.unfuddle.com/svn/rsamavi_first/
2. (optional) may need a username and password.

Reza Samavi COMP SCI 2XB3/ SOFT ENG 2XB3 Lecture 4 12


URLs and Protocols

http://myhost.com:port/path/to/repository

optional port
number
Protocol: Host name or Repository
IP address
svn relative
svn+ssh 127.0.0.1 path

http localhost

https host:8443

file
Reza Samavi COMP SCI 2XB3/ SOFT ENG 2XB3 Lecture 4 13
(1) Check out using Eclipse

1. Switch to "SVN
Repository Exploring
Mode".
2. Right click and choose
New => Repository
Location
3. Enter URL and (optional)
authentication info.

Reza Samavi COMP SCI 2XB3/ SOFT ENG 2XB3 Lecture 4 14


The trunk is a directory where
all the main development happens and
(1) Check out using Eclipse is usually checked out by developers to
work on the project.

• Now you can browse the repository.


• Choose the part you want to check-out (usually "trunk")
• Right click and choose "Check Out as..."
("Check Out as..." gives you a chance to change local
project name if you want.)

svn checkout

Reza Samavi COMP SCI 2XB3/ SOFT ENG 2XB3 Lecture 4 15


svn add
svn delete
(2) Work Cycle: Edit Files svn move
svn rename

1. Edit files using anything you like.

2. Test Your Work.

- Don't commit buggy code to the repository.

Then go to next step...

Reza Samavi COMP SCI 2XB3/ SOFT ENG 2XB3 Lecture 4 16


svn diff
(3) Check for Updates svn merge
svn resolve

• Before "committing" your


work, check for updates in
the repository.
• Subversion requires you to
synchronize before commit.
• Right-click => Team =>
Synchronize with Repository
• Eclipse switches to "Team
Synchronize" perspective.
• Use "Conflict mode" to
compare modified files.

Reza Samavi COMP SCI 2XB3/ SOFT ENG 2XB3 Lecture 4 17


Synchronization state

Source: https://eclipse.org/subversive/documentation/teamSupport/workspace_synch.php
Reza Samavi COMP SCI 2XB3/ SOFT ENG 2XB3 Lecture 4 18
svn status
View Differences svn diff

• You can compare your version and the base or


repo version.
• Select file, right-click => Compare with base

Reza Samavi COMP SCI 2XB3/ SOFT ENG 2XB3 Lecture 4 19


(4) Updating in Eclipse svn update

• You can use "Compare


Editor" to download
changes.
• or, right-click =>
"Update" on file or
project.

Reza Samavi COMP SCI 2XB3/ SOFT ENG 2XB3 Lecture 4 20


(5) Resolve Conflicts

• "Conflict" means you have made changes to a file, and


the version in the repository has been changed, too.
• So there is a "conflict" between your work and work
already in the repository.
• 'Merge' operation automatically handles everything
that can be done safely. Everything else is considered as
conflict. For example, "hello.c" file was modified in
branch and deleted in another branch. Such a situation
requires a person to make the decision.
• The 'resolve' operation is used to help the user figure
out things.

Reza Samavi COMP SCI 2XB3/ SOFT ENG 2XB3 Lecture 4 21


Conflict Support Files
Say that you checked out version 6 of README and are editing it
Other people commited various versions and the repository is now up to
version 12, and they changed some of the same lines as you did --
differently.
When you update, the changes conflict with yours, and svn not allow you to
commit that file until you resolve this.
Subversion client creates 4 files when a conflict
happens:

Reza Samavi COMP SCI 2XB3/ SOFT ENG 2XB3 Lecture 4 22


Resolving Conflicts

The choices are:


(1) merge local & remote changes into one file.
(2) accept remote, discard your local changes.
(3) override remote, use your local changes.

• Afer resolving all conflicts, mark the file as


"resolved".
• Subversion will delete the extra 3 copies.

Reza Samavi COMP SCI 2XB3/ SOFT ENG 2XB3 Lecture 4 23


Resolving Conflicts in Eclipse

• Use "Compare Editor" in Synchronize perspective.


• Accept or reject changes one-by-one or all at once.

Reza Samavi COMP SCI 2XB3/ SOFT ENG 2XB3 Lecture 4 24


(6) Commit in IDE

After "update" and resolving conflicts, commit


your work.

Eclipse:
• right click on file or project => Commit

Reza Samavi COMP SCI 2XB3/ SOFT ENG 2XB3 Lecture 4 25


Outline

• What is Version Control?


• Apache Subversion (SVN)
• Tags and Branches
• Which version control system is right for my project?

Reza Samavi COMP SCI 2XB3/ SOFT ENG 2XB3 Lecture 4 26


Tags Trunk is a directory where all the main
development happens and is usually
checked out by developers to work on
the project.
Root Tag The tags directory is used to store
named snapshots of the project. Tag
Project 1 operation allows to give descriptive and
trunk
memorable names to specific version in
the repository.To create a release tag just
copy

... subversion doesn't really copy
tags the files; it just creates a name
Release-1 number

("Release-1") for the revision


Reza Samavi COMP SCI 2XB3/ SOFT ENG 2XB3 Lecture 4 27
Tags
• Why do we need tags?
§ Mark a release version of a product.
§ Mark a snapshot of the current development.

• Typical Release names:


§ Release-1.0.0
§ REL-0.3.0RC1
• A Tag name must be unique.

• Contents of a "tag" should not be changed.


...but Subversion won't stop you from changing them!
LAST_STABLE_CODE_BEFORE_EMAIL_SUPPORT is more memorable than
Repository UUID: 7ceef8cb-3799-40dd-a067-c216ec2e5247
Reza Samavi COMP SCI 2XB3/ SOFT ENG 2XB3 Lecture 4 28
Branch is a copy of code
derived from a certain point
Branches in the trunk. It is used to
create another line of
development. It is useful
Root when you want your
Calc development process to fork
trunk off into two different
directions.
branches

my-calc branch

Paint
trunk

branches

Reza Samavi COMP SCI 2XB3/ SOFT ENG 2XB3 Lecture 4 29


Why Branching?

This could happen to you:


• You create a great product and it has been delivered to
your customers.
• Before you deliver the product you create a svn tag,
named it REL-1.0.0
• Your development team is modifying the trunk version
with new features.

And now Murphy‘s Law strikes!


• Customer reports that he found a major bug in your
software!

Reza Samavi COMP SCI 2XB3/ SOFT ENG 2XB3 Lecture 4 30


Using Branches

• You would like to work on the branch to fix the


bug.
• You can do it in two ways:
• Check out a complete new
working copy from the
branch. RELEASE 1.0.0
• Or switch your current
working copy to the
particular branch. BUGFIX_BRANCH

RELEASE
1.0.1

Reza Samavi COMP SCI 2XB3/ SOFT ENG 2XB3 Lecture 4 31


Merging From a Branch

• What’s 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 RELEASE 1.0.0
Branch back to the
BUGFIX_BRANCH 267
main line.

RELEASE
1.0.1
Merge back

Reza Samavi COMP SCI 2XB3/ SOFT ENG 2XB3 Lecture 4 32


Outline

• What is Version Control?


• Apache Subversion (SVN)
• Tags and Branches
• Which version control system is right for my project?

Reza Samavi COMP SCI 2XB3/ SOFT ENG 2XB3 Lecture 4 33


Different Version Control Solutions

• Decision criteria
- Server based or peer-to-peer
- speed
- functionality
- the learning curve associated with the system
• Major systems
- Concurrent Versions System (CVS)
- Apache Subversion (SVN)
- Git

Reza Samavi COMP SCI 2XB3/ SOFT ENG 2XB3 Lecture 4 34


CVS

• Pros:
- Has been in use for many years and is considered mature
technology
• Cons:
- Moving or renaming files does not include a version
update
- Security risks from symbolic links to files
- No atomic operation support, leading to source corruption
- Branch operations are expensive as it is not designed for
long-term branching

Reza Samavi COMP SCI 2XB3/ SOFT ENG 2XB3 Lecture 4 35


SVN
• Pros
- Newer system based on CVS
- Includes atomic operations
- Cheaper branch operations
- Wide variety of plug-ins for IDEs
- Does not use peer-to-peer model
• Cons
- Still contains bugs relating to renaming files and
directories
- Insufficient repository management commands
- Slower comparative speed

Reza Samavi COMP SCI 2XB3/ SOFT ENG 2XB3 Lecture 4 36


Git

• Pros
- Great for those who hate CVS/SVN
- Dramatic increase in operation speed
- Cheap branch operations
- Full history tree available offline
- Distributed, peer-to-peer model
• Cons
- Learning curve for those used to SVN
- Not optimal for single developers
- Limited Windows support compared to Linux

Reza Samavi COMP SCI 2XB3/ SOFT ENG 2XB3 Lecture 4 37


References
• Apache Subversion documentation
https://subversion.apache.org/docs/

• Subversion Ubuntu documentation


https://help.ubuntu.com/community/Subversion

• SVN Mozilla wiki


https://wiki.mozilla.org/SVN

• Tortoise clients for SVN and CVS


www.tortoisecvs.org/
tortoisesvn.net/

Reza Samavi COMP SCI 2XB3/ SOFT ENG 2XB3 Lecture 4 38

You might also like