1 / 16

Subversion

Subversion. What is Subversion?. A Version Control System A successor to CVS and SourceSafe Essentially gives you a tracked, shared file system. How does Subversion Work?. Create a repository Import files Checkout into Working Directory Make Changes Commit back to Repository Update.

shina
Download Presentation

Subversion

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Subversion

  2. What is Subversion? • A Version Control System • A successor to CVS and SourceSafe • Essentially gives you a tracked, shared file system

  3. How does Subversion Work? • Create a repository • Import files • Checkout into Working Directory • Make Changes • Commit back to Repository • Update MY REPOSITORY File 1 File 1 File 1 File 1 File 1 File 1 File 2 File 2 File 2 File 2 File 2 File 3 File 3 File 3 File 3 File 3 File 3 File 2 My Working Dir Your Working Dir File 2 File 1 File 3

  4. Importing Into A Repository $> ls branches tags trunk lstrunk login.js main.html map.js movement.js style.css svnimport svn://url/of/repo -m 'Initial commit' Adding trunk Adding trunk/login.js Adding trunk/movement.js Adding trunk/style.css Adding trunk/main.html Adding trunk/map.js Adding branches Adding tags Committed revision 1. • Add any directory to a repository • The source directory does not become a working directory or a repo • Directories typically structured with three subdirectories: trunk, branches, tags $> $>

  5. Checking Out a Repository $> cd development ls svncheckout svn://url/of/repo A demoapp/trunk A demoapp/trunk/login.js A demoapp/trunk/movement.js A demoapp/trunk/main.html A demoapp/trunk/style.css A demoapp/trunk/map.js A demoapp/branches A demoapp/tags Checked out revision 1. lsdemoapp/trunk/ login.js main.html map.js movement.js style.css • Never edit a repository directly • Check out a repository into a working directory • Make edits in working directory • Can use co instead of checkout $> $> $>

  6. Editing Your Working Directory $> cd demoapp nanotrunk/login.js svnstatus M trunk/login.js nanotrunk/gameplay.js svnstatus ? trunk/gameplay.js M trunk/login.js svnadd trunk/gameplay.js A trunk/gameplay.js svnstatus A trunk/gameplay.js M trunk/login.js svnrm trunk/movement.js D trunk/movement.js lstrunk gameplay.js login.js main.html map.js style.css • You can make changes to any file • Any changes to the file system must be made with svn commands: • svn add • svnrm • svnmkdir • svn mv • Etc… $> $> $> $> $> $> $> $>

  7. Updating Your Working Directory • Before committing changes to the repo, always update • Pulls in changes that anyone else might have made • Automatically merges changes, even to the same file (sort of). svnupdate U trunk/map.js Updated to revision 2. svnstatus M trunk/login.js D trunk/movement.js A trunk/gameplay.js $> $>

  8. Resolving Conflicts • Two people can make changes to the same part of the same file • Subversion cannot automatically merge these • Must be done by hand • Edit the conflicted file to manually merge the changes • Once complete, use svn resolved $> svnupdate C trunk/login.js Updated to revision 3. lstrunk gameplay.js login.js login.js.minelogin.js.r2 login.js.r3map.js main.html style.css $>

  9. Resolving Conflicts Continued cat trunk/login.js <<<<<<< .mine (function() { function login() { console.log('logging in'); } }()); ======= (function() { function login(){ window.alert('I AM NOW LOGGED IN!'); } }()); >>>>>>> .r3 nanotrunk/login.js svnresolved trunk/login.js Resolved conflicted state of 'trunk/login.js' $> • Two people can make changes to the same part of the same file • Subversion cannot automatically merge these • Must be done by hand • Edit the conflicted file to manually merge the changes • Once complete, use svn resolved $> $>

  10. Commiting Your Changes • Tell the repo about all the changes you’ve made to the working directory so far • Use svn commit • Always include a useful commit message • Use –m to include on the command line • Use –F to use the contents of a file svnstatus M trunk/login.js D trunk/movement.js A trunk/gameplay.js svncommit –m ‘Did awesome stuff’ Adding trunk/gameplay.js Sending trunk/login.js Deleting trunk/movement.js Transmitting file data .. Committed revision 4. svn status $> $> $> $>

  11. Looking at History svnlog ----------------------------------------r4 | yule | 2013-05-23 14:08:42 -0300 (Thu, 23 May 2013) | 1 line Did awesome stuff ----------------------------------------r3 | yule | 2013-05-23 13:51:00 -0300 (Thu, 23 May 2013) | 1 line made the login code 100% more awesome ----------------------------------------r2 | yule | 2013-05-23 13:40:19 -0300 (Thu, 23 May 2013) | 1 line Fixed a bug in the mapping code ... $> • svn log shows a history of all commits

  12. Looking at History svndiff -r 3 Index: trunk/gameplay.js ==========================================Index: trunk/login.js ==========================================--- trunk/login.js (revision 3) +++ trunk/login.js (working copy) @@ -1,5 +1,5 @@ -(function() { - function login(){ - window.alert('I AM NOW LOGGED IN!'); +function() { + function login() { + console.log('logging in'); } }()); $> • svn log shows a history of all commits • svn diff shows the difference between revisions

  13. Looking at History • svn log shows a history of all commits • svn diff shows the difference between revisions • svncat shows how a file looks at a certain revision svncat trunk/login.js -r 3 (function() { function login(){ window.alert('I AM NOW LOGGED IN!'); } }()); $>

  14. Looking at History • svn log shows a history of all commits • svn diff shows the difference between revisions • svncat shows how a file looks at a certain revision • svnlist gives the layout of the repo at a certain revision svnlist trunk -r 3 login.js main.html map.js movement.js style.css $> svn cat trunk/login.js -r 3 (function() { function login(){ window.alert('I AM NOW LOGGED IN!'); } }()); $>

  15. Important Points • Never touch the .svn directory • Always make sure to tell subversion about changes to the directory structure • You can revert any changes using svn revert • Many large projects use branches and tagging. You don’t need to.

  16. This is way too hard! • Use the svn help command • Eclipse has the Subclipse plugin • On Windows, you can use TortoiseSVN

More Related