Inhaltsverzeichnis

Subversion Tips

Svnbook - SVN Intro (german) - CVS Tips - Mercurial Tips

Apache Server Configuration

svnserve Server Configuration

This is not necessary if Apache Server (see above) is used!

Required

Server OS is Slackware Linux 11.0. Infos are collected from the svnbook and this site. The easiest alternative for running a svn server is used, i.e. svnserve as daemon. No apache, no SSH is used:

su -
groupadd svn
useradd -g svn -d /home/svn svn
mkdir /home/svn
chown svn:svn /home/svn
su svn
rm /home/svn/.* # delete .bash_history
svnadmin create /home/svn
exit
chmod -R o-rwx /home/svn

Note: The svnserve process ist started as a separate user svn as recommended. This increases security, but seems to prevent local access via file:///home/svn/... urls.

To start svnserve at boot time, append this to /etc/rc.d/rc.local:

su svn -c "/usr/bin/svnserve -d -r /home/svn"

To give users access to the repository, edit /home/svn/conf/svnserv.conf and /home/svn/conf/passwd see Built-in authentication and authorization

Browser Interface Configuration

This is optional. www.viewvc.org is mentioned in svnbook and used. Viewvc requieres Subversion with its SWIG Python bindings. Install swig e.g. from linuxpackages.

The Subversion which comes with Slack 11.0 is compiled witout swig/python support. Therefore download from the Slack source subversion dir, eg form here.

Now the buildscript subversion.SlackBuild has to be patched a bit in order to include the python bindings:

53a54
> make swig-py || exit 1
55a57
> make install-swig-py DESTDIR=$PKG
88a91,93
> mkdir -p $PKG/usr/lib/python2.4/site-packages
> echo "/usr/lib/svn-python" > $PKG/usr/lib/python2.4/site-packages/svn.pth
>

Run the buildscript to create a the package and install the package with upgradepkg –reinstall subversion-1.4.0-i486-1.tgz

Install viewvc by running viewrc-install (described in viewrc-1.0.4/INSTALL)

Edit /usr/local/viewrc-1.0.4/viewrc.conf:

80c80
< #svn_roots = svn: /home/svnrepos
---
> svn_roots = svn: /home/svn
105c105
< default_root = cvs
---
> default_root = svn

Copy (symlinks don't work) /usr/local/viewrc-1.0.4/bin/cgi/*.cgi to /var/www/cgi-bin

Add user nobody (Apache) to group svn in /etc/group to give Apache read permission for the svn repository. Then restart Apache and point your browser to http://server-hostname/cgi-bin/viewvc.cgi/.

Other Administration

Rename a Repostitory

Just use normal mv as root. See also

Locks

View and remove locks:

svnadmin lslocks /local/path/to/repo
svnadmin rmlocks /local/path/to/repo

Clients can remove own and other locks as well. See below!

more

Client Configuration

If you use the provieded command line svn client no config at all is necessary. This is also true if Cygwin is used as environment. Username and password are stored automatically after first login, see client credentials caching.

Client Usage

Commands refere to the SVN command line client which comes with SVN. Snytax for usage of SVN over HTTP is used. If the svnserve protocol is used, just replace http:// with svn://.

Subversion Complete Reference

First Import

Create a project. 3 directories are recommended:

becki@client:~/test$ tree testproj/
testproj/
|-- branches
|-- tags
`-- trunk
    `-- main.c

The import command imports the testproj project to the root dir of the repostitory also as project testproj

becki@client:~/test$ svn import testproj http://<servername>/<svnrootdir>/<reponame>/testproj

Checkout

svn co http://<servername>/<svnrootdir>/<reponame>/testproj

This creates the dir testproj in the current dir and fills it with the content of the project. If you want to have another directory name, just append the alternative name:

svn co http://<servername>/<svnrootdir>/<reponame>/testproj alternativeDirName

Check working copy status

[svn up]
svn st [-u] [-v] [file or dir]

The status seems to be always against the current head revision number of the local copy, not of the head of the repository. Therefore it is advisable to run svn update before.

See 1.4/svn.ref.svn.c.status.html

svn info

shows the highest revision of the current working dir.

See history of files, dirs and projects

[svn up]
svn log [-v] [fileOrDir]

The log seems to be always against the current head revision number of the local copy, not of the head of the repository. Therefore it is advisable to run svn update before running log.

FIXME verify: This way, you can always get a complete log o your project by changing into the root dir of the projcet, issuing the update command and then the log command.

Updating working directory

svn up

Brings changes from the head revision of the repository into the current dir and preserves local changes.

svn up -r <refNumber>

Brings the current dir into the state of revision of <refNumber> of the repository (and preserves local changes :?:). svn info reveals the revision of the current working dir.

Move Files and Dirs

svn move <from> <to>

Works just like the shell mv command :-) See 1.4/svn.ref.svn.c.move.html

Give up working copy

According to http://svn.haxx.se/dev/archive-2002-08/1385.shtml there is no command like the release of CVS. Just delete the working copy locally.

Branching

Intro

A branch is created simply by making a copy of the project. SVN knows only how to copy. Copies may have the meaning of branches or tags.

It is recommended to do the copy on the server, not locally. The remote copy also includes the commit in one step. Eg:

svn cp http://url/project/trunk http://url/project/branches/foo -m "Creating a branch for working on feature foo"
svn checkout http://url/project/branches/foo
project
|-- branches
|   `-- foo
|-- tags
`-- trunk

Use Cases

Merging

Intro

Merging (explanation / manpage): Apply the changes between repository tree X and repository tree Y into the working directory. Any revision on any branch is a repository tree.

Use Cases

Undoing Changes

Undoing lokal Changes

See revert

Undoing committed Changes

svn merge [--dry-run] -r 627:480 http://url/project

This command removes all changes which have been done between r480 and r627 in the workin copy. Afterwards a commit is necessary.

See also 1.4/svn.branchmerge.commonuses.html → Undoing Changes

Commit Log Message Correction

Example:

svnadmin setlog /path/to/repository --bypass-hooks logmessage.txt -r 25120

See also: Svnbook

Locks

View locks:

svn st -u

Create and remove locks:

svn lock file
svn unlock file

more → from „Discovering Locks“ on