Totalsvn Usage And Administration By Gopi


Published on

Complete SVN Usage and Administration

1 Like
  • Be the first to comment

No Downloads
Total views
On SlideShare
From Embeds
Number of Embeds
Embeds 0
No embeds

No notes for slide

Totalsvn Usage And Administration By Gopi

  1. 1. Subversion (SVN) Tutorial Version control with Subversion & its Administration how to set it up, use it, and save your sanity how to set it up, use it, and save your sanity By Gopinath Karangula E-mail :
  2. 2. What is version control? <ul><li>Version management allows you to control and monitor changes to files </li></ul><ul><ul><li>What changes were made? </li></ul></ul><ul><ul><li>Revert to pervious versions </li></ul></ul><ul><ul><li>When were changes made </li></ul></ul><ul><ul><li>What code was present in release 2.7? </li></ul></ul><ul><li>Earliest tools were around 1972 (SCCS) </li></ul><ul><li>Older tools – RCS, CVS, Microsoft Source Safe, PVCS Version Manager, etc… </li></ul><ul><li>Current tools – Subversion, Mercurial, Git, Bazaar </li></ul>
  3. 3. We will use subversion (svn) <ul><li>Why? </li></ul><ul><li>Because it’s popular </li></ul><ul><li>It’s well supported </li></ul><ul><ul><li>IDEs - Netbeans, Eclipse </li></ul></ul><ul><ul><li>Numerous GUI tools </li></ul></ul><ul><ul><li>Command line </li></ul></ul>
  4. 4. subversion concepts <ul><li>checkout – get a local copy of the files </li></ul><ul><ul><li>I have no files yet, how do I get them? </li></ul></ul><ul><li>add – add a new file into the repository </li></ul><ul><ul><li>I created a new file and want to check it in </li></ul></ul><ul><li>commit – send locally modified files to the repository </li></ul><ul><ul><li>I’ve made changes, how do I send them to the group? </li></ul></ul><ul><li>update – update all files with latest changes </li></ul><ul><ul><li>Other people made changes, how do I get them? </li></ul></ul><ul><li>tag / branch – label a “release” </li></ul><ul><ul><li>I want to “turn in” a set of files </li></ul></ul>
  5. 5. Advantages of Version Control <ul><li>Source Code Management </li></ul><ul><li>Distributed Work Environment </li></ul><ul><li>Knowledge Sharing </li></ul><ul><li>Version control / Revision control </li></ul><ul><li>Easy to track the modification </li></ul>
  6. 6. Version Control Steps <ul><li>Create a repository of project files (code) </li></ul><ul><li>CHECKOUT a working copy of the code to working directory </li></ul><ul><li>Edit code </li></ul>
  7. 7. <ul><li>COMMIT your changes back into the repository </li></ul><ul><li>If someone else changed the same file as you, resolve differences to the changed files as needed (MERGE) </li></ul><ul><li>UPDATE your working copy before continuing work the next time </li></ul>
  8. 8. Version control models
  9. 9. File sharing: the problem to avoid
  10. 10. Lock-Modify-Unlock Lock-Modify-Unlock
  11. 11. Copy-Modify-Merge
  12. 12. Copy-Modify-Merge (cont’d)
  13. 13. Working with Tortoise SVN <ul><li>First you should download Tortoise SVN Client, avaiable in .msi format. </li></ul><ul><li>It should be installed, after successful installation, your system will be getting restarted. </li></ul><ul><li>In windows expolorer, just right clik on any folder and check wether the following additional menu items will be available.. </li></ul>
  14. 14. Tortoise SVN Client Daily Tasks <ul><li>checkout </li></ul><ul><li>Edit a file </li></ul><ul><li>commit </li></ul><ul><li>Add ( Files /Folder) </li></ul><ul><li>Update </li></ul><ul><li>Merge </li></ul><ul><li>Differentiate </li></ul><ul><li>Lock </li></ul><ul><li>Release Lock </li></ul>
  15. 15. Create a repository using Tortoise SVN <ul><li>After installing tortoise SVN you should add the the URL provided by your system admin: </li></ul><ul><li>Eg: </li></ul><ul><li>Goto Start -> Select Tortoise SVN -> Repository Browser -> </li></ul>
  16. 17. <ul><li>After adding the URL in the URL Repository, you should select the path for the check out directory. </li></ul><ul><li>The cehck out directory will be your local working copy. </li></ul><ul><li>So you will be doing modifications in local working copy using IDEs like ellipse. </li></ul><ul><li>After succesful check out, your local working copy folder will be indicated with green symbol. </li></ul>
  17. 18. Adding a new file to the Repository <ul><ul><li>Move, copy, or create a new file that will be added to the repository </li></ul></ul><ul><ul><ul><li>Give the file a descriptive name to distinguish it from other files </li></ul></ul></ul><ul><ul><ul><li>(Remember, we are adding a new file.) </li></ul></ul></ul>
  18. 19. TortoiseSVN: Add a new file to the repository (continued) <ul><ul><li>Use “Add” to add it to the local repository </li></ul></ul><ul><ul><ul><li>Right-click the new file </li></ul></ul></ul><ul><ul><ul><li>(Here, right-click on “Aesthetic”) </li></ul></ul></ul><ul><ul><ul><li>Click “TortoiseSVN->Add” </li></ul></ul></ul><ul><ul><ul><li>A window appears </li></ul></ul></ul><ul><ul><ul><li>Click “OK” </li></ul></ul></ul><ul><ul><ul><li>A blue “plus” symbol should appear on the file in Windows Explorer: </li></ul></ul></ul>
  19. 20. Tortoise SVN: Add a new file to the repository (continued) <ul><ul><li>Right-click on the file you just added </li></ul></ul><ul><ul><li>Choose “SVN Commit…” to commit it to the repository: </li></ul></ul>
  20. 21. <ul><ul><li>This window appears: </li></ul></ul><ul><ul><li>Once it says “Completed” </li></ul></ul><ul><ul><li>you have added a file to the repository! </li></ul></ul><ul><ul><li>Congratulations! </li></ul></ul>
  21. 22. TortoiseSVN: Modify an existing file in the repository <ul><li>Overview: </li></ul><ul><ul><li>“ Check out” the folder containing the file to be modified </li></ul></ul><ul><ul><li>Edit and save the file on your computer </li></ul></ul><ul><ul><li>“ Commit” the changes you have made </li></ul></ul>
  22. 23. TortoiseSVN: Modifying a file (continued) <ul><li>Checkout appropriate folder from the repository </li></ul><ul><ul><li>Start the “Repo-browser” </li></ul></ul><ul><ul><li>(Repository browser) </li></ul></ul>
  23. 24. TortoiseSVN: Modifying a file (continued) <ul><li>Choose the folder containing the file you want to edit </li></ul><ul><li>(Here, have chosen Aesthetic/) </li></ul><ul><li>Right-click on the folder and choose “Checkout…” </li></ul><ul><li>A “Checkout” window appears </li></ul>
  24. 25. TortoiseSVN: Modifying a file (continued) <ul><li>Click the “…” next to “Checkout Directory” </li></ul><ul><li>A “Browse for Folder” window appears </li></ul><ul><li>Browse to the folder on your computer where you want to create a local copy of the repository folder </li></ul><ul><li>Create a folder with the same name as the one in the repository </li></ul><ul><ul><ul><li>Click “Make New Folder” </li></ul></ul></ul><ul><ul><ul><li>Enter the new folder name </li></ul></ul></ul><ul><ul><ul><li>(Here “Aesthetic”) </li></ul></ul></ul><ul><li>Click “OK” </li></ul>
  25. 26. TortoiseSVN: Modifying a file (continued) <ul><ul><li>Double-click the file you want to open </li></ul></ul><ul><ul><li>Edit the file (In Simile, for example) </li></ul></ul><ul><ul><li>Save it </li></ul></ul><ul><ul><li>The file now appears like this: </li></ul></ul><ul><ul><li>(This means it has been modified but changes have not been “committed” to the repository.) </li></ul></ul>
  26. 27. <ul><ul><li>This window appears: </li></ul></ul><ul><ul><li>Once it says “Completed” </li></ul></ul><ul><ul><li>you have modified the repository! </li></ul></ul><ul><ul><li>Congratulations! </li></ul></ul>
  27. 28. SVN Update <ul><li>Update gets all new changes from the repository. </li></ul><ul><ul><li>svn update </li></ul></ul><ul><ul><li>GUI Users: you should get it by now </li></ul></ul><ul><li>What happens if there is a conflict? </li></ul><ul><ul><li>User A has version 3 of the file, modifies it, commits it creating version 4. </li></ul></ul><ul><ul><li>User B has version 3 of the file, modifies it, commits it </li></ul></ul><ul><ul><ul><li>CONFLICT – User B’s copy of the file was out of date. User B must merge their changes into Version 4 </li></ul></ul></ul><ul><ul><li>For text files (like source code) SVN can help do this in an automated way </li></ul></ul><ul><ul><li>For binary files SVN cannot help… must be done manually </li></ul></ul><ul><li>Lesson: Always ensure you have the latest version (update frequently). If multiple people are editing the same file you could have problems </li></ul>
  28. 29. Summary – Checking things in <ul><li>Create the repository by “svn checkout” </li></ul><ul><li>Copy your documents into “trunk” directory </li></ul><ul><li>Use “svn add” to mark files to include in the repository </li></ul><ul><ul><li>Use “svn commit” to send the files to the repository </li></ul></ul><ul><li>Modify files, “svn commit” as needed until your deliverable is complete </li></ul><ul><li>svn commit (don’t forget the final commit!) </li></ul>
  29. 30. SVN Administration : Trunk : Updated and major code of the project Tag : Showcase of Release versions and ready to pack Branches : Contain Total source code, which was divided and distributed to the workforce, where a source code commits happens on the branches for development and merged to test branch to bug fix, and add patches to stabilize the code ( Quality analysis), merged to release branch and deployed to production safely.
  30. 31. Project Repository Creation using Visual Svn server : Using Visual SVN Server : we can perform: 1. Fresh creation of Repository with default structure of the Project 2. Creation of the Project Folder with out default Project structure. 3.User management and manging the privileges on branches, trees and tags. 4. Hook scripts management – post-commit scripts for E-mail notification to the testing team Precommit hook – To block the developers with empty log message commits, using command line also we can manage the repository by installing the subversion package, but for easy administration we use this visual svn server.
  31. 32. SVN Repository Backup: Backs up are available of three types in svn : 1. svndump : Dumping ( taking backup of the entire repository). 2. Hotbackup : It is a kind of backup where the entire project repository can be imported in very less time compared to the restroing the repository from svn dump. 3. Incremental Backup : Taking a range of versions backup
  32. 33. Commands to take the Project Repository Backup: Commands : 1. Svn dump : Entire repository : 1. c:/ProgramFiles/Visualsvn/bin/svnadmin dump C:/Repository/Repo_name > [Target Folder].dump 2. Svn Hot-copy : c:/ProgramFiles/Visualsvn/bin/svnadmin hot copy C:/Repository/Repo_name [Target Folder].dump
  33. 34. SVN Repository Backup: 3. Incremental Backup : c:/ProgramFiles/Visualsvn/bin/svnadmin dump -r:15:30 C:/Repository/Repo_name > [Target Folder].dump Here 15 indicated the starting version and 30 indicates the end version.
  34. 35. SVN Repository Backup: Backs up are available of two types in svn : 1. svndump : Dumping ( taking backup of the entire repository). 2. Hot backup : It is a kind of backup where the entire project repository can be imported in very less time compared to the restoring the repository from svn dump.
  35. 36. SVN Repository Restore: Commands : 1. Svn load : Entire repository : 1. c:/ProgramFiles/Visualsvn/bin/svnadmin load C:/Repositories/repositoryname < repobackup.dump This command leads to restore of the entire repository. 2. The second way of restoring the hot copy backup dump file : Open the visual svn server and create a repository folder and select the import tab and browse to the location where the dump file located and press ok, the hot copy backup repository wil be restored.
  36. 37. Hook Scripts to manage the Project repositories : What is Hook: Hook is a group of policies for a effective management of the project repository. There are serveral Hooks scripts available in the subversion ( SVN) 1. Pre-Commit Hook ( Check the policy before the commit happen to the repository) Eg: Empty log messages can be blocked using this pre commit hook 2. Post Commit Hook ( Check the policy after the happen to the repository) Eg: Email notifications to each commit to testing team for quality analysis.
  37. 38. Hook Scripts : Pre Commit Hook to block the Empty Log Messages : &quot;C:Program FilesVisualSVN Serverbinsvnlook.exe&quot; log -t %2 %1 | FindStr [a-zA-Z0-9] IF %ERRORLEVEL% EQU 0 GOTO OK echo &quot;Commit Comments are Required, Dear developer please give the task details in detail for this commit&quot; >&2 exit 1 :OK exit 0
  38. 39. Post Commit Hook for Email Notifications to testing team : &quot;C:Program FilesVisualSVN ServerbinVisualSVNServerHooks.exe&quot; ^ commit-notification &quot;%1&quot; -r %2 ^ --from --to,, ^ --smtp-server ^ --smtp-user ^ --smtp-password XXXXXXXX