Published on

Subversion - an improved version of CVS, minimized network traffic.

Published in: Technology
  • Be the first to comment

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

No notes for slide


  1. 1. Subversion Tricode Professional Services 22-08-2008 Patrick van Dissel
  2. 2. Index <ul><li>What is Subversion (SVN)? </li></ul><ul><li>Subversion features </li></ul><ul><ul><li>Repository based versioning </li></ul></ul><ul><ul><li>Metadata Properties </li></ul></ul><ul><ul><li>Distinction Between Status and Update </li></ul></ul><ul><ul><li>Conflict Resolution </li></ul></ul><ul><ul><li>Updates and Commits are Separate </li></ul></ul><ul><li>Standard project structure </li></ul><ul><li>Development/Release workflow </li></ul><ul><li>Tips </li></ul>
  3. 3. <ul><li>An improved version of CVS </li></ul><ul><ul><li>Uses a filesystem tree; everything works the same way, everything is versioned (files, directories, renames, deletions, properties, …) </li></ul></ul><ul><ul><ul><li>Branches and Tags work exactly the same as the Trunk, everything has it’s place in the repository filesystem tree </li></ul></ul></ul><ul><ul><ul><li>Repositories/Modules can connect to each other, like a symbolic-link in a *nix filesystem </li></ul></ul></ul><ul><ul><ul><li>A revision contains a complete state of the repository filesystem tree </li></ul></ul></ul><ul><ul><li>Minimized network traffic </li></ul></ul><ul><ul><ul><li>only connects to the repository when really needed </li></ul></ul></ul><ul><ul><ul><li>tranfers are based on differences between versions instead of sending whole files </li></ul></ul></ul>What is Subversion (SVN)?
  4. 4. <ul><li>Terms of how they improve upon CVS's design </li></ul><ul><li>Directory versioning </li></ul><ul><ul><li>CVS only tracks the history of individual files, but Subversion implements a “virtual” versioned filesystem that tracks changes to whole directory trees over time. Files and directories are versioned </li></ul></ul><ul><li>True version history </li></ul><ul><ul><li>Since CVS is limited to file versioning, operations such as copies and renames—which might happen to files, but which are really changes to the contents of some containing directory—aren't supported in CVS. Additionally, in CVS you cannot replace a versioned file with some new thing of the same name without the new item inheriting the history of the old—perhaps completely unrelated—file. With Subversion, you can add, delete, copy, and rename both files and directories. And every newly added file begins with a fresh, clean history all its own </li></ul></ul><ul><li>Versioned metadata </li></ul><ul><ul><li>Each file and directory has a set of properties—keys and their values—associated with it. You can create and store any arbitrary key/value pairs you wish. Properties are versioned over time, just like file contents </li></ul></ul>Subversion features (1)
  5. 5. <ul><li>Terms of how they improve upon CVS's design </li></ul><ul><li>Atomic commits </li></ul><ul><ul><li>A collection of modifications either goes into the repository completely, or not at all. This allows developers to construct and commit changes as logical chunks, and prevents problems that can occur when only a portion of a set of changes is successfully sent to the repository </li></ul></ul><ul><li>Consistent data handling </li></ul><ul><ul><li>Subversion expresses file differences using a binary differencing algorithm, which works identically on both text (human-readable) and binary (human-unreadable) files. Both types of files are stored equally compressed in the repository, and differences are transmitted in both directions across the network </li></ul></ul><ul><li>Efficient branching and tagging </li></ul><ul><ul><li>The cost of branching and tagging need not be proportional to the project size. Subversion creates branches and tags by simply copying the project, using a mechanism similar to a hard-link. Thus these operations take only a very small, constant amount of time </li></ul></ul>Subversion features (2)
  6. 6. Repository based versioning <ul><li>A revision contains a complete state of the repository filesystem tree </li></ul>Revision numbering => CVS uses file based versioning, SVN uses repository based versioning. Metadata properties svn:ignore *.tmp svn:ignore ~* svn:keywords Id rev.2 svn:ignore *.tmp svn:keywords Id rev.1
  7. 7. Metadata Properties CVS uses .cvsignore files containing patterns of files/directories to exclude from CVS. In SVN, every file and directory can have metadata properties. SVN recognizes the following special properties but will store any arbitrary properties set: <ul><li>svn:ignore </li></ul><ul><li>svn:keywords </li></ul><ul><ul><li>URL, HeadURL </li></ul></ul><ul><ul><li>Author, LastChangedBy </li></ul></ul><ul><ul><li>Date, LastChangedDate </li></ul></ul><ul><ul><li>Rev, Revision, LastChangedRevision </li></ul></ul><ul><ul><li>Id </li></ul></ul><ul><li>svn:executable </li></ul><ul><li>svn:eol-style One of 'native', 'LF', 'CR', 'CRLF‘ </li></ul><ul><li>svn:mime-type </li></ul><ul><li>svn:externals </li></ul><ul><li>svn:needs-lock If present, indicates that the file should be locked before it is modified </li></ul>Note: The svn:keywords, svn:executable, svn:eol-style, svn:mime-type and svn:needs-lock properties cannot be set on a directory. A non-recursive attempt will fail.
  8. 8. Metadata Properties – Usage (1) <ul><li>svn:ignore A newline separated list of file patterns to ignore For example: svn ps svn:ignore * cache This excludes all files within the cache directory from adding to SVN. Files still can be added by specifically adding them </li></ul><ul><li>svn:keywords Keywords to be expanded (case-sensitive!) For example: svn ps -R svn:keywords Id . This sets the ‘Id’ keyword on all files recursively from current directory. After this, ‘$Id$’ will be replaced at commit with information of the last modification and looks something like: $Id: calc.c 148 2006-07-28 21:30:43Z sally $ </li></ul>
  9. 9. Metadata Properties – Usage (2) <ul><li>svn:externals A newline separated list of module specifiers For example: Zend Tricode http://svn.tri.../tricode/branches/1.1/library/Tricode/ This connects the Zend directory to the specified 1.5.2-tricode repository and the Tricode directory to specified 1.1 branch. When you update your whole project, the externals will also be updated . When you commit your while project, the externals will NOT be committed . Commits to externals must be done explicitly. </li></ul>
  10. 10. <ul><li>One of the fundamental rules of Subversion is that a “push” action does not cause a “pull”, nor the other way around. </li></ul><ul><ul><li>Just because you're ready to commit new changes to the repository doesn't mean you're ready to receive changes from other people </li></ul></ul><ul><ul><li>And if you have new changes still in progress, then svn update should gracefully merge repository changes into your own, rather than forcing you to publish them </li></ul></ul>Updates and Commits are Separate
  11. 11. <ul><li>svn status </li></ul><ul><ul><li>Shows only information about current working-copy without needing to connect to the repository. Unless you specify the -u option, then the reposity is contacted to recieve update information (files are not updated!) </li></ul></ul><ul><li>svn update </li></ul><ul><ul><li>Updates current working-copy to the latest/given revision and shows information about the files that are updated </li></ul></ul>Distinction Between Status and Update
  12. 12. <ul><li>Steps for merging: </li></ul><ul><li>Open the project/working-copy you want to merge changes to For merging the ‘trunk’ to ‘cycle18’ branche, you open the ‘cycle18’ branche and then execute the ` svn merge ` on the { trunk url } </li></ul><ul><li>Make shure you have NO local modifications (`svn status`) </li></ul><ul><li>Execute merge </li></ul><ul><li>Solve conflicts & mark resolved </li></ul><ul><li>Commit changes to complete merge </li></ul>Merging
  13. 13. <ul><li>{projectname} </li></ul><ul><ul><li>branches => specific development versions </li></ul></ul><ul><ul><li>tags => released versions </li></ul></ul><ul><ul><li>trunk => latest development version </li></ul></ul><ul><li>Naming convention </li></ul><ul><li>For branches: </li></ul><ul><li>YYYY-MM-DD_ I ##### </li></ul><ul><li>YYYY-MM-DD_ RFS ### </li></ul><ul><li>YYYY-MM-DD_ RFC ### </li></ul><ul><li>YYYY-MM-DD_ cycle ## </li></ul><ul><li>For tags: </li></ul><ul><li>YYYY-MM-DD_ cycle ## </li></ul>Standard project structure
  14. 14. <ul><li>{projectname} </li></ul><ul><ul><li>branches </li></ul></ul><ul><ul><ul><li>2008-08-18_ cycle 18 </li></ul></ul></ul><ul><ul><ul><li>2008-08-19_ I 7654321 </li></ul></ul></ul><ul><ul><ul><li>2008-08-19_ RFC 0012345 </li></ul></ul></ul><ul><ul><ul><li>2008-08-19_RFC0022386 </li></ul></ul></ul><ul><ul><ul><li>2008-08-19_ RFS 0012345 </li></ul></ul></ul><ul><ul><li>tags </li></ul></ul><ul><ul><ul><li>2008-08-18_ cycle 17 </li></ul></ul></ul><ul><ul><li>trunk </li></ul></ul>Standard project structure
  15. 15. Development/Release workflow FA TA Build UAT 1 week 1 week 1 week 1 week trunk (prod + incidents/rfs) GoLive After GoLive previous cycle Create cycle branch Merge to cycle Merge to cycle NOK Fix NOK RFC Branch Create branch per Change Build Changes Decide which Changes will go in the release Tag Clean branches
  16. 16. Development/Release workflow symbolic-link switcher cron Auto remove branches which are not in HEAD SVN revision symbolic-link trunk ../trunk ../b1 ../trunk ../b1 ../ixxx /virtual/{project} /virtual/{project} /virtual/{project} LIVE TEST DEV
  17. 17. <ul><li>Use JIRA issue keys in commit messages </li></ul><ul><ul><li>If a commit is resolving an issue from the issue tracker, the issue KEY should be indicated in the commit comment (i.e. &quot;This resolves ZF-2 &quot;) </li></ul></ul><ul><li>Enable SVN Auto-props in SVN client config </li></ul><ul><ul><li>Config can be found at: %UserProfile%Application DataSubversionconfig </li></ul></ul><ul><ul><li>Set the following in the config: enable-auto-props = yes [auto-props] *.php = svn:keywords=Id  </li></ul></ul>Tips