Version Control Tools Source Code Control Venkat N Gudivada Marshall University 13 July 2010 Venkat N Gudivada Version Control Tools 1/73
Outline 1 References and Resources 2 3 4 Venkat N Gudivada Version Control Tools 2/73
References: Braude, E.J. & Bernstein, M.E. (2008). Software Engineering. (2 nd Edition). New York: John Wiley & Sons, Inc. ISBN: 0471692085. Chapter 6 (). Click Me to find this on Amazon. Venkat N Gudivada Version Control Tools 3/73
References: CVS and Smart, J.F. (2008). Java Power Tools. Cambridge: O Reilly Media, Inc. ISBN: 0596527934. Chapters 3 (CVS) and 4 (). Click Me to find this on Amazon. Venkat N Gudivada Version Control Tools 4/73
References: CVS Fogel, K.F. (1999). Open Source Development with CVS: Learn How to Work With Open Source Software. Coriolis Group Books. ISBN: 1576104907. Click Me to find this on Amazon. Venkat N Gudivada Version Control Tools 5/73
References and Resources: Downloading CVS CVS servers run on most Unix variants and Windows. CVS Project Page: http://www.nongnu.org/cvs/ CVS Documentation: http://ximbiot.com/cvs/manual/ Download CVS: http://ftp.gnu.org/non-gnu/cvs/ Download TortoiseCVS (i.e., a CVS Client): http://www.tortoisecvs.org/ Venkat N Gudivada Version Control Tools 6/73
References: Pilato, C.M., Collins-Sussman, B. & Fitzpatrick, B.W. (2008). Version Control with. Cambridge: O Reilly Media, Inc. ISBN: 0596510330. Click Me to find this on Amazon. Venkat N Gudivada Version Control Tools 7/73
References and Resources: Downloading servers run on most Unix variants and Windows. Project Page: http://subversion.apache.org/ Documentation: http://subversion.apache.org/docs/ Download Binary Packages: http://subversion.apache.org/packages.html Download Source Code: http://subversion.apache.org/source-code.html Venkat N Gudivada Version Control Tools 8/73
References: O Sullivan, B. (2009). : The Definitive Guide. Cambridge: O Reilly Media, Inc. ISBN: 0596800673. Click Me to find this on Amazon. Venkat N Gudivada Version Control Tools 9/73
References and Resources: servers run on most Unix variants and Windows. Wiki: http://mercurial.selenic.com/wiki/ Quick Start: http://mercurial.aragost.com/kick-start/ Tutorial: http://mercurial.selenic.com/wiki/tutorial by Example (A Tutorial, PDF format): http://www.jemander.se/byexample.pdf Venkat N Gudivada Version Control Tools 10/73
References and Resources: Downloading An Article on Titled Inside a distributed version control system : http://mercurial.selenic.com/wiki/?action=attachfile&do=get Quick Reference Cards and Cheat Sheets for : http://mercurial.selenic.com/wiki/quickreferencecardsandcheatsheets Download Source and Binary Packages: http://mercurial.selenic.com/wiki/download?action=show&redirect=bin Venkat N Gudivada Version Control Tools 11/73
References: Loeliger, J. (2009). Version Control with : Powerful Tools and Techniques for Collaborative Software Development. Cambridge: O Reilly Media, Inc. ISBN: 0596520123. Click Me to find this on Amazon. Venkat N Gudivada Version Control Tools 12/73
References and Resources: Wiki: http://en.wikipedia.org/wiki/ (software) Home Page: http://git-scm.com/ Documentation: http://git-scm.com/documentation FAQ: https://git.wiki.kernel.org/index.php/faq Venkat N Gudivada Version Control Tools 13/73
References and Resources: User s Manual: http://www.kernel.org/pub/software/scm/git/docs/user-manual.html Tutorial: http://www.kernel.org/pub/software/scm/git/docs/gittutorial.html Cheat Sheet: http://zrusin.blogspot.com/2007/09/git-cheat-sheet.html Download : http://git-scm.com/download Venkat N Gudivada Version Control Tools 14/73
Software Life Cycle Venkat N Gudivada Version Control Tools 15/73
(SCM) Identifying, tracking, and storing all the artifacts of a project. Each artifact is a configuration item (CI). Storage of artifacts in a repository. Managing changes to these artifacts. Tracking and reporting changes to these artifacts. Venkat N Gudivada Version Control Tools 16/73
(SCM) Auditing the SCM process. Managing software builds and releases. Labor-intensive activities. SCM systems help automate these processes. Venkat N Gudivada Version Control Tools 17/73
SCM Goals Baseline safety assures that older versions are still in tact and retrievable. Overwrite safety prevents lost update problem. Reversion be able to revert to a previous version of a CI. Disaster recovery stronger form of reversion. Venkat N Gudivada Version Control Tools 18/73
SCM Activities 1 Configuration Identification 2 Baselines 3 Change Control 4 Version Control 5 Configuration Audits 6 Configuration Status Reporting 7 Release Management and Delivery Venkat N Gudivada Version Control Tools 19/73
Configuration Identification Source and Object Code Project Specifications User Documentation Test Plans and Data Supporting Software Such as Compilers, and Editors Any Artifact that will Undergo Modification or Need to be Retrieved at Some Time after its Creation Venkat N Gudivada Version Control Tools 20/73
CI Tree Venkat N Gudivada Version Control Tools 21/73
Baselines Formally reviewed and approved artifact is a baseline. IEEE Std 1042 defines a baseline as A specification or product that has been formally reviewed and agreed to by responsible management, that thereafter serves as the basis for further development, and can be changed only through formal change control procedures. A baseline is an individual or group of CIs labeled at key project milestones. Venkat N Gudivada Version Control Tools 22/73
Transitioning from One Baseline to the Next Venkat N Gudivada Version Control Tools 23/73
Why Use Baselines? Reproducibility be able to produce a particular software version or set of documentation. Traceability allows to recognize and establish relationships between various project artifacts. Tie test cases to requirements, and requirements to design. Reporting determine all the elements of a baseline. Compare the contents of various baselines. Useful in identifying problems in a release of software. Venkat N Gudivada Version Control Tools 24/73
Change Control CIs undergo change as a result of error correction and enhancement. Change Control (aka Configuration Control) refers to activities to request, evaluate, approve or disapprove, and implement these changes to the baseline. Steps: Identification and Documentation CI is identified and documentation produced. Analysis and Evaluation CI is analyzed for correctness, impact analysis performed. Approval or Disapproval decision made. Verification, Implementation and Release once implemented, verified for correctness and released. Venkat N Gudivada Version Control Tools 25/73
Version Control System: Capabilities (Checkin/Checkout) Repository centralized database for storing artifacts and their versions. Checkin/Checkout Request (checkout) a version, update, and store the new version (checkin). Checked out either locked or unlocked. Concurrent write privileges with branching. Venkat N Gudivada Version Control Tools 26/73
Version Control System: Capabilities (Branching) Team members work on the same set of files concurrently branching. A branch is a private work area in a Version Control System (VCS). Correctly apply changes to common files so that none are lost or overwritten merging. If two sets of changes don t conflict with each other, VCS can perform merge operation automatically. If the two sets of changes conflict, CVS will ask the user to merge the changes manually. Venkat N Gudivada Version Control Tools 27/73
Version Control System: Capabilities (Branching and Merging Changes) Venkat N Gudivada Version Control Tools 28/73
Version Control System: Capabilities (Builds) Support for reliably and reproducibly compile and build an executable from versions of source code files. User can specify which branch of code to build from allows concurrent development. Build process produces logs showing the file versions used in the build. Venkat N Gudivada Version Control Tools 29/73
Version Control System: Capabilities (Version Labeling) Versions are created by applying a label to all files comprising a build. The label is typically a version number (e.g., version 1.0). Labeling allows software versions to easily be referenced and reconstructed. Venkat N Gudivada Version Control Tools 30/73
Configuration Auditing IEEE 1028-2008 defines a software audit as An independent examination of a software product, software process, or set of software processes to assess compliance with specifications, standards, contractual agreements, or other criteria. Goals of a configuration audit are to verify/determine: Proper procedures are followed, such as formal technical reviews. SCM policies, such as those defined by change control, are followed. Whether a software baseline is comprised of the correct configuration items. Performed by quality assurance group. Venkat N Gudivada Version Control Tools 31/73
Configuration Status Reporting Provides the software configuration information. Change and version control processes provide the raw data. Extraction, arrangement, and formation of reports as requested by users. Configuration reports include: Name and version of CIs Approval history of changed CIs Software release contents and comparison between releases Number of changes per CI Average time taken to change a CI Venkat N Gudivada Version Control Tools 32/73
Release Management and Delivery IEEE 12207-1998 defines release management and delivery as master copies of code and documentation shall be maintained for the life of the software product. The code and documentation that contain safety or security critical functions shall be handled, stored, packaged and delivered in accordance with the policies of the organization involved. Venkat N Gudivada Version Control Tools 33/73
Configuration Management Plans IEEE standard for Configuration Management Plans (SCMP) IEEE 828-2005. Venkat N Gudivada Version Control Tools 34/73
CVS Microsoft Visual SourceSafe TM Rational/IBM ClearCase Perforce Venkat N Gudivada Version Control Tools 35/73
Commonly used, open source system. Based on client-server architecture. CVS server stores repository of project files. CVS client software runs on user computers. Venkat N Gudivada Version Control Tools 36/73
Still widely used in many organizations. Essentially a Unix application, though there is a fork for Windows called CVSNT. CVS server is most commonly hosted in a Unix environment. CVS client can run virtually on any computer. Venkat N Gudivada Version Control Tools 37/73
Setting Up a CVS Repository First create a directory in which the CVS repository will be saved. Use cvs init command to set up appropriate directory structure and administrative files. Administrative files are stored in a directory called CVSROOT. cvs -d /usr/local/cvs init Don t mess with files in /usr/local/cvs/cvsroot/ ls /usr/local/cvs/cvsroot/ Venkat N Gudivada Version Control Tools 38/73
Creating a New Project in CVS First tell CVS where to look for your repository by defining the CVSROOT environment variable. export CVSROOT=/usr/local/cvs For organization-wide CVS server across the network, use pserver protocol. export CVSROOT=:pserver:john@cvs.mycompany.com:2401/usr/local/cvs If the repository doesn t support anonymous access, login first. cvs login Venkat N Gudivada Version Control Tools 39/73
Creating a New Project in CVS Import the directory structure cvs import -m Initial message project vendortag releasetag project field refers to the directory that you want to store in CVS vendortag releasetag are rarely used in practice Venkat N Gudivada Version Control Tools 40/73
Creating a New Project in CVS Suppose our project is a module called ShopCoreApi cd /projects/shopcoreapi cvs import -m New Project ShopCoreApi vendortag start ls /user/local/cvs ls /user/local/cvs/shopcoreapi Venkat N Gudivada Version Control Tools 41/73
Checking Out a Project cvs checkout -R ShopCoreApi If the CVS repository is another machine, use pserver protocol with password-based access cvs -d :pserver:john@cvs.mycompany.com:/usr/local/cvs login Venkat N Gudivada Version Control Tools 42/73
Updating and Commiting Updating: cd /projects/shopcoreapi cvs update -RPd Before you commit your changes to the repository, test if someone else has updated cvs update Add any new files to the repository: cvs add src/main/resources/messages.cpp Venkat N Gudivada Version Control Tools 43/73
Commit Changes cvs commit -m made Some Changes Venkat N Gudivada Version Control Tools 44/73
File Version Numbers and Tags CVS keeps track of individual file versions. When a set of changes are committed, each modified file is updated separately. Tags can be used to identify a snapshot of the repository at a specific point in time. Use tags to identify a particular version of your application. Say, you want to mark the current working copy as milestone-iteration-1 cvs tag milestone-iteration-1 Venkat N Gudivada Version Control Tools 45/73
Creating Branches in CVS To create a new branch from the working copy, cvs tag -b production-release-1.0-patches Venkat N Gudivada Version Control Tools 46/73
Using CVS in Windows There are several graphical clients that you can use to manage CVS in Windows. Well known is TortoiseCVS, a graphical CVS client that integrates smoothly into Windows Explorer. Whatever can be done in command line, the same can also be done using TortoiseCVS. Venkat N Gudivada Version Control Tools 47/73
Configuration Management in Eclipse using CVS Eclipse is an Integrated Development Environment (IDE) for software projects. Eclipse is developed by geographically dispersed engineers. Eclipse integrates a built-in CVS GUI. Venkat N Gudivada Version Control Tools 48/73
Two Classes of Eclipse Users Venkat N Gudivada Version Control Tools 49/73
Version Numbering (source: http://wiki.eclipse.org/version Numbering) Venkat N Gudivada Version Control Tools 50/73
CVS Shortcomings Showing its age. Architectural defects and missing features for Java development projects and modern agile development practices. Difficult to move or rename directories makes refactoring difficult or cumbersome. Directory structures are very rigid difficult to delete a directory. Support for non-text files is limited. The notion of atomic commits is totally absent. If you have a choice between CVS and, consider seriously. Venkat N Gudivada Version Control Tools 51/73
One of the best open source products for version control system or software configuration management (SCM). Relatively new product, and is designed to overcome historical shortfalls of CVS. Venkat N Gudivada Version Control Tools 52/73
Revision Numbers and Atomic Updates A revision (revision tree) is a representation of the repository structure and contents at a given point in time. Revisions are the basis for atomic updates. Updating subversion repository is like updating a relational database using transactions. When you commit a set of changes, guarantees that either all of your changes have been integrated into the repository or none. stores successive representations of the entire repository structure as a whole. The log function makes it easy to get a summary of the changes made in a particular revision. Venkat N Gudivada Version Control Tools 53/73
Fast Branching and Tagging In CVS every single file must be individually tagged, which is time consuming. In, tagging a new version is simply copying the current repository into another directory on the server. Np physical copying is actually done, simply a logical reference is made. Tagging is extremely fast, and consumes very little disk space. Similar mechanism is used for branching. Venkat N Gudivada Version Control Tools 54/73
Lightweight Network Transactions Provides excellent network performance when dealing with large binary files. Quantity of data sent over the network is proportional to the size of your modifications, and not to the size of your files. (client) stores a local copy of the original repository files. Operations such as diff and revert are done without accessing the server. Venkat N Gudivada Version Control Tools 55/73
Handling Binary Files All files are internally stored as binary files. Only the binary differences between the revisions are stored on the server. Venkat N Gudivada Version Control Tools 56/73
Installing Recommended to use binary installation package. For Windows, you can download graphical installer packages for both and Python bindings. You need Python bindings if you plan to use Trac. Trac is an open source, lightweight issue tracking and project management tool that builds on. For many Linux distributions, prebundled installation packages are available. On Ubuntu, for example, sudo apt-get install subversion libapache2-svn Venkat N Gudivada Version Control Tools 57/73
Installing If you want to install Trac on a Linux server, may need to build with correct Python bindings. To use through your Apache server, may need to build and install the Apache modules. Building from source code is not a trivial task. Venkat N Gudivada Version Control Tools 58/73
Repository Types For a new project, first decide on where to store the source code repository and in what form. Choice of two storage systems: Berkeley DB database or as a set of flat files (aka FSFS). Berkeley DB database is not portable from one OS to another. Berkeley DB database repositories don t work well on shared network drive (might be different now). Berkeley DB database may end up in an unstable and inaccessible state if a client suddenly crashes. If you use FSFS, each revision tree is stored as a single file. All revision trees are stored in the same special directory. Venkat N Gudivada Version Control Tools 59/73
Setting Up a Repository svnadmin create /path/to/repos for FSFS repository type svnadmin create fs-type bdb /path/to/repos Berkeley DB database On Windows, svnadmin create C\data\svn\dev-repos Examine the repository directory structure with, for example, ls /data/svn/dev-repos/ Venkat N Gudivada Version Control Tools 60/73
Setting Up a New Project Convention for subdirectory structures in the project directory: trunk/, tags/, branches/ Main development work is stored in trunk/ Project repository snapshots in tags/ Named branches coming off the main development line in branches/ The easiest way to create a new project is to create an empty directory in a temporary directory, and then import this directory structure into. Venkat N Gudivada Version Control Tools 61/73
Setting Up a New Project $ pwd /home/doe $ mkdir svn-tmp $ cd svn-tmp $ mkdir myproject $ mkdir myproject/trunk $ mkdir myproject/tags $ mkdir myproject/branches Venkat N Gudivada Version Control Tools 62/73
Setting Up a New Project Assume that the repository is in /data/svn/dev-repos directory. $ svn import. file:///data/svn/dev-repos -m Initial repository structure Using the HTTP protocol, $ svn import. http://myserver/svn/dev-repos -m Initial repository structure You don t need the temporary directory anymore. Venkat N Gudivada Version Control Tools 63/73
Checking Out Your Working Copy Decide on where your project is going to stay on your computer, say, /projects $ mkdir /projects $svn checkout file:///data/svn/dev-repos/myproject/trunk myproject To import existing files, $ svn import newproject file:///data/svn/dev-repos/newproject/trunk -m Initial Import Venkat N Gudivada Version Control Tools 64/73
Other Commands list mkdir update add copy delete move status commit Venkat N Gudivada Version Control Tools 65/73
Unlike CVS and SVN, is truly distributed system. Gives each developer a local copy of the entire development history. Independent of network access or a central server. Committing, branching and merging are fast and cheap. Venkat N Gudivada Version Control Tools 66/73
Installing For Debian-based Linux computer, which has the apt program manager, $ sudo apt-get install mercurial $ hg version Venkat N Gudivada Version Control Tools 67/73
Creating a Repository $ mkdir hg1 $ cd hg1 $ hg init Venkat N Gudivada Version Control Tools 68/73
Adding Files $ hg add file1 Venkat N Gudivada Version Control Tools 69/73
is a distributed version control system. does not use a centralized server. runs on Linux, BSD, Solaris, Darwin, Windows, Android and other operating systems Venkat N Gudivada Version Control Tools 70/73
Commands $ git init $ git add. $ git add file1 file2 file3 $ git diff $ git status $ git commit Venkat N Gudivada Version Control Tools 71/73
Commands $ git log $ git branch $ git branch experimental $ git checkout experimental $ git merge experimental Venkat N Gudivada Version Control Tools 72/73
and Comparison: http://www.wikivs.com/wiki/ vs and Comparison: https://git.wiki.kernel.org/index.php/svncomparsion Venkat N Gudivada Version Control Tools 73/73