Subversion. What is Subversion? A Version Control System A successor to CVS and SourceSafe...
-
Upload
candace-thompson -
Category
Documents
-
view
213 -
download
1
Transcript of Subversion. What is Subversion? A Version Control System A successor to CVS and SourceSafe...
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?1. Create a repository
2. Import files
3. Checkout into Working Directory
4. Make Changes
5. Commit back to Repository
6. Update
MY REPOSITORYFile 1 File 2 File 3
My Working Dir
File 1 File 2 File 3
Your Working Dir
File 1 File 2 File 3
File 1 File 2 File 3File 1 File 1 File 2 File 3File 3 File 2
File 2File 1 File 3
Importing Into A Repository• 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
lsbranches tags trunkls trunklogin.js main.html map.js movement.js style.csssvn import svn://url/of/repo -m 'Initial commit'Adding trunkAdding trunk/login.jsAdding trunk/movement.jsAdding trunk/style.cssAdding trunk/main.htmlAdding trunk/map.jsAdding branchesAdding tags
Committed revision 1.
$>$>
$>
Checking Out a Repository• Never edit a repository directly
• Check out a repository into a working directory
• Make edits in working directory
• Can use co instead of checkout
cd developmentls svn checkout svn://url/of/repoA demoapp/trunkA demoapp/trunk/login.jsA demoapp/trunk/movement.jsA demoapp/trunk/main.htmlA demoapp/trunk/style.cssA demoapp/trunk/map.jsA demoapp/branchesA demoapp/tagsChecked out revision 1.ls demoapp/trunk/login.js main.html map.js movement.js style.css
$>$>$>
$>
Editing Your Working Directory• You can make changes to any file
• Any changes to the file system must be made with svn commands:
svn add
svn rm
svn mkdir
svn mv
Etc…
cd demoappnano trunk/login.jssvn statusM trunk/login.jsnano trunk/gameplay.jssvn status? trunk/gameplay.jsM trunk/login.jssvn add trunk/gameplay.jsA trunk/gameplay.jssvn statusA trunk/gameplay.jsM trunk/login.jssvn rm trunk/movement.jsD trunk/movement.jsls trunkgameplay.js login.js main.html map.js style.css
$>$>$>$>$>
$>$>
$>$>
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).
svn updateU trunk/map.jsUpdated to revision 2.svn statusM trunk/login.jsD trunk/movement.jsA trunk/gameplay.js
$>
$>
svn updateC trunk/login.jsUpdated to revision 3.ls trunkgameplay.js login.js login.js.mine login.js.r2 login.js.r3 map.js main.html style.css
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
$>
$>
cat trunk/login.js<<<<<<< .mine(function() { function login() { console.log('logging in'); }}());
=======(function() { function login(){ window.alert('I AM NOW LOGGED IN!'); }}());>>>>>>> .r3nano trunk/login.jssvn resolved trunk/login.jsResolved conflicted state of 'trunk/login.js'
Resolving Conflicts Continued• 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
$>
$>$>
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
svn statusM trunk/login.jsD trunk/movement.jsA trunk/gameplay.jssvn commit –m ‘Did awesome stuff’Adding trunk/gameplay.jsSending trunk/login.jsDeleting trunk/movement.jsTransmitting file data ..Committed revision 4.svn status
$>
$>
$>$>
Looking at History• svn log shows a history of all commits
svn log----------------------------------------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...
$>
Looking at History• svn log shows a history of all commits
• svn diff shows the difference between revisions
svn diff -r 3Index: 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'); } }());
$>
Looking at History• svn log shows a history of all commits
• svn diff shows the difference between revisions
• svn cat shows how a file looks at a certain revision
svn cat trunk/login.js -r 3(function() { function login(){ window.alert('I AM NOW LOGGED IN!'); }}());
$>
Looking at History• svn log shows a history of all commits
• svn diff shows the difference between revisions
• svn cat shows how a file looks at a certain revision
• svn list gives the layout of the repo at a certain revision
$> svn cat trunk/login.js -r 3(function() { function login(){ window.alert('I AM NOW LOGGED IN!'); }}());
svn list trunk -r 3login.jsmain.htmlmap.jsmovement.jsstyle.css
$>
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.
This is way too hard!• Use the svn help command
• Eclipse has the Subclipse plugin
• On Windows, you can use TortoiseSVN