Skip to content

Instantly share code, notes, and snippets.

@rkbodenner
Created December 14, 2010 22:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rkbodenner/741230 to your computer and use it in GitHub Desktop.
Save rkbodenner/741230 to your computer and use it in GitHub Desktop.
Helpful SVN shell functions
### SVN commands
# Run these in the tag/branch working copy root.
# The svn_merge* functions depend on having 'trunk' and '<tag name>' working copies in the same directory.
SVN_TRUNK=~/_work/Site/trunk
# Print changelog since the last tag was cut
function tag_patches()
{
if expr `pwd` : '.*/m[0-9][0-9]-[0-9][0-9]-[0-9][0-9]$' > /dev/null; then
svn log | perl -ne 'printf; if ($_ =~ /^Tag m.*/) { last; }'
else
echo Error: Run in a tag directory \(e.g., m10-10-26\)
fi
}
function last_path_segment()
{
DIR=$1
echo ${DIR} | sed -e 's/.*\/\([^\/]*\)/\1/'
}
# Print the commit message from the given revision at the given SVN URL, annotated with where it came from
function svn_merge_msg()
{
REV=$1
URL=$2
TAG=$(last_path_segment ${URL})
echo -n "Merge from ${REV}@${TAG}: "
svn log ${URL} -r ${REV} | tail -n +4 | grep -ve '^\s*$' | grep -ve '^-*$'
}
# Argument: revision number to merge
function svn_merge_from_trunk()
{
TRUNK="^/projects/Site/trunk"
svn merge --ignore-ancestry -c $1 ${TRUNK} .
svn_merge_msg $1 ${TRUNK}
}
# Argument: revision number to merge
function svn_merge_to_trunk()
{
svn merge --ignore-ancestry -c $1 . ${SVN_TRUNK}
svn_merge_msg $1 `pwd`
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment