Home

last update: 2020-09-20 at 22:00:27 CEST

Subversion

Often used subversion commands

Project URLs

Creating a Tag

To create a tag simply use the svn copy command. Actually every revision number is internally a tag. But they are difficult to remember. Therefore a tag marks the repository like a bookmark. A new software release for example can be tagged as tags/releases/project-1.0.0, a development snapshot could have a name like tags/snapshots/project-1.0.0-feature-XY-implementation.

Tags should be freezed after their creation. never commit on a tag. Although it is possible it will confuse other developers or customers. Better create another new tag or a branch for further development

Tagging the Trunk

Create a tag named snapshot-trunk of the trunk.

svn copy https://project.org/trunk https://project.org/tags/snapshot-trunk

Tag Your Local Working Copy

Assuming your $PWD is your projects directory (.)

svn copy . https://project.org/tags/snapshot-workingcopy

Tag a branch

svn copy https://project.org/branches/branch https://project.org/tags/snapshot-branch

Creating a Branch

Create a branch from the trunk analog to the commands above

svn copy https://project.org/trunk https://project.org/branches/branch

Remove an Added File

If you have added a file to subversion and want to undo it use svn revert

Example:

svn add file
svn revert file

Delete All Unversioned Files

The first command does print all files going to be deleted by the second command. Please check that first ;)

for f in $(svn st | grep ^?|sed 's/^?[ \t]*//'); do echo "deleting: $f";done
for f in $(svn st | grep ^?|sed 's/^?[ \t]*//'); do rm -v $f;done

Get Revisions and Date of all files in CWD

This command does show all revisions and the commit date of all files in the current working directory. egrep does filter the output of svn log. The sed command does cut away some unnecessary stuff near the end and and replaces it with the filename instead.

for f in $(ls --color=none); do svn log "$f" --limit=1 | \
egrep "(^r[0-9]+)"|sed "s/\(.*\)|.*$/\1 $f/"; done

Svn Diff

Commands you often use in the same form are to time-consuming to type them everytime. One way is to put them in a function. And put this function into your .bashrc for example

Do a normal svn diff but ignore all whitespace changes. Then pipe the output into vim.

svndiff()
{
  svn diff --diff-cmd diff -x -uw "${@}" | vim -R -
}

Count how many lines of code will be added/removed in current commit state

svnstat()
{
        rem=$(svn diff | grep ^- | wc -l)
        add=$(svn diff | grep ^+ | wc -l)
        echo "[$add lines added / $rem lines removed]"
}