SVN

From Attie's Wiki
(Redirected from Svn)
Jump to: navigation, search

My svn cheat sheet! See my git cheat sheet

command description
svn co <path> checks out a copy of the project
svn up retrieves the latest version of the project
svn ci commits any changes
svn pe property edit... see below for examples
svn pe svn:ignore . add items to the ignore list
svn revert [file] revert file(s)
svn log ^/ list the full revision history for this repository
svn merge -r HEAD:<revision> [file] reset a file to the state it was in at <revision>

Contents

SVN+SSH using a specific identity

export SVN_SSH="ssh -i /home/attie/.ssh/custom.id_rsa"

Get Full History of a File

Credit: bendin on StackOverflow.com

function history_of_file() {
    url=$1 # current url of file
    svn log -q $url | grep -E -e "^r[[:digit:]]+" -o | cut -c2- | sort -n | {
 
#       first revision as full text
        echo
        read r
        svn log -r$r $url@HEAD
        svn cat -r$r $url@HEAD
        echo
 
#       remaining revisions as differences to previous revision
        while read r
        do
            echo
            svn log -r$r $url@HEAD
            svn diff -c$r $url@HEAD
            echo
        done
    }
}

Extracting a Sub-Tree

Extract an SVN subtree - Import into Git
This section will show you how to extract a sub-tree from one repository, and make it the base of a new repository.

  • First, extract everything in the repository (do not strip the revisions)
  • Filter the path you wish to keep
  • At this point, you must remove the Node-path: support/doc directory add item, which will become the root
  • Change the path to the base
  • Create a fresh repository
  • Load the filtered & relocated dump into the new repository
EXTRACT_PATH="support/doc"
 
svnadmin dump ./firstRepo > extracted
 
cat extracted | svndumpfilter include --drop-empty-revs --renumber-revs $EXTRACT_PATH > filtered
 
cat filtered | awk "BEGIN{p=1}{
                 if (p == 1) {
                    if (\$0 == \"Node-path: $EXTRACT_PATH\") p = 0;
                    if (p == 1) print \$0
                 } else {
                   if (\$0 == \"PROPS-END\") p = 1
                 }}" > filtered2
 
cat filtered2 | sed -re "s#^(Node(-copyfrom)?-path): $EXTRACT_PATH#\\1: #" > relocated
 
svnadmin create ./freshRepo
 
cat relocated | svnadmin load --ignore-uuid ./freshRepo

Dump a remote repository

svnadmin create localrepo
 
cat << EOF > localrepo/hooks/pre-revprop-change
#!/bin/bash
exit 0
EOF
 
chmod +x localrepo/hooks/pre-revprop-change
 
svnsync init --username $USERNAME file://`pwd`/localrepo $REMOTE_REPO
 
svnsync sync --username $USERNAME file://`pwd`/localrepo
 
svnadmin dump ./localrepo | gzip > dump.gz

Load a dump into a new repository

svnadmin create repo
 
cat dump.gz | gzip -d | svnadmin load ./repo
 
# optionally check it out to ensure the repo is good
svn co file://`pwd`/repo ./checkout
Personal tools
Namespaces

Variants
Actions
Navigation
Toolbox