The Decider said over 3 years ago permalink Comment? (0)
Tagged: svn cheat sheet

Making svn easier to use

As one of my UF professors use to say:

It’s known to those who know it

If you don’t use svnmerge.py you are really hurting yourself when doing branches with svn. Here’s my complete svn cheat sheet. The branching and merging stuff is at the bottom. Of course, substitute your URL for the svn+ssh://example.com/ in the examples.

Checking out

svn co svn+ssh://example.com/path/to/svnrepos/surveil surveil_local

Updating your local copy

cd surveil_local; svn up

See all codes at the bottom of this page

Status

  • svn st Show the status of your local copy vs the last time you updated. No network access.
  • svn st -u Displays update information from the repos. Uses the network
  • See all codes at the bottom of this page

Dealing with conflicts

Look for the ‘C’

svn up will display a C in the update status of a file if it finds a conflict. Use svn status -u to look for these problems before they occur.

Steps to resolve the conflict

  1. cd to the dir of the conflicted file
  2. There should be at least 4 copies of it listed as:
  3. .mine – file in your local as it existed before svn up
  4. .old_ref – file from last svn up
  5. .new_rev – file from this svn up
  6. .normal_extension – merged file with conflict “tags”
  7. Merge the conflicts by hand, meaning: Edit the .normal_extension file or copy one of the versions over this file. You’ll have to decide.
  8. svn resolved my_file.normal_extension
  9. svn ci -m 'Conflics resolved! This version is great.' my_file.normal_extension

Status Codes
The first six columns in the output are each one character wide:

First column: Says if item was added, deleted, or otherwise changed

  • ’ ’ no modifications
  • ‘A’ Added
  • ‘C’ Conflicted
  • ‘D’ Deleted
  • ‘I’ Ignored
  • ‘M’ Modified
  • ‘R’ Replaced
  • ‘X’ item is unversioned, but is used by an externals definition
  • ‘?’ item is not under version control
  • ‘!’ item is missing (removed by non-svn command) or incomplete
  • ‘~’ versioned item obstructed by some item of a different kind

Second column: Modifications of a file’s or directory’s properties

  • ’ ’ no modifications
  • ‘C’ Conflicted
  • ‘M’ Modified

Third column: Whether the working copy directory is locked

  • ’ ’ not locked
  • ‘L’ locked

Fourth column: Scheduled commit will contain addition-with-history

  • ’ ’ no history scheduled with commit
  • ‘+’ history scheduled with commit

Fifth column: Whether the item is switched relative to its parent

  • ’ ’ normal
  • ‘S’ switched

Sixth column: Repository lock token

(without -u)

  • ’ ’ no lock token
  • ‘K’ lock token present

(with -u)

  • ’ ’ not locked in repository, no lock token
  • ‘K’ locked in repository, lock toKen present
  • ‘O’ locked in repository, lock token in some Other working copy
  • ‘T’ locked in repository, lock token present but sTolen
  • ‘B’ not locked in repository, lock token present but Broken

The out-of-date information appears in the eighth column (with -u):

  • ‘*’ a newer revision exists on the server
  • ’ ’ the working copy is up to date

Remaining fields are variable width and delimited by spaces:

  • The working revision (with -u or -v)
  • The last committed revision and last committed author (with -v)
  • The working copy path is always the final field, so it can
    include spaces.
    #

Ignoring files in a directory, like log/

We don’t want our log files versioned, so let’s remove them from SVN and tell SVN to ignore them in the future. You could also ignore the database.yml file, but I never do since I always mimic my development environment’s settings when I work from various machines (i.e. I use the same MySQL login and password from machine to machine).

  • svn remove log/*
  • svn propset svn:ignore "*.*" log/
  • svn ci -m "removing log files and ignoring them in the future"
  • svn up

Branches

Be sure to read the svn-book about branches and merging! This is just a tribute…

Extra software to make things easier, http://www.orcaware.com/svn/wiki/Svnmerge.py

This software will make sure you don’t merge revisions twice.

A good use example

Creating

  • just copy trunk to a branch of your choice svn copy svn+ssh://example.com/path/to/svnrepos/surveil/trunk svn+ssh://example.com/path/to/svnrepos/surveil/branches/my_new_branch -m "I just created my own personal branch from the trunk"
  • checkout your new branch: svn co svn+ssh://example.com/path/to/svnrepos/branches/my_new_branch local_path_to_branch
  • cd local_path_to_branch
  • Use the svnmerge software svnmerge.py init
  • svn ci -F svnmerge-commit-message.txt
  • rm svnmerge-commit-message.txt

Keeping up-to-date with the trunk

  1. Make your changes to the branch
  2. Every now and then see what updates are available from the trunk: svnmerge.py avail
  3. Update your branch from the trunk: svnmerge.py merge
  4. Resolve any conflicts!
  5. @svn ci -F svnmerge-commit-message.txt # Check in the trunk merges: @
  6. rm svnmerge-commit-message.txt
  7. goto step 1.

Merging your branch back to the Trunk

  1. Find out in what change set revision your branch was created
    • cd local_path_to_branch
    • svn log --stop-on-copy (the oldest entry is the revision you are looking for, assume for the example it is 12345)
  2. (Temporarily) initialize merge tracking on the trunk, for your branch
    • cd trunk-working-copy
    • svnmerge.py init -r1-12345 svn+ssh://example.com/path/to/svnrepos/branches/my_new_branch
  3. Perform the actual merge
    • svnmerge.py merge -bF
  4. Resolve any conflicts…
  5. edit svnmerge-commit-message.txt to say what functionality you are merging into the trunk…
  6. Commit the merge, but discard the changes made to the svnmerge-integrated property on /trunk
    • svn propdel svnmerge-integrated .
    • svn commit -F svnmerge-commit-message.txt
    • rm svnmerge-commit-message.txt
  7. Remove your branch
  8. svn rm svn+ssh://example.com/path/to/svnrepos/branches/my_new_branch
  9. Done

The Decider said over 2 years ago permalink Comment? (0)
Tagged: keynote svn subversion

Keynote kills .svn

Gee thanks keynote. Just when I was beginning to like your great abilities you go and rewrite your entire bundle (read directory) on every save thus blowing away the .svn directory. I can’t think of anyway around this since subversion requires .svn dirs at each level of hierarchy. I suppose now is the time to switch to git or bazaar