Craig's Subversion Notes

Reference:

Properties:

(List properties)
svn proplist main.c
Properties on 'main.c':
  svn:keywords
  svn:eol-style

(Get properties)
svn propget svn:keywords main.c
Author Date Id Revision

(Set ignored file list)
svn propedit svn:ignore .

(Set keywords)
svn propset svn:keywords 'Author Date Id Revision' main.c

(Set end of line style)
(Note: incompatible with configure scripts generated by autoconf 2.62)
svn propset svn:eol-style native main.c

(Set executable)
svn propset svn:executable '*' install-sh

Initial creation:

(local)
svnadmin create --fs-type fsfs /usr/src/svn/project
svn mkdir file:///usr/src/svn/project/trunk -m ''
svn mkdir file:///usr/src/svn/project/branches -m ''
svn mkdir file:///usr/src/svn/project/tags -m ''

Initial checkout:

(HTTP)
svn checkout http://svn.icir.org/bro/trunk/bro bro-svn

(SSH)
svn checkout svn+ssh://fred@nosuch.xyz/usr/src/svn/project/trunk project

(local)
svn checkout file:///usr/src/svn/project/trunk project

Diff:

(context)
svn diff -r70:72 main.c

(straight)
svn diff --diff-cmd diff --extensions --normal -r70:72 main.c

(whitespace)
svn diff --diff-cmd diff --extensions '--normal -i' -r70:72 main.c

(whitespace and ignore case)
svn diff --diff-cmd diff --extensions '--normal -iw' -r70:72 main.c

Tagging:

svn copy file:///usr/src/svn/project/trunk \
    file:///usr/src/svn/project/release-1.3 -m "release-1.3"

Edit a log message:

(Enable on the repo system)
cd /usr/src/svn/project/hooks && \
    cp -pi pre-revprop-change.tmpl pre-revprop-change && \
    chmod +x pre-revprop-change

(Edit last commited version)
svn propedit -rHEAD --revprop svn:log

(Edit in a working copy)
svn propedit -r58 --revprop svn:log

(Edit on the repo system)
svn propedit -r58 --revprop svn:log \
    file:///usr/src/svn/project

(Edit from a different host)
svn propedit -r58 --revprop svn:log \
    svn+ssh://fred@nosuch.xyz/usr/src/svn/project

Revision dates:

svn log -r '{2012-01-19}'
svn log -r '{16:00:00}'

.subversion/config:

(Don't forward ssh creds, X11 or ports)
ssh = ssh -ax -o clearallforwardings=yes

(Default svn keywords)
*.c = svn:eol-style=native;svn:keywords=Author Date Id Revision
*.h = svn:eol-style=native;svn:keywords=Author Date Id Revision

Switch the repository root:

svn switch --relocate \
    file:///usr/src/svn/apache24-conf \
    file:///usr/src/svn/crd-apache24-conf

Undelete a file:

First find the revision you want;

svn log -v | more
Then copy the file into your working tree:

svn copy file:///usr/src/svn/project/trunk/test.c/@666 test2.c
svn copy svn+ssh://nosuch.xyz/svn/project/trunk/test.c/@666 test2.c

Copy Files Between Repos With History:

The basic strategy is to dump the entire source repo with svnadmin dump, use svndumpfilter to select the source files you want, and then use svnadmin load to insert it in the destination repo.

svnrdump can be used to dump/load with network repos.

It is wise to backup the destination repo before trying this! If anything goes wrong, it's not uncommon for the destination repo to be left in a "locked" state. "svn unlock" can help with this.

Commit hooks can cause problems for this workflow. What seems to work is to create a script containing:

#!/bin/sh
# XXX allow everything
exit 0

Then copy it to hooks/pre-commit and hooks/pre-revprop-change in the destination repo. (Don't forget to remove these when you're done!)

Here are some sample commands:

svnrdump dump svn+ssh://example.org/svn/test1 > test1.dmp
svndumpfilter include trunk/handy.c < test1.dmp > test2-handy.dmp
svnrdump load svn+ssh://example.org/svn/test2 < test2-handy.dmp

This will result in one svn revision in the destination repo for each source repo revision that applies to the file(s) being copied.

A limitation is that no files or directories may exist in both the source and destination repos. This includes "trunk" so you need to be clever with which paths you include/exclude with svndumpfilter.

Miscellaneous:

svn update
svn commit
svn status
svn info

RCS and CVS to SVN:

RCS:


[email Craig]