Sei sulla pagina 1di 52

Version Control

Lecturer: Ngô Huy Biên


Books And Reading
There is no course textbook. Here are some useful books:
• Version Control with Subversion By Ben Collins-Sussman, Brian W.
Fitzpatrick, C. Michael Pilato, 2004
• Subversion Version Control: Using The Subversion Version Control
System in Development Projects By William Nagel, 2005
• Visual SourceSafe 2005 Software Configuration Management in
Practice By Alexandru Serban, 2007
• Essential CVS By Jennifer Vesperman, 2006
Working Together
– "Hey, Jane, could you send me a copy of those changes
you made last Tuesday?"
– "Bob, this function doesn't work anymore. Did you change
something?“
– "Sorry, I can't seem to find those old classes. I guess
you'll just have to re-implement them.“

– "Ok, we've all been working hard for the last week. Now
let's integrate everyone's work together."

Where did my code go? When did file X last


Who overwrote my code? change?
Why did you overwrite my What changed in the file?
code? Why was the file
and... changed?
When was the last time we and...
backed up the code? Who changed the file?
The Repository
The repository stores information in the form of a filesystem
tree—a typical hierarchy of files and directories. Any number
of clients connect to the repository, and then read or write to
these files.

Typically server/client architecture.


Working Copy

The version control


system manages
the synchronization
between repository
and working copies

States Users work on a copy, the


Unchanged, and current Working Copy
Locally changed, and current
Unchanged, and out-of-date
Locally changed, and out-of-date
Workspaces
An area where users can work separated from the repository and to isolate
each user from the others.

Working folder
Working directory
Sandbox
View
Enlistment
Revision
Revision Numbers

Revision Keywords
The repository's HEAD
filesystem BASE, COMMITTED, PREV
Revisions
Revision Dates
{2009-03-19}
{“2008-02-17 15:30”}

calc/Makefile:4 calc/Makefile:4 calc/Makefile:6 Mixed Revision


integer.c:4 integer.c:4 integer.c:6 Working Copies
button.c:4 button.c:5 button.c:6 Updates and Commits
are Separate
Global Revision Numbers
Deltas
The difference between the two revisions is called a delta.

Forward Deltas

Reverse Deltas
CheckOut/Update
To get a resource from the repository with the
purpose of making changes to it

A patchfile is a special file that can be used


by the patch utility to update a set of files
from one revision to another.
Modify/Edit
To make changes to the resources in our
workspace
Check In/Commit
To save changes to the repository

Atomic commits ensures that


while one person is committing
changes to the repository, no
one else can.

A hook is a place to hang a


script, such that the script is
run at a specific stage of the
version control
processperhaps before or after
a change is committed, when a
log message is stored, or when
a file is checked out for
exclusive development.
Conflict
Lock – Modify – Unlock
Lock – Modify – Unlock (cont.)
Copy – Modify – Merge
To combine changes of 2 working copies to one
working copy

Automatic merge
Manual merge
Branch

A codeline represents a project's


development evolution across time, having a
continuous history.

A branch is a line of
development that exists
independently of another line.

Starting repository The branching of one file's history


layout Repository with new copy
Merging Branches
To integrate changes
performed in one
branch into another
branch.
Tag/Label

A tag (label) is
just a snapshot of
a project in time.
Exclusive Development
The version control system permits only one user at a time to work on any individual
file.
Simultaneous Development
Multiple users can work on the same file and the version control system attempts
to merge the respective changes seamlessly.
Central Repository
Central repository – The historic data about project changes is
stored in a single place.

Data export – An
exported set of data User
should not contain
administrative files or
data for the version
control system.
Central
User User
Repository

User
Distributed Repositories
Distributed Repositories – Each developer has a personal repository, and the
repositories update from their peers.

User Repository

User Repository Repository User


Proxied Repositories
Proxied repositories – There is a central repository, which holds the changes
data, and proxy repositories, which are used for read requests and which refer
write requests to the central repository.

User Proxy
Repository

Proxy Central Proxy


User Repository
Repository Repository User

Proxy
Repository
User
Remote Access To The Repository
Benefits
Any stored revision of a file can be retrieved,
viewed, and changed.
The differences between any two revisions can Any version control
be displayed. is better than no
Patches can be created automatically. version control.
Multiple developers can work simultaneously on
the same project or file without overwriting one
another's changes.
The project can be branched to allow
simultaneous development along varied tracks.
These branches can be merged back into the main
line of development.
Distributed development is supported across
large or small networks.
Tools
• VSS (http://msdn.microsoft.com/en-us/vs2005/aa718670.aspx)
• CVS (http://www.nongnu.org/cvs/)
• SVN (http://subversion.tigris.org/)
• Perforce (http://www.perforce.com/perforce/products.html)
• BitKeeper (http://www.bitkeeper.com/Products.html)
• Accurev (http://www.accurev.com/accurev.html)
• ClearCase (http://www-306.ibm.com/software/awdtools/clearcase/)
• CM Synergy (http://www.telelogic.com/corp/products/synergy/index.cfm)
• StarTeam (http://www.borland.com/us/products/starteam/index.html)
• MKS Integrity (http://www.mks.com/products/index.jsp)
• Vault (http://www.sourcegear.com/vault/)
Comparing Version Control
Systems
VCS Development model Repository type Atomic commits
Simultaneous or
CVS Central and proxied No
exclusive
Bitkeeper Simultaneous Distributed Yes
Simultaneous or
ClearCase Central or distributed N/A
exclusive
Git Simultaneous Distributed Yes
GNU Arch Simultaneous Distributed Yes
Simultaneous or
Perforce Central Yes
exclusive
Simultaneous or
Subversion Central Yes
exclusive
Visual Source Safe Exclusive Central No
http://www.open.collab.net/downloads/subversion/
CollabNet Subversion Installation
CollabNet Subversion Installation
(cont.)
Creating Repository
Creating Repository (cont.)
Commit
Update
Controlling Access To The
Repository
httpd.conf
Lock
Add/Delete
Revision
Diff/Revert/CleanUp
Resolving Conflicts
Resolved
Create Tag/Branch
Working With Branch
Merging A Branch Into Trunk
Merging A Branch Into Trunk
(cont.)
GUI Client
Using GUI Client
Using GUI Client (cont.)
Tips
...XYZ "is not a working copy directory” error
1."externally" remove XYZ from system
2.svn cleanup (to unlock parent directory)
3.svn revert XYZ (to remove "missing tag")
Thank you for your time

Potrebbero piacerti anche