René Nyffenegger's collection of things on the web
René Nyffenegger on Oracle - Most wanted - Feedback -
 

Subversion

Subversion is a tool for version control. It is a ground-up rewrite of CVS with many advantages.

Subversion's Homepage

Available subcommands

add

blame (praise, annotate, ann)

cat

checkout

co is an abbreviation that can be used instead of checkout.
On windows, the following syntax can be used for the file protocol:
svn checkout file:///C:/path/to/repository
Checking out a repository creates a local copy of it, containing the HEAD revision.
checkout is an initial action, probably only needed once per repository. After having checked out a repository, you wil most probably use update.

cleanup

commit

ci is an abbreviation that can be used instead of commit.
After commiting a file into the repository, other users will see this 'latest' verson of the commited file.
A commit increases the version number.

copy (cp)

co is an abbreviation that can be used instead of copy.

delete

del, remove and rm are abbreviations that can be used instead of delete.

diff (di)

This command is one of the three to examine changes.
Creating patch files:
svn diff > patch_file

export

help

? and h are abbreviations that can be used instead of help.
svn help <subcommand> shows options about subcommands.

import

info

list (ls)

log

merge

mkdir

move

mv, rename and ren are abbreviations that can be used instead of move.
A shorter form for svn copy foo.cpp bar.cpp and svn delete foo.cpp

propdel (pdel, pd)

propedit (pedit, pe)

propget (pget, pg)

propget can be used to retrieve the value of a property previously set with propset.

proplist (plist, pl)

propset (pset, ps)

Used to set a property.

resolved

Removes the three temporary files

revert

This command is one of the three to examine changes.
Overwrites the file with the pristine version

status

stat and st are abbreviations that can be used instead of status.
This command displays the states of the files in the working directory.
This command is one of the three to examine changes.
  • A: File or directory is scheduled for addition into the repository
  • C: File or directory is conflicting state.
  • D: File or directory is scheduled for deletion into the repository
  • M: File was modified
  • X: Directory in unversioned, but is related to external definitions.
  • ?: File or directory is not under version control. (use -q (--quiet) to supress)
  • !: File or directory is under version control but missing (or incomplete(?)). For example after removing the file without delete
  • ~: File should be directory or vice versa

switch (sw)

update

up is an abbreviation that can be used instead of update.
Updating a file or files sort of synchronizes changes on that file with changes other users made on that file. That is, it, update brings the (local) working copy into
A repository must be checked out befor any changes, updates and the like can be made on it.
updating a repository is therefor usually the first step in a work cycle.
  • U: file was updated
  • A: file was added
  • D: file was deleted
  • R: file was replaced (same name, different file....)
  • G: file was merged.
  • C: Conflict!!!!

Basic Work Cycle

Update your working copy

Make changes

Examine your changes

Merge others' changes

Commit your changes

Repository

Creating

svnadmin create path/to/repos

Working copy

Working directory

Subversion records two pieces of information (within .svn/ about each file within the working directory:
  • The revision the file is based on
  • A timestamp indicating when the local copy was last updated.
A file within a working directory has one of the following four states:
  • Unchanged and current
  • Locally changed and current
  • Unchanged, out of date
  • Locally changed and out of date
The state for files can be checked with the status command

.svn

Also called the administrative area.
Each directory in a working directory contains a .svn directory.
.svn is also used in order to determine which files need to be updated.

Version numbers

Version numbers apply to entire trees, not to individual files. This implies that version V and W of a file do not necessarily differ (which is different from how CVS handles it.
It is helpful to think of version number N as to the state of the repository after the Nth commit.

Revision

A revision is a snapshot of the repository of a particular moment in time.
Revisions can be specified using the --revision (or -r) switch.

Revisions can also be referred to with date in curly braces: --revision {2002-08-28} or --revision {"2002-08-28 22:21"}.
Note, {2002-08-28} referres to as {"2002-08-28 00:00"}, which might lead to some unexpected results.
<

ASE Revision

A BASE revision is the version of the last update, also called pristine copy. It is stored in the .svn directory.
The idea behind the pristine copy is to make it possible to quickly (that is, without contacting the repository on the server) a diff, status and revert

HEAD Revision

The latest revision in the repository

COMMITED Revision

The latest revision in the repository

PREV Revision

Conflicts

Conflicts can be detected with the update command. When Subversion detects a conflict in a file, it places conflict markers into the file (to allow the user to find the places of the conflict) and creates the following three files in the directory:
  • filename.mine
    The file without the conflict markers
  • filename.rOLDREV
    The file as it was before I started to change it.
  • filename.rNEWREV
    The HEAD revision of the file

Resolving conflicts

Conflicts can be resolved by doing one of the following three things:
  • Merge the conflicting areas (conflict markers)
  • replace the file in question with one of the three files mentioned above
  • running svn resolved