Unformatted text preview:

1Problem 1: Working SoloHow do you keep track of changes to your program?Option 1: Don't botherHope you get it right the first timeHope you can remember what changes you made if you didn't(You probably won't get it right)(Or remember)(You will end up rewriting code)(I do!)Working solo (cont'd)Option 2: Periodically save “backups”Save snapshots of your program in another directory or under a different nameE.g. Main.1.java, Main.2.javaOr save it in a directory by dateProblems:Totally ad hocOnly the programmer knows how to interpret the namesHard to pick a version to go back toProne to errorNo tools to help youProblem 2: Working in a TeamHow do you coordinate who has the authority to change a file?Worry about it after the fact“Hey, why is this broken?”“My changes got overwritten!”“You weren't supposed to change that file.”Exchange email“Okay, I'm going to work on A.java, so don't touch it.”Problem 3: Moving AroundAfter a hard day of work in the lab, you want to go home and do some work at home in the evening.How do you know which files to copy to your home machine?Copy everythingpotentially slowmight overwrite something you did at home, but forgot to copy from home to schoolTry to remember what changedhighly likely to get it wrong2Solution: Version ControlKeep code in a central location (“repository”)This is the master copyNever directly modify this directoryCreate a local copy of the repository in your account at school, on your machine at home, on your laptop...CommitWhen the local copy changes, “commit” the changes to the repositorySolving Problem 1When you get something working, commit the changesTools allow you to revert to a previous versionWrite good log messages so that you don't have to remember what changed in each versionManaging ConcurrencyWhat if two (or more) people want to edit the same file at the same time?Option 1: prevent itOnly allow one writeable copy of the filePessimistic concurrency Microsoft Visual SourceSafeOption 2: patch up afterwardOptimistic concurrency"Easier to get forgiveness than permission"CVS, Perforce, Subversion3Optimistic Angela commits changesHassan tries to commit changesHassan updates his version4Hassan now commits ConflictTo resolve a conflict, Hassan must manually fix the conflict before he commits<<<<<<< a.javaIterator i = changedGroups.iterator();while (i.hasNext()) {if (userNotInGroup(currentUser, (Group) i.next())) {addUserToGroup(currentUser, (Group) i.next()));}}=======Iterator i = changedGroups.iterator();while (i.hasNext()) {Group g = (Group)i.next();if (userNotInGroup(currentUser, g)) {addUserToGroup(currentUser, g));}}>>>>>>> 1.3Storage SchemeStoring entire copy of a file on every change would require an enormous amount of disk spaceVersion control systems store incremental differencesThe incremental differences allow the system to reconstruct previous versionsCVS“Concurrent Version System”Background information:Each project is called a moduleCommand-line tool on Unix and WindowsBuilt on top of older system called RCSSeveral graphical and web interfacesThe Eclipse IDE has a CVS featureWe will create one repository for each of youYou will use CVS to submit work in this course!First step: set your CVSRO OT environment variable5Common CVS Commandscvs checkout [module] Get initial copyDo this every time you want to get a new copy of moduleRecommended step: check out fresh copy after you commit the version you want us to mark, and test itIf that repository is up to date, it is okay to delete the working copycvs add [filenames] Add new filesNotifies CVS that you want it to track the new filesadd almost always be followed by a com mit: add doesn't actually modify the repositoryCommon CVS Commandscvs update [filenames] Synchronize with repositoryCopies stuff from the master repository to your local copyAny commits made by another person or commits done by you from another local copy will be updated in your local copyDoes not change the repositoryWatch the messages closelycvs com mit [filenames] Commit local changesCopy changes to the repositoryWill only be allowed if local copy is up to dateCommon CVS Commandscvs remove [filenames] Remove files from repositoryMust first remove the file from the local copyIt is not easy to remove directoriescvs diff [filenames] Show diffs between localcopy and repositoryHandy to see what changed between versionscvs log [filenames] Show history of filesShows log message, timestamps and who made the revisionsKeyword ExpansionCVS replaces strings like $Keyword:$ with associated value during check-in$Author: pgries $$Date: 2004/05/11 02:51:33 $Always in Universal Time$Revision: 1.1.1.1 $6Keyword ExpansionOften embed these values in strings, rather than in commentsclass Something implements Versioned {public static final String VERSION = "$Revision: 1.1.1.1 $";public String getVersion() {return VERSION.split(' ')[1].trim();}}File TypesCVS treats files as text by defaultTries to perform keyword expansionTries to translate Unix and Windows line endingsOften don't want thisE.g. image filesAdd with cvs add -kb filenamekb means "binary"Manual explains how to set file type after the factWhat To Check InDon't check in files that are automatically created from others. E.g..class filesUses disk space and bandwidth for no reasonDo check in:Your own little test programsAnd their expected outputReadme files, notes, build logs, etc.Anything else you created by handWhen To Check InVersion control is not a backup systemYour computer should have one of thoseDon't check in just because you're taking a break to surf the webCheck in files when they are stableE.g. after adding a new featureOr when you have to move from location to locationE.g. from home to school or vice


View Full Document

Toronto CSC 309H - Working Solo

Download Working Solo
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 Working Solo 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 Working Solo 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?