Home

Everything* you wanted to know about revision control but never

image

Contents

1. UNIVERSITY OF http www cl cam ac uk research dtg P CAMBRIDGE j Computer Laboratory SVN Branching Commands Create a branch just copy to elsewhere in the repo SVN COPY CrunkURL DrancnURL Download another branch into your working copy svn switch r revisionNo branchURL Merge changes from trunk into branch as many times as you like optionally specify trunk revision number svn merge c revisionNo trunkURL Track what changes from trunk have been merged into your current branch using properties only in 1 5 svn mergeinfo Merge branch into a working copy of trunk svn merge reintegrate branchURL mm UNIVERSITY OF htto www cl cam ac uk research dtg CAMBRIDGE Computer Laboratory Making Life Easier Utilities Integrate SVN into Eclipse for DTG use http www cl cam ac uk research dtg research wiki local oharingCodelnDTG Tortoise Graphical front end http tortoisesvn tigris org Kidff3 is brilliant for comparing and working out what change to keep http kditf3 sourceforge net http www cl cam ac uk research dtg fi UNIVERSITY OF P CAMBRIDGE Computer Laboratory Distributed Version Control RCS CVS and SVN are all centralised i e there is one most up to date repository that everyone commits to Mercurial and Git have the idea that all repositories are equal and contain the entire change history Note that you ll stil
2. while Scolours if Scolours s s d 1 3 s d 1 3 s d 1 3 s n x T Print TS An UNIVERSITY OF http Awww cl cam ac uk research dtg CR CAMBRIDGE Computer Laboratory diff in Action Explained foss trunk S svn diff r PREV tndex colour pl colour pl revision 1 Original lines 1 4 colour pl WOTKING copy ae 1 TI 8 ee Showing new 1 bin perl print The following coteuTrs are my SColesrs showrghb print Scolours twhile Scolours if Scolours sys di 1 eo rveevdi Ek Ce TAAI a print sl n Removed line Inserted 5 lines amm UNIVERSITY OF http www cl cam ac uk research dtg lt 7 CAMBRIDGE Computer Laboratory Collaboration amp Conflict David lt b fie a UNIVERSITY OF htto Awww cl cam ac uk research dtg lt 9 CAMBRIDGE i S Computer Laboratory What a Conflict Looks Like foss trunks vi readme txt foss trunk svn commit Sending readme txt Svn svn Commit failed details follow svn Out of date trunk readme txt in transaction 12 4 Svn Your commit message was left in a temporary file svn filer dnc25 unix_home workingCopy trunk svn commit tmp foss trunk svn update C readme txt Updated to revision 3 a UNIVERSITY OF http www cl cam ac uk research dtg lt 7 CAMBRIDGE Computer Laboratory Update What Changed The update command will compare your working copy to th
3. Everything you wanted to know about revision control but never dared to ask OK most things think are useful and that can try to fit into a 20 minute talk David Cottingham david cottingham cl cam ac uk mA UNIVERSITY OF http www cl cam ac uk research dtg P CAMBRIDGE S Computer Laboratory What is Revision Control Poor man s version Keep multiple copies of the same file one for each change ever made and some notes Keep track of changes to a file Roll back undo changes if needed Merge multiple changes together to create the next revision mA UNIVERSITY OF htto www cl cam ac uk research dtg 9 CAMBRIDGE e S Computer Laboratory Where to Use Revision Control Your own software projects return to a stable version when necessary Documents particularly papers where you are likely to re write sections Working collaboratively on either of these can merge in changes from multiple reviewers keep track of original version mH UNI F htto www cl cam ac uk research dtg i omputer Laboratory Concurrent vs Strict Locking Version control exists in many applications Simplest form is an undo log e MS Word has Track Changes feature These are great for keeping track of changes to a document that is passed around between users i e only one person edits at once Revision Control Systems a k a Software Configuration Management SCM systems al
4. OF http www cl cam ac uk research dtg ER CAMBRIDGE Computer Laboratory Resolving the Conflict foss irunk vi readme txt foss trunk cat readme txt This is a useless readme file for colour plL Don t ever modify this code foss trunk svn resolved readme txt Resolved conflicted state of readme txt foss trunk S svn commit m Merged xyz12 s change of first sentence with mine Sending readme txt Transmitting file data Committed revision 4 foss trunk S svn commit m Merged xyz12 s change of first sentence with mine TE UNIVERSITY OF http www cl cam ac uk research dtg lt 7 CAMBRIDGE Computer Laboratory Revision Version Numbers amp Change Log SVN has a single revision number for the entire repository CVS keeps version numbers on a per file basis Each commit increments the revision version number Every commit should have a comment from the committer explaining what the change is the change log contains all of these ma UNIVERS http www cl cam ac uk research dtg i 0 uter Laborato Revision Version Numbers amp Change Log I foss trunkS svn log readme txt dnc25 2008 02 01 14 23 45 0000 Fri 01 Feb 2008 line Merged xyz12 s change of first sentence with mine xyz12 2006 02 01 13 59 58 0000 Fri 0L Feb 2008 lines Told everyone that the readme file was useless dne25 2008 02 01 13 24 52 0000 Fri 01 Feb 2008 line Project import UNI
5. further work on the branch i e create a new tip then re merge this generates a conflict This is because the diff that is attempted to be applied to the trunk is of the branch root and its tip i e including the contents of your first merge Fix tag the branch before every merge Then on merging elect to merge in the changes that were committed to the branch after the last tag Or use svn merge which is clever If you don t tag you can use dates instead Caution if you merge in someone else s branch make Sure the tip of that branch is then tagged mm UNIVERSITY OF htto www cl cam ac uk research dtg 0 Branching amp Merging Example SVN Do some work on an existing trunk Commit your changes becomes revision 13 Do some more commit revision 14 Oh Actually e Revision 14 was bug fixes to trunk Revision 13 should have been a branch Problems How to make a branch containing changes from 13 and the bug fixes How to get trunk back to revision 12 the bug fixes from 14 UNIVERSITY http www cl cam ac uk research dtg J CAMBRIDGE Computer Laboratory Branching amp Merging Example SVN II How to make a branch containing changes from 13 and the bug fixes Create a branch at revision 12 i e the point before you committed the changes that should be on the branch Switch your working copy to point to the branch e Merge changes from revisions 13 to 14 of the
6. VERSITY OF http www cl cam ac uk research dtg ZP CAMBRIDGE Computer Laboratory Rolling Back Reverting l You broke al l revision 2 l l Roll back m oo working copy to revision 1 Commit Rev 3 now same as 1 Get earlier revision then commit it as a change Roll back as far as you wish CVS Works on individual files entire repository more complex mA UNIVERSITY OF http www cl cam ac uk research dtg S CAMBRIDGE e 9 Computer Laboratory Reverting to a Previous Revision foss trunkS foss trunkS svn diff r 2 Index readme txt readme txt revision 2 readme txt working copy 1 2 1 2 This is a readme file for colour pl This is a useless readme file for colour pl Don t ever modify this code foss trunkS svn cat r 2 file svn testRepo trunk readme txt gt readme txt foss trunk svn commit m Reverted readme text to before useless was added Sending readme txt Transmitting file data Committed revision 5 UNIVERSITY OF http www cl cam ac uk research dtg ZP CAMBRIDGE Computer Laboratory Reverting an Entire Repository For SVN this is the same as for a single file as a revision number is for the entire repository Remember in CVS every file has its own revision number Hence when you release version 1 0 of your programme you may well have some files that are at revision 2 5 1 4 0 9 To revert a reposi
7. Y OF http www cl cam ac uk research dtg Bad BS CAMBRIDGE Computer Laboratory Trunk Branches Tips Il Generally your repository will be tree like in structure Your trunk will be the new release of the software you re working on Older releases will each have branches rooted at particular points on the trunk Each branch will have a tip the latest commit made to that branch confusingly git calls these heads Example bug fix needed for release 1 0 of the software whilst you re working on release 3 0 The trunk has a tip called the HEAD in CVS and SVN the most recent commit to release 3 0 In SVN the trunk is no different from any other branch In CVS the trunk is special mm UNIVERSITY OF htto www cl cam ac uk research dtg 0 Merging From a Branch Into the Trunk lt may be that you need to apply all the bug fixes that you made to the 1 0 branch to release 3 0 the trunk as well When merging a branch into the trunk the system calculates the diff between the root of that branch and its tip That diff is then applied to the trunk s tip Note this is not the same as reverting the entire trunk to the previous release You can also merge from the trunk into a branch e g cvs update j HEAD UNIVERSITY OF http www cl cam ac uk research dtg 9 CAMBRIDGE S mputer L t Caution Multiple Merges gt Conflict lf you merge a branch into the trunk then later do
8. e repository Reports which files have changed and merges them if possible but does nothing further i e conflicts are your problem Note commit only pushes your changes to repository you probably then want to update ERUN F htto www cl cam ac uk research dtg i omputer Laboratory Merging Conflicts he revision control system can work out simple conflicts itself e g two separate portions of a file A conflict occurs if there have been concurrent edits to the same line of a file If this happens your commit will fail and you will need to update rack your brains write upset e mail to co worker sort it out manually Then tell SVN that the conflict is resolved and commit the fix back to the repository mA UNI F http www cl cam ac uk research dtg i omputer Laboratory Merging Conflicts Il foss trunkS cat readme txt lt lt lt lt lt lt lt mine a readme file for colour pl a useless readme file for colour pl KN E Don t ever modify this code NIVERSITY OF http www cl cam ac uk research dtg CAMBRIDGE Computer Laboratory Merging Conflicts Il Explained foss trunk S cat readme txt lt lt lt lt lt lt lt mine Working copy This is a readme file for colour plL change a useless readme file for colour pl gt gt gt gt gt gt gt 4r3 Repo change Don t ever modify this cede Repo Revision Contextual line fi UNIVERSITY
9. g Very Basic Terminology Revision a set of changes to a project A z revision is a snapshot of a project oe Repository master copy of a project s revision history on a eener g Working Copy your own workstation copy of the project you can mess this up as much as you like mE UNIVERSITY OF htto www cl cam ac uk research dtg 9 CAMBRIDGE e 3 omput er Laboratory Importing a k a Starting a New Repository Create a repository for this project C O Import g existing files Delete backup existing files mm UNIVERSITY OF htto www cl cam ac uk research dtg P CAMBRIDGE Computer Laboratory Creating a Repository amp Importing in SVN foss foss foss CONE foss S mkdir p svn testRepo svnadmin create fs type fsfs svn testRepo S ls svn testRepo dav db format hooks Locks README txt S svn import scripts file filer dnc25 unix_home svn testRepo trunk m Project import Adding scripts colour pl Adding scripts readme txt Committed revision 1 foss foss mv scripts scripts old S svn list file svn testRepo trunk exon elbharaent readme txt a UNIVERSITY OF http www cl cam ac uk research dtg lt 7 CAMBRIDGE Computer Laboratory Checking Out amp Committing l eg Check out q l 1 l working copy lt i hn at revision 1 C gt Do work on g file A Commit changes to repositor
10. ing Commands Create a tagged branch drop b to tag without branching cvs tag D branchName Checkout the tip of a branch cvs checkout r branchName Update working copy to trunk remove stickiness Cvs update A Update working copy with diffs from a specified tagged branch cvs update J tagName Merge a branch s changes after a specified tagged commit to that branch cvs update J tagName J branchName http www cl cam ac uk research dtg SVN Properties Every object in the repository can have metadata associated with it This can be textual e g copyright notice bug ID or binary e g a thumbnail image Use svn propset to set then svn proplist to get the property names svn propget to obtain the actual property value Properties can be versioned or unversioned SVN provides language bindings to easily access properties fi UNIVERSITY OF htto www cl cam ac uk research dtg Y CAMBRIDGE e S Computer Laborator SVN Unique Commands View log of changes to a file or directory svn log fileName r revisionNumber Revert to the last repository copy of a file svn revert fileName See a particular revision of a given file svn cat r revisionNumber fileName See files in a given directory without downloading svn list feel URL Use journal to restore working copy to consistent state svn cleanup To copy rename or move files use SV COPY SVN rename svn Move
11. l probably want one central backup and up to date repository anyway but you dont have to ERUN F htto www cl cam ac uk research dtg i omputer Laboratory Mercurial hg To checkout a project you hg clone the entire repository You then have your own local repository not just a working copy Can hg commit to your repository Get changes from other repos using hg pull Merge your repo with the result of the pull using hg update plus hg merge Push the result to other repos using hg push mm UNI F http www cl cam ac uk research dtg i omputer Laboratory Why Bother With Mercurial Having your own repository allows you to commit intermediate code states regularly but not publish them to anyone else Bisect extension allows you to mark earliest changeset you know of where a bug is present and the latest where it is not Then bisect iterates through changesets updating your working copy For each you inform it whether your binary bug test fails This then enables you to find the exact changeset that introduced the bug Lots of hooks even more than SVN that allow actions to be run in response to repository events Patch queues mm UNIVERSITY OF htto www cl cam ac uk research dtg 0 Links for Reference CVS Book hitp cvsbook red bean com OSDevWithCVS 3E pdf SVN Book http svnbook red bean com nightly en svn book pdf Mercurial Book http hgbook red bean co
12. low concurrent editing of files by multiple users mm UNIVERSITY OF htto www cl cam ac uk research dtg CAMBRIDGE Computer Laboratory Contents amp Non Contents We will cover Basic revision control import check out commit update diff merge revert rollback e Advanced revision control branching e Different revision control paradigms centralised vs distributed We will not cover In depth command line options of any one system though there are some reference slides mm UNIVERSITY OF htto www cl cam ac uk research dtg P CAMBRIDGE Computer Laboratory Quick Comparison RCS not network aware only files not projects strict locking rather than optimistic concurrency useful for single config files CVS built on RCS but fixes above widely used non atomic commits no directory versioning no binary files SVN fixes above but uses Berkeley DB so you can t view metadata with a text editor Allows property sets text binary files for all objects in repository ERUN F htto www cl cam ac uk research dtg i omputer Laboratory Quick Comparison I Mercurial great for giving each developer their own repository slightly confusing first time round lots of hooks bisect to find bugs patch queues various extensions Git not mentioned here also distributed used for Linux kernel source management Many others http www cl cam ac uk research dt
13. m hgbook pdf Git User Manual htto www kernel org oub software scm git docs user manual html mm UNI http www cl cam ac uk research dtg i CAMBRIDGE Computer L There are a huge number of revision control systems out there We have examined CVS and SVN in detail centralised approach Briefly looked at Mercurial distributed Personally CVS is OK SVN far better but database locks up use fsfs instead Mercurial thus far has been great a UNI F htto www cl cam ac uk research dtg i omputer Laboratory Everything you wanted to know about revision control but never dared to ask Thanks for listening David Cottingham david cottingham cl cam ac uk mE UNIVERSITY OF htto www cl cam ac uk research dtg 9 CAMBRIDGE e 3 omput er Laboratory
14. tory can do so by date latest revision of all files up to that date Or tag give a useful name to a set containing one revision of each file Revert to a tagged set SVN also supports tag and date reversion mm UNIVERSITY OF http www cl cam ac uk research dtg i CAMBRIDGE Computer Laborator Branching Iimelines Consider a time machine Think of Doc Brown from Back to the Future here A timeline can split into two or more versions at a particular event the root For example you could choose to listen or not listen to this talk In one timeline would get upset and walk out in the other will be generally happy mm UNIVERSITY OF htto www cl cam ac uk research dtg R CAMBRIDGE Computer L t Branching Repositories Comp u When you release a version of your software project you may still have to supply updates for it whilst developing a completely new currently unstable version So when beginning on the new version make a copy of the repository s contents a branch Leave this branch intact so you can work on it separately if needed whilst you continue to work on the main repository The root of the branch is the release event which is contained within the main development tree the trunk ma UNIVERSITY OF http www cl cam ac uk research dtg BRIDGE S ter Laboratory Trunk Branches Tips Start of HEAD project CD Release Ti Time P UNIVERSIT
15. trunk into your working copy Commit your working copy to the branch Notes e If you have no working copy just check out the branch e Switching is preferable because it doesn t download the entire repository just the differences UNIVERSITY http www cl cam ac uk research dtg J CAMBRIDGE Computer Laboratory Branching amp Merging Example SVN III How to get trunk back to revision 12 the bug fixes from 14 e EITHER Check out revision 12 of the trunk to a scratch space working copy e Merge in only changeset 14 the bug fixes to your working copy e OR use merge to reverse changeset 13 only rather than revert Commit your working copy to the trunk revision 15 Notes You never actually delete anything from the history revision 14 stays as 13 the bug fixes e You can specify a range of changesets rather than just a single one that you want to apply to your working copy UNIVERSITY http www cl cam ac uk research dtg J CAMBRIDGE Computer Laboratory CVS Watchers amp Notifications Useful if you want to know by e mail SMS when someone begins to edit or commits on a file you re interested in For edit notification requires you to tell the system that you are about to edit e g cvs edit fileName Very cumbersome SVN and Mercurial provide hooks which require much less effort to use ERUN F htto www cl cam ac uk research dtg i omputer Laboratory CVS Branch
16. y Resolve conflicts store new revision mA UNIVERSITY OF htto www cl cam ac uk research dtg 9 CAMBRIDGE e S Computer Laboratory Checking Out in SVN foss S mkdir workingCopy cd workingCopy foss workingCopys svn co file svn testRepo trunk A trunk colour pl A trunk readme txt Checked out revision 1 foss workingCopys cd trunk cat colour pl bin perl print The following colours are available n my Scolours showrgb print Scolours foss trunk S perl colour pl The following colours are available 255 250 250 snow 248 248 255 ghost white mm UNIVERSITY OF http www cl cam ac uk research dtg GR CAMBRIDGE Computer Laboratory Committing in SVN foss trunk S perl colour pl The following colours are available 299 200 250 snow 248 248 255 ghost white Loss trunko vi colour pl foss trunk S perl colour pl The following colours are available snow ghost white foss trunk svn commit m Made colour listing only names Sending oro molbnaraone Transmitting file data Committed revision 2 TE UNIVERSITY OF http www cl cam ac uk research dtg lt 7 CAMBRIDGE Computer Laboratory What Changed aiff In Action foss trunk svn diff r PREV Index colour pl CO lour pl revision 1 colour pl working copy GQ 1 4 1 8 bin perl print The following colours are available n my Scolours showrgb print Scolours

Download Pdf Manuals

image

Related Search

Related Contents

Catalogue Commercial Delta    control12 user manual    Instructions de service chariot tracteur electrique SAKB  AmpliVox SW223 User's Manual  医療の質管理を目的とした文書体系構築に関する研究  ISN-SM-80 - Bosch Security Systems    Manual do Utilizador do Nokia 2610  

Copyright © All rights reserved.
Failed to retrieve file