Mad Marmot A blog about programming, ruby, rails.

Subversion

Overview

Subversion is a lightweight version control system built on top of cvs with the intention of fixing all of CVS's well known problems.

Documentation

Use

SVN is very similar to CVS so those familiar with CVS should pick it up very quickly. In many cases you can substitute svn for cvs.

Dealing with conflicts

When doing an update and a conflict occurs, SVN inserts the conflict into the file in a similar manner to CVS. In addition SVN creates 3 temporary files to help you deal with the conflict, including a copy of your file before the update, a copy of the latest version from the repository, and a copy of the previous version from the repository. Before checking your file in you will have to clean up the conflict and run svn resolved on the file which will remove the temporary files.

Editing an SVN log message

The original log message will be lost, so proceed with caution.

  • svn propedit svn:log --revprop -r 13370

This will open an editor with the log message for revision 13370. Upon saving in the editor, the log message will be changed. No commit necessary.

Turning on execute permissions for a file

  • svn propedit svn:executable FILENAME

Ignoring a file

  • cd to the parent directory
  • svn propedit svn:ignore directory
  • then enter the name of each file to ignore in that directory, with each file on its own line
  • And then check it in (may have to do an update first too).
  • ex. Say you want to ignore the database.yml file in a rails project

Working With Branches

Here are a few useful tips:

A branch (or a tag) is treated no differently in svn than any other directory.

  1. Make a branch using svn mkdir and svn copy.
    1. svn mkdir file://$SVNROOT/branches/NAME_OF_BRANCH
    2. svn copy -m "making branch" file://$SVNROOT/trunk/Common file://$SVNROOT/branches/NAME_OF_BRANCH/Common
    3. svn copy -m "making branch" file://$SVNROOT/trunk/cannon file://$SVNROOT/branches/NAME_OF_BRANCH/cannon
  2. Working in a branch
    1. This is no different than working anywhere. Get a checkout, edit, commit, etc.
  3. Checkout
    1. svn checkout file://$SVNROOT/branches/NAME_OF_BRANCH
  4. Merging changes from branch into trunk
    1. Usually you want any changes in the branch to also be in the trunk. This can be done tediously in a manual manner, or automatically using svn merge (recommended!).
    2. svn merge will operate on your local checkout and changes to the repository will not take affect until you commit, so it is low risk.
    3. ex. Say you want to merge changes from the branch to trunk. Lets say the revision number representing the changes that already exist in the branch is revision 190. To get these merged into the trunk, cd into your trunk working copy and do:
      1. svn merge -c 190 file://$SVNROOT/branches/NAME_OF_BRANCH/cannon/
        1. This will modify your working area. You still have to check it in.
      2. TIP: Do a diff before every merge to see what it will change:
        1. svn diff -c 190 file://$SVNROOT/branches/NAME_OF_BRANCH/cannon/

Resurrecting deleted items

There is no attic in SVN. If you know the exact file and version you can do an svn copy to resurrect a file. To help remember or figure out the file you need to resurrect:

"Subversion has no Attic directory like CVS does, so you need to use svn log to discover the exact coordinate pair you wish to resurrect. A good strategy is to run svn log --verbose in a directory which used to contain your deleted item. The --verbose option shows a list of all changed items in each revision; all you need to do is find the revision in which you deleted the file or directory. You can do this visually, or by using another tool to examine the log output (via grep, or perhaps via an incremental search in an editor)."


Comments (0) Trackbacks (0)

No comments yet.


Leave a comment


No trackbacks yet.