Concurrent Versions System Introduction (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 Juan Santos • Create branch versions. (Marketing / Sales) (Expert) 1 2
CVS Basics CVS - Frequent Commands
Person Working Copy 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. • Log – shows the change log messages. CVS 3 4
Why use CVS? Where to use CVS
• Keep track of changes for you/others. • Code or pulse sequences (.e, .c, .h files) • Synchronize projects: • Track versions that are used by others. • 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 • Set environment variable CVSROOT in once: .cshrc/.bashrc: • Make the desired directory structure. • CVS commands will now default to this repository. • cvs import –m “message” project • Now erase the directory structure (weird part!)
7 8
Joining a Project: checkout Making Edits – 1: update
• cvs checkout
Making Edits – 2: commit Adding files or subdirectories: add
• cvs commit
2 Comparing files: diff Tracing the history: log
• cvs diff
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 16
Conflicts Resolving Conflicts
• After attempted commit, User B runs cvs update • Sometimes two users make changes to a • Conflicting text appears in file: particular version that conflict. <<<<<<< sample.tex These changes made by User B might • User A commits changes as usual. conflict. ======• When User B commits changes, an error is These are the changes that User A made. reported. >>>>>>> 1.9 • 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. • cvs tag release-1.0 • Frequent cvs update commands help reduce conflicts. • 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 Juan says this isn’t as good! 20
Branches Tags, Revisions, Branches and Bug Searches
• Nice because you can officially create a • Last-resort bug search is to “converge” on branch of code for someone else to work 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 22
Directory Structures Remote Repositories
• Adding directories: • CVS commands can run through rsh or ssh. cvs add
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 26
CVS and Laptops Binary Files
• In ~/cvsroot/ : • CVS can track “binary” files too: tex/, public_html/ epic/, matlab/ cvs add –kb
• Update and commit as with text files. • Folders on laptop, in “My Documents” • Uses more space in repository. tex, public_html, epic, matlab • Nice for .eps figures for LaTeX documents • At most 4 “cvs updates” and we’re done! • Edit figures on Illustrator in Windows. • Laptop work gets backed up in the process. • CVS to transfer to unix/linux for LaTeX.
27 28
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. • Others can track your development. % $Id$ revision / date / user. • Other keywords: • Maintain a “clinical” sequence while continuing $Author$ development (branch). $Date$ $Header$ • cvs diff gives a nice view of what it took to $Revision$ upgrade to CNV3. …and others! 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. • Changes can be merged smoothly. • Do a favour for your successors. • Conflicts can be resolved.
31 32
Final Word
• In ½ hour you can be using CVS. • Excellent for C, EPIC, HTML, LaTeX, Matlab.
33
6