Prof. Hilfinger CS164 Lecture 4

Slides:



Advertisements
Similar presentations
TortoiseSVN By Group 1 Team B. Installing TortoiseSVN.
Advertisements

 Please sit next to your partner.  If you don’t have a partner, please find one now.
1. What is Subversion? Why do we need CM? Basic concepts Repositories Options Setup Clients Options Setup Operation Troubleshooting Slide 2.
Version Control 1.  Version control (or revision control) is the term for the management of source files, and all of the intermediate stages as development.
Version Control System Sui Huang, McMaster University Version Control SystemSui Huang, McMaster University Version Control System -- base on Subversion.
David Notkin Autumn 2009 CSE303 Lecture 22 Subversion is an open source version control system. Social Implications Friday version control system.
2/6/2008Prof. Hilfinger CS164 Lecture 71 Version Control Lecture 7.
Using subversion COMP 2400 Prof. Chris GauthierDickey.
Source Code Revision Control with Subversion Christophe Dupré May 13, 2005 Update KEJ May 10, 2006 Scientific Computation Research Center Rensselaer Polytechnic.
Low level CASE: Source Code Management. Source Code Management  Also known as Configuration Management  Source Code Managers are tools that: –Archive.
Source Control Repositories for Enabling Team Working Svetlin Nakov Telerik Corporation
SubVersioN – the new Central Service at DESY by Marian Gawron.
Source Code Revision Control Software CVS and Subversion (svn)
Prof. Aiken CS 169 Lecture 71 Version Control CS169 Lecture 7.
Version Control with git. Version Control Version control is a system that records changes to a file or set of files over time so that you can recall.
Git for Version Control These slides are heavily based on slides created by Ruth Anderson for CSE 390a. Thanks, Ruth! images taken from
Version Control with Subversion. What is Version Control Good For? Maintaining project/file history - so you don’t have to worry about it Managing collaboration.
1 Topics for this Lecture Software maintenance in general Source control systems (intro to svn)
Subversion. What is Subversion? A Version Control System A successor to CVS and SourceSafe Essentially gives you a tracked, shared file system.
The Design Workshop Introduction to Version Control 1.
Version Control with Subversion Quick Reference of Subversion.
Git – versioning and managing your software L. Grewe.
Subversion (SVN) Tutorial for CS421 Dan Fleck Spring 2010.
Object-Oriented Software Engineering Using UNIX groups and Subversion Estimated Time: minutes “Unix is user-friendly. It's just very selective about.
Version control Using Git Version control, using Git1.
Git workflow and basic commands By: Anuj Sharma. Why git? Git is a distributed revision control system with an emphasis on speed, data integrity, and.
Object-Oriented Analysis & Design Subversion. Contents  Configuration management  The repository  Versioning  Tags  Branches  Subversion 2.
CSE 219 Computer Science III CVS
12 CVS Mauro Jaskelioff (originally by Gail Hopkins)
Part 4: FCM and the UM University of Reading, December 2015.
Version Control and SVN ECE 297. Why Do We Need Version Control?
Introduction to Git Yonglei Tao GVSU. Version Control Systems  Also known as Source Code Management systems  Increase your productivity by allowing.
1 CSE 303 Lecture 19 Version control and Subversion ( svn ) slides created by Marty Stepp
(1) Introduction to Subversion (SVN) and Google Project Hosting Philip Johnson Collaborative Software Development Laboratory Information and Computer Sciences.
(1) Introduction to Subversion (SVN) and Google Project Hosting Philip Johnson Collaborative Software Development Laboratory Information and Computer Sciences.
Subversion (SVN) Tutorial for CS421 Dan Fleck Spring 2010.
Source Control Repositories for Enabling Team Working Doncho Minkov Telerik Corporation
CS520 Web Programming Version Control with Subversion Chengyu Sun California State University, Los Angeles.
1 Subversion Kate Hedstrom April Version Control Software System for managing source files –For groups of people working on the same code –When.
Git A distributed version control system Powerpoint credited to University of PA And modified by Pepper 28-Jun-16.
Problem Solving With C++ SVN ( Version Control ) April 2016.
CS491A Software Design Lab Version Control with CVS and Subversion Chengyu Sun California State University, Los Angeles.
Source Control Dr. Scott Schaefer. Version Control Systems Allow for maintenance and archiving of multiple versions of code / other files Designed for.
Version Control Systems
CS5220 Advanced Topics in Web Programming Version Control with Git
Version Control CS These slides were created by Kevin Schenk, BS in Computer Science, Purdue University, 2012.
Version Control with Subversion
CReSIS Git Tutorial.
SVN intro (review).
LECTURE 2: Software Configuration Management
Source Control Dr. Scott Schaefer.
Version Control CS These outstanding slides were created by Kevin Schenk, BS in Computer Science, Purdue University, 2012.
Subversion Reasons to use How it works Subversion important commands
Version Control with Subversion (SVN)
Version control, using Git
CSE 303 Concepts and Tools for Software Development
CS5220 Advanced Topics in Web Programming Version Control with Git
Development and Deployment
Subversion.
Version Control Systems
Concurrent Version Control
Version Control System
LECTURE 3: Software Configuration Management
slides borrowed and adapted from Alex Mariakis and CSE 390a
Compilers, Make and SubVersion
Subversion Basics Guide
Git CS Fall 2018.
Introduction to Version Control with Git
Version Control CS169 Lecture 7 Prof. Aiken CS 169 Lecture 7.
Systems Analysis and Design I
Presentation transcript:

Prof. Hilfinger CS164 Lecture 4 Version Control Lecture 4 1/29/2009 Prof. Hilfinger CS164 Lecture 4

Prof. Hilfinger CS164 Lecture 4 Administrivia In order to do the homework and turn in the project, you must have run set-keys. Do so today! HW assignment will be posted Friday (for next Friday) Reading for Tuesday: Notes §2.1-2.7 1/29/2009 Prof. Hilfinger CS164 Lecture 4

Prof. Hilfinger CS164 Lecture 4 The Problem Software projects can be large and complex. May involve many people, geographically distributed May require maintenance of several related versions MacOS vs. Windows vs. GNU Linux Stable release vs. beta release of next version Commericial vs. non-commercial May require prototyping potential features while still maintaining existing ones. 1/29/2009 Prof. Hilfinger CS164 Lecture 4

Version-Control Systems Version-control systems attempt to address these and related problems. Allow maintenance and archiving of multiple versions of a piece of software: Saving complete copies of source code Comparing versions Merging changes in several versions Tracking changes 1/29/2009 Prof. Hilfinger CS164 Lecture 4

Prof. Hilfinger CS164 Lecture 4 Subversion Subversion is an open-source version-control system. Successor to CVS Provides a simple model: numbered snapshots of directory structures Handles local or remote repositories 1/29/2009 Prof. Hilfinger CS164 Lecture 4

Prof. Hilfinger CS164 Lecture 4 Subversion’s Model User 1 Repository X Y Z add X add Y add Z User 2 1/29/2009 Prof. Hilfinger CS164 Lecture 4

Subversion’s Model User 1 Repository X Y Z User 2 X Y Z commit 1 checkout User 2 1/29/2009

Subversion’s Model User 1 Repository X X Y Z Q Z User 2 X Y Z Delete Y Add Q Modify Z 1 Z Q Z User 2 X Y Z 1/29/2009

Subversion’s Model User 1 Repository X X Y Z Q Z X User 2 Z Q X Y Z 1 commit Z X 2 User 2 Z Q X Y Z 1/29/2009

Subversion’s Model User 1 Repository X X Y Z Q Z X User 2 Z Q X Z Q 1 update Z Q

Subversion’s Model User 1 Repository X X Y Z Q Z X User 2 Z Q X X Z Q Modify X 1 Z Q Z X 2 User 2 Z Q X Modify X commit X Z Q 3 Z Q

Subversion’s Model User 1 Repository X Y Z Q Z X User 2 Z Q X X Z Q Z merged text X X Y 1 Z Q Z update X 2 User 2 Z Q X X Z Q 3 Z Q

Prof. Hilfinger CS164 Lecture 4 Terminology Repository: Set of versions Revision: A snapshot of a particular directory of files Revision number: A sequence number denoting a particular revision Working copy: A directory or file initially copied from a revision + administrative data 1/29/2009 Prof. Hilfinger CS164 Lecture 4

Prof. Hilfinger CS164 Lecture 4 A Useful Property In the previous example, Subversion does not really keep 3 complete copies of the files. Instead, it maintains differences between versions: if you change little, your revision takes up little space. Copying an entire file or directory in the repository is very cheap “Directory foo in revision 110 is the same as directory bar in revision 109” 1/29/2009 Prof. Hilfinger CS164 Lecture 4

Prof. Hilfinger CS164 Lecture 4 Some Basic Commands We’ll be using “ssh tunnels” to access our Subversion repositories. We created an ssh key pair for you when you first logged in. In the following, we consider login cs164-xx and team Ursa; we’ll use nova as a convenient host. 1/29/2009 Prof. Hilfinger CS164 Lecture 4

Creating 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 old1 1/29/2009 Prof. Hilfinger CS164 Lecture 4

Some useful (local) abbreviations On instructional accounts, I have defined a few shortcuts: $REPOS = svn+ssh://cs164-ta@quasar.cs.berkeley/cs164-xx $STAFF = svn+ssh://cs164-ta@quasar.cs.berkeley/staff $TEAMREPOS = svn+ssh://cs164-ta@quasar.cs.berkeley/URSA I’ll use these from now on. 1/29/2009 Prof. Hilfinger CS164 Lecture 4

Prof. Hilfinger CS164 Lecture 4 Abbreviated 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 old1 1/29/2009 Prof. Hilfinger CS164 Lecture 4

Add, Delete, Rename Files, Directories When you add or remove a file or directory in a working copy, must inform Subversion of the fact: svn add NEW-FILE svn delete OLD-FILE-OR-DIR svn move OLD-PLACE NEW-PLACE These forms don’t change the repository, just your personal working directory. Must commit changes to change repository. 1/29/2009 Prof. Hilfinger CS164 Lecture 4

Prof. Hilfinger CS164 Lecture 4 Reverting Before committing, can undo adds, removes, modifications. The command % svn revert FILE undoes changes to FILE. Reverting a modification or delete restores file. Reverting an add removes FILE from version control. 1/29/2009 Prof. Hilfinger CS164 Lecture 4

Prof. Hilfinger CS164 Lecture 4 Committing Changes The command svn commit -m “Log message” in a working directory will create a new revision in the repository New revision differs from previous in the contents of the current directory, which may only be part of the whole tree. Message should be informative. If you leave off the -m, will call your favorite editor. 1/29/2009 Prof. Hilfinger CS164 Lecture 4

Prof. Hilfinger CS164 Lecture 4 Updating To get versions of files from most recent revision, 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 you and (independently) in the repository since you updated/checked out. 1/29/2009 Prof. Hilfinger CS164 Lecture 4

Prof. Hilfinger CS164 Lecture 4 Merges 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 changes 1/29/2009 Prof. Hilfinger CS164 Lecture 4

Prof. Hilfinger CS164 Lecture 4 Notating Conflicts When you have a conflict, you’ll find that the resulting file contains both overlapping changes: <<<<<<<<< .mine My change ======== Repository change >>>>>>>>>>> .r 99 (gives revision #) 1/29/2009 Prof. Hilfinger CS164 Lecture 4

Prof. Hilfinger CS164 Lecture 4 Resolving Conflicts You can either choose to go with the repository version of conflicted file, or yours, or do a custom edit. Subversion keeps around your version and the repository 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

Prof. Hilfinger CS164 Lecture 4 Branches and Tags Suppose Bob wants to make some changes to his project, checking in intermediate steps, but without interfering with partner Mary. Good practice is to create a branch, a copy of the project files independent of the trunk. Copy command does it: svn copy $TEAMREPOS/trunk \ $TEAMREPOS/branches/Bobs-branch svn co $TEAMREPOS/branched/Bobs-branch mydir and go to work (be sure trunk is committed first). 1/29/2009 Prof. Hilfinger CS164 Lecture 4

Prof. Hilfinger CS164 Lecture 4 Branches and Tags The use of the branches directory is convention; could put it anywhere. Again, this copy is cheap in the repository. Bob’s changes in branches/Bobs-branch are completely independent of the trunk. Rather elegant idea: no new mechanism! 1/29/2009 Prof. Hilfinger CS164 Lecture 4

Prof. Hilfinger CS164 Lecture 4 Tags A tag is the same as a branch, except that (by convention) we don’t usually modify it once it is created. Conventional to put it in the tags subdirectory, as in the instructions for turning in your project. Tags are usually intended as names of particular snapshots of the trunk or some branch (e.g., a release). 1/29/2009 Prof. Hilfinger CS164 Lecture 4

Typical examples of turning in work You’ve completed hw1 and want to hand it in. Currently, it’s in $REPOS/trunk/hw1 (and, of course, committed). Use % svn copy $REPOS/trunk/hw1 $REPOS/tags/hw1-N Or (using UNIX shorthand): % svn copy $REPOS/{trunk/hw1,tags/hw1-N} where N is unique number. Team submission: % svn copy $TEAMREPOS/{trunk/proj1,tags/proj1-N} 1/29/2009 Prof. Hilfinger CS164 Lecture 4

Prof. Hilfinger CS164 Lecture 4 Comparing Revisions One great feature: ability to compare versions, branches. Simple case: what local changes have I made to this working directory? svn diff How does this working directory compare to revision 9? svn diff -r 9 How do revisions 9 and 10 of directory differ? svn diff -r 9:10 1/29/2009 Prof. Hilfinger CS164 Lecture 4

Prof. Hilfinger CS164 Lecture 4 More Comparisons How does Bobs-branch compare to revision 100 of the trunk? svn diff $TEAMREPOS/branches/Bobs-branch \ $TEAMREPOS/trunk@100 1/29/2009 Prof. Hilfinger CS164 Lecture 4

Prof. Hilfinger CS164 Lecture 4 Merging To merge changes between two revisions, R1 and R2, of a file or directory into a working copy means to get the changes that occurred between R1 and R2 and make the same changes to the the working copy. To merge changes into current working copy: svn merge SOURCE1@REV1 SOURCE2@REV2 where SOURCE1 and SOURCE2 are URLs (svn+ssh:… ) or working directories and REV1, REV2 are revision numbers. 1/29/2009 Prof. Hilfinger CS164 Lecture 4

Prof. Hilfinger CS164 Lecture 4 More Merging For short, when sources the same: svn -r REV1:REV2 SOURCE To merge in changes that happened between two tagged revisions: svn $TEAMREPOS/tags/{v1,v2} \ branches/Bobs-branch 1/29/2009 Prof. Hilfinger CS164 Lecture 4

Prof. Hilfinger CS164 Lecture 4 After Merging After merging, as for update, must resolve any conflicts. Then we commit the merged version. 1/29/2009 Prof. Hilfinger CS164 Lecture 4

Prof. Hilfinger CS164 Lecture 4 Getting Information The command svn status is your friend. Identifies changes, additions, deletions that have not been committed; files, directories that have not been added things you’ve messed up. To list what’s in a repository directory: svn ls $TEAMREPOS/tags To list revisions of a file or directory: svn log FILEORDIR svn log -v FILEORDIR # For details 1/29/2009 Prof. Hilfinger CS164 Lecture 4

Prof. Hilfinger CS164 Lecture 4 Final thought If you commit early and often, system is quite forgiving. You can reconstruct previous states. You can freely clean things up by deleting and checking out again. BUT for this to work, you must commit regularly and must make sure that everything you want is under version control (svn status) 1/29/2009 Prof. Hilfinger CS164 Lecture 4