Introduction
Concurrent Versions System (CVS)
• Motivations for version control: • Track changes to a project. • Synchronize changes of multiple developers. • Handle conflicts in development. • “Release” versions periodically.
• Additional Features • Back up to previous versions
Brian Hargreaves (Marketing / Sales)
Juan Santos (Expert)
• Create branch versions. 1
CVS Basics
CVS - Frequent Commands
Working Copy
Person
2
Repository
• Checkout – gets working copy from repository. • Update – updates working copy from repository.
Master Copy
• Add – adds a new file/directory to the project. • Remove – removes a file/directory from the project. • Commit – updates repository from working copy. • Diff – compares working copy to repository.
CVS
• Log – shows the change log messages. 3
Why use CVS?
4
Where to use CVS
• Keep track of changes for you/others.
• Code or pulse sequences (.e, .c, .h files) • Track versions that are used by others.
• Synchronize projects: • Multiple developers.
• Matlab files (.m, .mex)
• Linux / unix / laptops.
• Web pages (.html)
• Different operating systems.
• LaTeX (.tex)
• Redundancy
• Register binary files or .eps files.
• Work when the networks go down! • Inherent backup. 5
6
1
Creating the Repository: init
Starting a Project: import
• Only have to do this once! • Create a directory, preferrably on a backed-up system:
• Puts the project into the repository
cvs –d ~/cvsroot init
• The project administrator only has to do this once:
• Set environment variable CVSROOT in .cshrc/.bashrc:
• Make the desired directory structure. • cvs import –m “message” project
• CVS commands will now default to this repository.
• Now erase the directory structure (weird part!) 7
Joining a Project: checkout
Making Edits – 1: update
• cvs checkout
• cvs update
is probably the most important command:
• Copies any new files to the working directory.
• Creates the working directory structure and copies files to it from the repository.
• Updates working directory files where possible.
• Once you have the working directory, it is easy to add files or subdirectories to the project. • Others can checkout the latest working directory as they join the project.
8
• Notes potential conflicts between working copy and repository. • Informs you when you have made changes to files.
9
Making Edits – 2: commit
10
Adding files or subdirectories: add
• cvs commit
• cvs add
• Updates the repository copy with changes in the working copy. • Prompts you to enter a log message.
• Schedules the file or directory to be added to the CVS repository.
• Responds when changes conflict with changes made by others.
• Files must be committed before actually being put in the repository. 11
12
2
Comparing files: diff
Tracing the history: log
• cvs diff • Shows difference between repository copy and working copy of a file. • Can also specify revisions of file.
• cvs log • Shows the list of log messages that have been entered as changes to the file were committed. • Lists the user who made the changes.
13
14
Example
Conflicts The primary use of MRI is for diagnosing musculoskeletal disorders
Why waste time imaging the knee when you can image the heart? 15
Conflicts
16
Resolving Conflicts • After attempted commit, User B runs cvs update
• Sometimes two users make changes to a particular version that conflict.
• Conflicting text appears in file: > 1.9
• User A commits changes as usual. • When User B commits changes, an error is reported. • User B must resolve the conflict.
• User B fixes the conflict and commits change. 17
18
3
Avoiding Conflicts
Tags
• Conflicts happen when two users modify the same revision. • Frequent cvs update commands help reduce conflicts.
• cvs tag release-1.0 • Sometimes (when code actually works!) nice to stamp all files of a project. • Can get back appropriate source files: • cvs checkout -r release-1.0
19
Branches
• Could also recover for a particular date, but Juan says this isn’t as good!
20
Tags, Revisions, Branches and Bug Searches
• Nice because you can officially create a branch of code for someone else to work on.
• Last-resort bug search is to “converge” on what is causing the bug.
• Can merge branches later on.
• Start with version that worked, and version that has the bug.
• Can patch changes in both branches.
• Merging these toward each other you hopefully converge on the bug. • Branches, Tags and revisions simplify this. 21
Directory Structures
22
Remote Repositories
• Adding directories:
• CVS commands can run through rsh or ssh.
cvs add
• Nice way to synchronize file systems.
• CVS commands from different directories:
• Inherent backup.
• From base directory, apply to all subdirectories. • From subdirectory, applies to that and lower directories.
• Example…
• /CVS directories: • Exist in any subdirectory of a project. • Tell where the repository for that project is – cool! 23
24
4
CVS Interfaces
CVS Links
• Command-line (built-in linux/unix)
• Full manual:
www.cvshome.org
• Windows (Example)
• Windows:
www.wincvs.org
• Mac
• Mac:
www.maccvs.org
• Web interface (Example)
• MRSRL How-to: www-mrsrl/cvs/ • Getting Started:
www-mrsrl/~brian/cvstutorial
25
CVS and Laptops
26
Binary Files • CVS can track “binary” files too:
• In ~/cvsroot/ :
cvs add –kb
tex/, public_html/ epic/, matlab/
• Update and commit as with text files. • Uses more space in repository.
• Folders on laptop, in “My Documents” tex, public_html, epic, matlab
• Nice for .eps figures for LaTeX documents • Edit figures on Illustrator in Windows. • CVS to transfer to unix/linux for LaTeX.
• At most 4 “cvs updates” and we’re done! • Laptop work gets backed up in the process. 27
Keyword Substitution
EPIC Example
• CVS can add info to files:
• Working directory on gag or linux machines.
/* $Log$
%
• PSD repository gets backed up.
Adds log messages on commit.
*/ $Id$
28
• Others can track your development.
revision / date / user.
• Maintain a “clinical” sequence while continuing development (branch).
• Other keywords: $Author$ $Date$ $Header$ $Revision$ …and others!
• cvs diff gives a nice view of what it took to upgrade to CNV3. 29
30
5
Grant Proposals?!
So, Why use CVS?
• Current scheme: everyone edits same files.
• You won’t have to worry with backups.
• CVS:
• Organization of group-efforts is easier.
• No longer need everyone to work on quench.
• Keep file systems synchronized.
• Can recover earlier revisions.
• Do a favour for your successors.
• Changes can be merged smoothly. • Conflicts can be resolved.
31
32
Final Word • In ½ hour you can be using CVS. • Excellent for C, EPIC, HTML, LaTeX, Matlab.
33
6