DOC PREVIEW
Berkeley COMPSCI 164 - Version Control Lecture 4

This preview shows page 1-2 out of 6 pages.

Save
View full document
View full document
Premium Document
Do you want full access? Go Premium and unlock all 6 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 6 pages.
Access to all documents
Download any document
Ad free experience
Premium Document
Do you want full access? Go Premium and unlock all 6 pages.
Access to all documents
Download any document
Ad free experience

Unformatted text preview:

11/29/2009 Prof. Hilfinger CS164 Lecture 4 1Version ControlLecture 41/29/2009 Prof. Hilfinger CS164 Lecture 4 2Administrivia• In order to do the homework and turn in theproject, you must have run set-keys. Do sotoday!• HW assignment will be posted Friday (for nextFriday)• Reading for Tuesday: Notes §2.1-2.71/29/2009 Prof. Hilfinger CS164 Lecture 4 3The Problem• Software projects can be large and complex.• May involve many people, geographicallydistributed• May require maintenance of several relatedversions– MacOS vs. Windows vs. GNU Linux– Stable release vs. beta release of next version– Commericial vs. non-commercial• May require prototyping potential featureswhile still maintaining existing ones.1/29/2009 Prof. Hilfinger CS164 Lecture 4 4Version-Control Systems• Version-control systems attempt to addressthese and related problems.• Allow maintenance and archiving of multipleversions of a piece of software:– Saving complete copies of source code– Comparing versions– Merging changes in several versions– Tracking changes1/29/2009 Prof. Hilfinger CS164 Lecture 4 5Subversion• Subversion is an open-source version-controlsystem.• Successor to CVS• Provides a simple model: numbered snapshotsof directory structures• Handles local or remote repositories1/29/2009 Prof. Hilfinger CS164 Lecture 4 6Subversion’s Modeladd Yadd Xadd ZXYZUser 1User 2Repository21/29/2009 7Subversion’s ModelXYZXYZcommitUser 1User 2Repository1XYZcheckout1/29/2009 8Subversion’s ModelXZXYZUser 1User 2Repository1XYZDelete YQAdd QModify Z1/29/2009 9Subversion’s ModelXZXYZUser 1User 2Repository1XYZQ2XZQcommit10Subversion’s ModelXZXYZUser 1User 2Repository1Q2XZQXZQupdate11Subversion’s ModelXZXYZUser 1User 2Repository1Q2XZQXZQXZQ3commitModify XModify X12Subversion’s ModelXZXYZUser 1User 2Repository1Q2XZQXZQXZQ3updatemerged text31/29/2009 Prof. Hilfinger CS164 Lecture 4 13Terminology• Repository: Set of versions• Revision: A snapshot of a particular directoryof files• Revision number: A sequence number denotinga particular revision• Working copy: A directory or file initiallycopied from a revision + administrative data1/29/2009 Prof. Hilfinger CS164 Lecture 4 14A Useful Property• In the previous example, Subversion does notreally keep 3 complete copies of the files.• Instead, it maintains differences betweenversions: if you change little, your revisiontakes up little space.• Copying an entire file or directory in therepository is very cheap– “Directory foo in revision 110 is the same asdirectory bar in revision 109”1/29/2009 Prof. Hilfinger CS164 Lecture 4 15Some Basic Commands• We’ll be using “ssh tunnels” to access ourSubversion repositories.• We created an ssh key pair for you when youfirst logged in.• In the following, we consider login cs164-xxand team Ursa; we’ll use nova as a convenienthost.1/29/2009 Prof. Hilfinger CS164 Lecture 4 16Creating a working copy of a repository• To get the latest revision of projects: svn co svn+ssh://cs61b-ta@nova/Ursa/trunk mydir• Or just one directory: svn co svn+ssh://cs61b-ta@nova/Ursa/trunk/proj1 \ mydir• A particular revision: svn co -r100 \ svn+ssh://cs61b-ta@nova/Ursa/trunk/proj1 old11/29/2009 Prof. Hilfinger CS164 Lecture 4 17Some useful (local) abbreviations• On instructional accounts, I have defined afew shortcuts:– $REPOS = svn+ssh://[email protected]/cs164-xx- $STAFF = svn+ssh://[email protected]/staff- $TEAMREPOS = svn+ssh://[email protected]/URSAI’ll use these from now on.1/29/2009 Prof. Hilfinger CS164 Lecture 4 18Abbreviated commands• To get the latest revision of projects: svn co $TEAMREPOS/trunk mydir• Or just one directory: svn co $TEAMREPOS/trunk/proj1 mydir• A particular revision: svn co -r100 $TEAMREPOS/trunk/proj1 old141/29/2009 Prof. Hilfinger CS164 Lecture 4 19Add, Delete, Rename Files, Directories• When you add or remove a file or directory ina working copy, must inform Subversion of thefact:– svn add NEW-FILE– svn delete OLD-FILE-OR-DIR– svn move OLD-PLACE NEW-PLACE• These forms don’t change the repository, justyour personal working directory.• Must commit changes to change repository.1/29/2009 Prof. Hilfinger CS164 Lecture 4 20Reverting• Before committing, can undo adds, removes,modifications.• The command % svn revert FILEundoes changes to FILE.• Reverting a modification or delete restoresfile.• Reverting an add removes FILE from versioncontrol.1/29/2009 Prof. Hilfinger CS164 Lecture 4 21Committing Changes• The command svn commit -m “Log message” in a working directory will create a newrevision in the repository• New revision differs from previous in thecontents of the current directory, which mayonly be part of the whole tree.• Message should be informative. If you leaveoff the -m, will call your favorite editor.1/29/2009 Prof. Hilfinger CS164 Lecture 4 22Updating• To get versions of files from most recentrevision, do this in directory you want updated svn update• This will report files Subversion changes,adds, deletes, or merges• Merged files are those modified both by youand (independently) in the repository since youupdated/checked out.1/29/2009 Prof. Hilfinger CS164 Lecture 4 23Merges and Conflicts• Reports of changes look like this: U foo1 foo1 is updated A foo2 foo2 is new D foo3 foo3 was deleted R foo4 foo4 was deleted, then re-add G foo5 foo5 had mods from you and in repository that did not overlap C foo6 Conflicts: overlapping changes1/29/2009 Prof. Hilfinger CS164 Lecture 4 24Notating Conflicts• When you have a conflict, you’ll find that theresulting file contains both overlappingchanges: <<<<<<<<< .mine My change ======== Repository change >>>>>>>>>>> .r 99 (gives revision #)51/29/2009 Prof. Hilfinger CS164 Lecture 4 25Resolving Conflicts• You can either choose to go with therepository version of conflicted file, or yours,or do a custom edit.• Subversion keeps around your version and therepository version in foo6.mine, foo6.99• Personally, I usually just edit the file.• When conflicts are resolved, use svn resolved foo6 to indicate resolution; then commit.1/29/2009 Prof. Hilfinger CS164 Lecture 4 26Branches and Tags• Suppose Bob wants to make some changes to hisproject, checking in intermediate steps, but withoutinterfering with partner Mary.• Good


View Full Document

Berkeley COMPSCI 164 - Version Control Lecture 4

Documents in this Course
Lecture 8

Lecture 8

40 pages

Load more
Download Version Control Lecture 4
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 Version Control Lecture 4 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 Version Control Lecture 4 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?