<<

Concurrent Versions System Introduction (CVS) • Motivations for : • 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. • – updates repository from working copy. • – 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 • cvs update is probably the most important command: • Creates the working directory structure and copies • Copies any new files to the working directory. files to it from the repository. • Updates working directory files where possible. • Notes potential conflicts between working copy and • Once you have the working directory, it is easy to add repository. files or subdirectories to the project. • Informs you when you have made changes to files. • Others can checkout the latest working directory as they join the project. 9 10

Making Edits – 2: commit Adding files or subdirectories: add

• cvs commit • Updates the repository copy with changes in • cvs add the working copy. • Schedules the file or directory to be added to • Prompts you to enter a log message. the CVS repository. • Responds when changes conflict with changes • Files must be committed before actually being made by others. put in the repository. 11 12

2 Comparing files: diff Tracing the history: log

• cvs diff • cvs log • Shows difference between repository copy and working copy of a file. • Shows the list of log messages that have been entered as changes to the file were committed. • Can also specify revisions of file. • 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 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 • Could also recover for a particular date, but

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 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 • 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 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