Introduction to Programming

Download Report

Transcript Introduction to Programming

Version Control using Subversion (SVN)

November 18, 2008

David Goldschmidt, Ph.D.

Computer Science The College of Saint Rose

Version Control

Version control refers to the management of multiple versions (a.k.a. revisions) of project-related documents, source code, etc.

 Synonyms include:    Revision control Source control Source code management

Version Control System

 A version control system is crucial to engineering and software development projects

disadvantage: extra workflow

 Maintains a centralized repository of digital documents    Facilitates organized team-based collaboration Provides revision history for both individual documents and groups of documents Often supports multiple branches of development

Version Control Systems

 Numerous version control systems are available   Commercial (ranging from $100-$4000+ per user):   ClearCase Microsoft Visual SourceSafe Open-source – free:  RCS (Revision Control System)    SCCS (Source Code Control System) CVS (Concurrent Versions System)

Subversion

http://en.wikipedia.org/wiki/Comparison_of_revision_control_software

Architecture of a Version Control System

 Centralized repository serves multiple clients (from http://www.zefhemel.com/archives/2005/03/24/isdw-day-4-file-exchange)

Subversion

 Developed in 2000 and 2001 (by CollabNet, Inc.) to replace CVS and its shortcomings     Subversion is free Subversion is open-source Subversion operates across a network Subversion handles any types of files, documents, or directories  Subversion requires administrative support

Subversion’s Storage Repository

 Subversion provides a centralized storage repository     Storage repository acts as a fileserver Clients connect, then read from or write to files Clients can also view logs of changes made to files or directories All changes are logged, storing date, time, user responsible, user-specified notes

Problems with Sharing Files

 Overwriting changes

Problems with Sharing Files

How can we solve the overwriting changes problem?

  Allow a client to lock a file, ensuring only that client can make changes to the file Clients can still read the file, but only one client has access to write the file back to the repository  Key disadvantage: idle developer time spent waiting for write-access

The Copy-Modify-Merge Approach

 Subversion uses the copy-modify-merge approach  No locking of files

The Copy-Modify-Merge Approach

 Subversion will merge the changes together

Conflicts may arise!

Resolving Conflicts

How are conflicts resolved?

   A conflict does not occur if changes exist in separate parts of the file A conflict does occur if changes overlap Subversion shows both versions and allows Harry to decide how to perform the merge

Using Subversion

 On its own, Subversion is command-line driven  UNIX: $ svn checkout http://xyz.com:3690/rep ...

 MS-DOS: C:\> svn checkout http://xyz.com:3690/rep ...

 Numerous GUIs have been built on top of SVN   

TortoiseSVN

VisualSVN XCode (Mac OS X) http://tortoisesvn.net/

TortoiseSVN

 TortoiseSVN is    Open-source (free) Integrated directly into Windows Explorer http://tortoisesvn.net/ Usable with any development environment

TortoiseSVN

 From Windows Explorer, use TortoiseSVN by right-clicking...

  Right-click within a folder or on an individual file A context-sensitive menu with applicable options appears

TortoiseSVN: Checking Files Out

 Read files from the repository by using the checkout command  Connect to the repository using: or include the port number:

svn://srv55z3 svn://srv55z3:3690

  Typically checkout the entire trunk to ensure proper compilation Once checked out, you may modify files, delete files, create new files, etc.

TortoiseSVN: Checking Files Out

 Read files from the repository by using the checkout command    Specify the URL of the repository Select the local checkout directory Specify a revision, if applicable  Also view history logs

TortoiseSVN: Viewing a File’s Status

 Windows Explorer shows the status of your files   A checkmark within a green circle indicates the file has not been altered since checked out of the repository An exclamation point within a red circle indicates the file or folder has been modified

TortoiseSVN: Reviewing & Committing Changes

 After appropriate changes, deletions, and additions have been made, you may commit your changes  SVN records your changes and associates them with a new revision number  Update the repository with all of your changes by performing a commit from the top-level folder

TortoiseSVN: Reviewing Changes

 View a diff of the files to be committed

TortoiseSVN: Committing Changes

 Describe your changes for the revision log  Commit from the top-level folder  Every change that you commit goes down in history....

TortoiseSVN: Committing Changes

 A commit operation is atomic  The new revision number is shown in the resulting dialog box

TortoiseSVN: Importing a New Set of Files

 Right-click and select Import to add a new set of files to the repository

TortoiseSVN: Importing a New Set of Files

 Specify the repository URL, including the name of the subdirectory to create in the repository

TortoiseSVN: Typical Workflows

  Update your working copy (i.e. your local repository):  svn update Change your working copy:    svn add svn delete svn copy   svn move svn mkdir

TortoiseSVN: Typical Workflows

   Review your changes:    svn status svn diff svn revert (undo) Resolve conflicts by merging:  svn update  svn resolved Commit your changes:  svn commit

Additional Recommendations

 Usage recommendations:    Avoid storing binary files or JARs  Binary files use a lot of repository space Avoid storing IDE-specific files  e.g. do not store JDeveloper workspace or project files Commit changes at meaningful checkpoints   Frequently enough for others to share in development Infrequently enough so as not to create too many revisions

Thank You!

 Thank you for your interest and attention  Please feel free to e-mail me ([email protected]) with additional questions