DOC PREVIEW
UW CSE 303 - Lecture Notes

This preview shows page 1-2-3-4 out of 12 pages.

Save
View full document
View full document
Premium Document
Do you want full access? Go Premium and unlock all 12 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 12 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 12 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 12 pages.
Access to all documents
Download any document
Ad free experience
Premium Document
Do you want full access? Go Premium and unlock all 12 pages.
Access to all documents
Download any document
Ad free experience

Unformatted text preview:

'&$%CSE 303:Concepts and Tools for Software DevelopmentDan GrossmanSpring 2005Lecture 23— Version control, shared files, cvsDan Grossman CSE303 Spring 2005, Lecture 23 1'&$%Where are WeLearning tools and concepts relevant to multi-file, multi-person,multi-platform, multi-month projects.Today: Managing source code• Reliable backup of hard-to-replace information (i.e., the sourcecode)• Tools for managing concurrent and potentially conflicting changesfrom multiple people• Version numbe rs, ability to “rollback” or at least see thedifferences with previous versions.Note: None of this has anything to do with code. Like make,version-control systems are typically not language-specific.• I use cvs (a version-control system) for papers I write too.• But cvs is better at plain-text (for detecting differences)Dan Grossman CSE303 Spring 2005, Lecture 23 2'&$%Version-control systemsThere are plenty: rcs, cvs, subversion, sourceforge, SourceSafe,...The terminology and commands aren’t so standard, but once youknow one, the others s houldn’t be difficult.cvs is actually a layer over rcs.Weakpoint of cvs: renaming files or (worse) directories.Dan Grossman CSE303 Spring 2005, Lecture 23 3'&$%The set-upThere is a cvs repository, where files (and past versions) are reliablystored.• Hopefully the repository files are backed up, but that’s not cvs’sproblem.You do not edit files in the repository directly. Instead:• You check-out a working copy and edit it.• You commit changes back to the repository.You use the cvs program to perform any operations that need therepository.One repository may hold many projects. (The repository itself just hasa directory structure.)Dan Grossman CSE303 Spring 2005, Lecture 23 4'&$%Questions• How do you set-up:– A repository (init)– A project in a repository (import)– A working copy of a project in a repository (checkout)• How do you edit files:– Get latest updates of a project (update)– Add or remove files (add or remove)– Put changes back in repository (commit)• How do you get inform ation about:– History of revisions (log)– Difference between versions (diff)• Other (branches, loc ks, watches, ...)Dan Grossman CSE303 Spring 2005, Lecture 23 5'&$%Common vs. uncommonLearn the common c ases; look up the uncommon ones:• You will set up new repositories approx. once eve ry 5 years• You will add a project approx. once a year• You will checkout a project approx. once a month• You will update your working copy and update the repositoryapprox. once a day.Nonetheless, the command-structure for all of these is similar:cvs cvs-options cmd cmd-options filenamesExamples:cvs -d ~djg/cvsroot checkout foocvs update -P fooDan Grossman CSE303 Spring 2005, Lecture 23 6'&$%Getting startedSet up a repository and project.• Remember, I have to look up the commands for this.Accessing the repository:• From the same machine, just specify the root via a path name(-d).• After the checkout, the working-copy “remem bers” the repositoryso -d is unnecessary.• Can access remotely by specifying user-id and machine.– Must have cvs and ssh installed on your loc al machine– Will be prompted for password.– How I w rite code with people in other time zones.– I recommend you not spend the time to set this up for hw6.Dan Grossman CSE303 Spring 2005, Lecture 23 7'&$%File manipulation• Add files with cvs add.• Get files with cvs update.• Commit changes with cvs commit.– Any number of files (no filename means all files in directoryand all transitive subdirectories)– Added files not really added until commit (unliked directories)Commit messages are mandatory:• -m "a short message"• -F filename-containing-message• else an editor pops up– vi unless you se t environment variable VISUAL (or EDITOR?)– learn how to quit vi :) (or learn vi)Dan Grossman CSE303 Spring 2005, Lecture 23 8'&$%ConflictsThis all works great if there is one working-copy: you keep oldversions, can see their differences, etc.With multiple working-copies there can be conflicts:1. Your working-copy chec ks out ve rsion 1.7 of foo.2. You edit foo.3. Somebody else commits a new version (1.8) of foo.You cannot commit; you must update foo. What about your changes?• If you’re nervous, make a copy of foo locally first.• But cvs will use diff and patch to merge the changes between1.7 and 1.8 into your working-copy foo.• Merging is line-based, which is why cvs is better for text files.• Conflicts indicated in the working-copy file (search for <<<<<<).Dan Grossman CSE303 Spring 2005, Lecture 23 9'&$%It’s all just files and diffThere is very little magic to cvs; you can poke around to see how it’simplemented:• The repository just uses directories and files.• Files are kept read-only to avoid “mistakes” (cvs commandtemporarily changes that and changes it back)• Files are kept in terms of diffs (so small changes lead to smallincrease in repository size, even for large files)• Set group permissions appropriately (see chgrp if necessary).• Hard part of implementation is preventing simultaneous commitsand other concurrency errors.As for the working copy:• All the “magic” is in the CVS subdirectory.Dan Grossman CSE303 Spring 2005, Lecture 23 10'&$%CVS gotchas• To get new subdirectories to update -P (for hw6, one directoryshould be plenty).• Do not forget to add files or your group members will be veryunhappy.• Keep in the repository exactly what you need to build theapplication!– Yes: foo.c foo.h Makefile– No: foo.o a.out– You don’t want versions of .o files:∗ Replacable things have no value∗ They will change a lot when .c files change a little∗ Developers on other machines can’t use themDan Grossman CSE303 Spring 2005, Lecture 23 11'&$%SummaryAnother tool for le tting the com puter do what it’s good at:• Much better than manually emailing files, adding dates tofilenames, etc.• Managing versions, storing the differences• Keeping source-code safe.• Preventing concurrent access, detecting conflicts.How to “cheat” and throw away somebody else’s changes – don’t!mv foo barcvs update foomv bar foocvs commit -m "muhahaha" foocvs just knows about version numbers and diff; it’s not magic.Dan Grossman CSE303 Spring 2005, Lecture 23


View Full Document

UW CSE 303 - Lecture Notes

Documents in this Course
Profiling

Profiling

11 pages

Profiling

Profiling

22 pages

Profiling

Profiling

11 pages

Testing

Testing

12 pages

Load more
Download Lecture Notes
Our administrator received your request to download this document. We will send you the file to your email shortly.
Loading Unlocking...
Login

Join to view Lecture Notes and access 3M+ class-specific study document.

or
We will never post anything without your permission.
Don't have an account?
Sign Up

Join to view Lecture Notes 2 2 and access 3M+ class-specific study document.

or

By creating an account you agree to our Privacy Policy and Terms Of Use

Already a member?