Subversion

From miki
Revision as of 09:06, 25 November 2013 by Mip (talk | contribs) (→‎Workflows)
Jump to navigation Jump to search

References

Configuration

  • Colored diff — Either define colordiff as diff-cmd in ~/.subversion/config:
  • diff-cmd = colordiff
    

    However, to keep the internal svn diff tool, you need to define your own function & alias. This will also highlight diff header in green:

    function svnwrap()
    {
        if [ "$1" = "diff" ] ; then
    		"svn" "$@" | colordiff | less -FRX
    	else
    		"svn" "$@"
    	fi
    }
    alias svn=svnwrap
    

    To page the output, use | less -R

Workflows

Create default folder layout

From [1]:

url=svn://somewhere
svn mkdir $url/$1/trunk $url/$1/branches $url/$1/tags -m "New project $1" --parents

Or on a repository that is already checked out:

svn mkdir trunk branches tags
svn mv src trunk               # Assuming we already have a dir 'src' that needs to be moved to trunk
svn commit -m "create default layout"

Branch integration

From [2]:

  • Create a new branch off the trunk
  • Work on the branch
  • Merge (reintegrate) the branch into trunk
cd trunk
svn merge --reintegrate ^/branches/topic
svn commit
# Committed revision 555. 
# # this revision is ^^^^ important
  • From now on:
    • Either delete the branch
      svn delete ^/branches/topic
      
    • Or merge trunk back to the branch so that subsequent merges do not generate conflicts.
      This steps is necessary to tell svn that it should ignore the merged revision on the trunk at the next branch reintegration):
cd branches/topic
svn merge --record-only -c 555 ^trunk
svn commit

Commands

status (st)

Show modified/new/... files in the working copy.

svn status

propget (pg)

svn propget svn:mergeinfo

info

svn info .
svn info /dir/file

HTTPS Client Certificates

References:

Besides requiring a password, access to a svn repository through HTTPS may also require a client-side certificate. In that case, svn is smart enough to prompt for the location of the file containing the certificate and private key and for the password.

This can also be configured in the file ~/.subversion/servers:

[groups]
myserver = *.myserver.org

# This contains the settings for group "myserver". 
# ! paths must be absolute !
# Client certificates are in format .p12 (same as .pfx), as generated by openssl pkcs12
[myserver]
#The file containing your client certificate
ssl-client-cert-file = /home/user/.subversion/clientcert.p12
#This gives a list of CA to use to authenticate the server certificate
ssl-authority-files = /absolute/path/to/cacert.pem,/absolute/path/to/root.pem

# Add the following to prevent SVN storing your passwords:
[auth]
store-passwords = no
store-auth-creds = no


Changing the client certificate password

See SSL for instructions on how to change the client certificate password.

How-To

re-fetch a range of revisions

See [3]:

# Re-fetch from revision 2010:
git svn reset -r 2010
git svn fetch

Examples

  • Checking out a project
svn co svn+ssh://ftp.noekeon.org/opt/www/daemenj/web/private/SVN/Keccak