1 / 52

Software Revision Control with Subversion

Software Revision Control with Subversion. Evan Dickinson & Andy Huang – 9 March 2011. About revision control. Revision control tracks the changes you make to your code Professional software developers can’t live without it.

ban
Télécharger la présentation

Software Revision Control with 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. Software Revision Control with Subversion Evan Dickinson & Andy Huang – 9 March 2011

  2. About revision control • Revision control tracks the changes you make to your code • Professional software developers can’t live without it. • Worth knowing if you write code at all, even if you’re not a “software person”

  3. What it’s good for • Offsite backup • Coordinate team work • See changes • Undo the change that broke everything • Freedom to experiment • You can always revert back to working code • Organization • Don’t have to e-mail files, or make lots of copies.

  4. Why you might not use it (for now) • Learning takes (a bit of) time • You’re using MAX/MSP • Photoshop, Illustrator, and other media files also have low payoff. • Several features work best with text files, not graphics. • But other features are still valuable, even with graphic files. • Plan B: Dropbox • At least have a backup & central location for all code

  5. About Subversion (svn) • There are several tools for revision control • subversion is one of them • svn is a command-line tool • several graphical front-ends available • Free GUI and free hosting: • SmartSVN (GUI – Mac, Windows, and Linux) • Demo. Free version has limited features, but they’re good enough. • Assembla.com (hosting)

  6. Installation • Will be covered later • It’s boring

  7. Subversion Concepts

  8. Repository • A server that stores your code • Repository records: • Every change that’s made • Who made it, when, and why • This is what assembla.com gives you • Except they call repositories “spaces.” It’s the same thing.

  9. Working copy A copy of the code on your laptop What you edit when you’re writing code You can have several working copies on your computer Your teammates have their own working copies

  10. 1 Repository & Many Working Copies Evan’s Computer Two working copies, each in different folders Andy’s Computer One working copy Repository (assembla.com server) Clip art: all-free-download.com

  11. Revisions • When you get your code to a good stopping point, snapshot the change in a revision. • Share the code with your team • Gives a known-good point to go back to • Assembla also calls these “change sets”

  12. Workflow Example

  13. Step 1: Write your code • Stop when the code does what you want it to, and you’re ready to share

  14. Step 2: Review your changes • Make sure you’re changing what you think you’re changing • Keep out temporary/testing changes • SmartSVN: “Changes” button. • Sometimes called “diff”

  15. Step 3: Update • Brings in newer changes (if any) • Keeps you from overwriting your team members’ changes. • SmartSVN: “Update” button

  16. Step 4: Commit the Change • SmartSVN: “Commit” button • Write a message that describes what you changed

  17. Done: Now your change is in the repository

  18. Demo

  19. Multiplayer Subversion Working with other people

  20. Workflow: Two people editing different files

  21. Two people editing one file • Best to do this rarely: • I’m not saying “don’t” – sometimes you need to • Use good communication: • Coordinate who’s doing what • Avoid incompatible changes • But when you do: • You can’t accidentally overwrite someone else’s changes • When you do an update (to get new changes): • Changes that don’t conflict are brought in automatically • Conflicting changes are highlighted for you to fix (see the section Conflict Resolution)

  22. Demo

  23. Links and Resources • SmartSVN: http://www.syntevo.com/smartsvn/ • http://www.syntevo.com/smartsvn/documentation.html • Subversion: http://subversion.apache.org/ • Assembla: http://www.assembla.com • Version Control with Subversion • Online book • http://svnbook.red-bean.com/

  24. Installation Three steps: Sign up for an assembla.com account Install SVN client Install SmartSVN

  25. Assembla.com • Register an account • Create a space • You want the free subversion repository • The free options are hidden – click to expand • http://www.assembla.com/catalog

  26. Install SVN Client – Mac • Install the MacOS X developer tools • SVN is included • These are on the MacOS X install DVD • Also downloadable from http://developer.apple.com/technologies/tools/ • Is svn already installed? • Open Terminal • Run: which svn

  27. Install SVN Client – Windows • Download it from: • http://sourceforge.net/projects/win32svn/

  28. Install & Configure SmartSVN • Download from: • http://www.syntevo.com/smartsvn • When you run it for the first time, it will ask for paths to svnadmin and svnserve • Mac: • /usr/bin/svnadmin • /usr/bin/svnserve • Windows: • c:\program files\subversion\bin\svnadmin • c:\program files\subversion\bin\svnserve

  29. Configure SmartSVN (part 2) • It starts by offering to set up a repository for you. • Say no. (That offer assumes your repository already has code in it.) • Instead, you want: Import Project Into Repository • This is on the welcome window, or File -> Import

  30. SmartSVN: Import Project Into Repository • While importing into the repository, you’ll get to a step where it asks you which repository to import to. • This is where you tell SmartSVN about your assembla repository. • Add a new repository and fill in the details Here’s where you find the URL to use

  31. SmartSVN Overview A reminder of what all the buttons do

  32. Check the selected file If you select one file, you only work with that one file. That can be bad if you wanted to commit all your files, but just commit one by mistake. If you select a directory, your action applies to all files in that directory. This is usually what you want.

  33. Refresh Load the latest data from the repository. Use this to see if there are newer revisions.

  34. Update Two uses: Grab the latest code from the repository. Change the working copy to an older revision. (This is useful for figuring out if a problem you just found exists in older revisions.)

  35. Commit Send the contents of your working copy to the repository. None of the changes you make to your working copy are applied to the repository until you do a commit.

  36. Add Tells subversion to track changes to the selected file (or directory). Subversion only tracks the files you tell it to track. Files you don’t add won’t be in your repository.

  37. Remove Tells subversion stop tracking changes to the selected file (or directory). Old versions of the file will remain available in the repository. But the file will no longer be in new versions of the repository.

  38. Move (and Rename) Move and/or rename a file. SmartSVN gets confused if you move/rename files from the Finder (or Windows Explorer) In this example, we’ve renamed Arm.pde to Leg.pde. Until you do a commit, Arm.pde will show up as “removed.”

  39. Revert Throws away the changes you’ve made in your working copy. Reverts a file (or directory) back to the way it was when you did an update.

  40. Delete Deletes a file. Only use this on files that are not tracked by subversion.

  41. Changes Shows the changes you’ve made in the file.

  42. Annotate Shows who wrote each line of the file, and when.

  43. Log Shows the list of revisions

  44. Fix and Graph These are advanced features. You don’t need them.

  45. Conflict Resolution

  46. Conflicts • Conflicts occur when two people make incompatible changes to one file at the same time. • Usually, it’s OK for two people to change the same file, as long as they change different parts of the file. But if the changes are too close together, they conflict. • Conflicts are rare. But if they happen to you, here’s what to do. • If you communicate with your team about who’s changing what, you can avoid conflicts in the first place.

  47. What conflicts look like • We did an update and – oh no! – there are conflicts. • The new files are: • .mine – the file you edited, as it was before the update • .r3 – the predecessor for your changes. (That is, the file as it was before you started editing.) The number will be different in your case. • .r6 – the newest version of the file.

  48. Fixing conflicts Bring up the conflict solver with Tools -> Conflict Solver We got a conflict because two people changed the same line, at the same time. The center pane is the file where you’ll resolve the conflicts. Right now, it has both changes in it, which is no good. The left pane shows your file, before the update. The right pane shows the newest version in the repository.

More Related