Skip to content

Instantly share code, notes, and snippets.

@nikcorg
Created March 9, 2012 09:50
Show Gist options
  • Save nikcorg/2005881 to your computer and use it in GitHub Desktop.
Save nikcorg/2005881 to your computer and use it in GitHub Desktop.
Preview what will happen when you svn update
#!/bin/bash
WD="."
function extract_revision()
{
REV=$(svn info $1|grep "Revision:"|cut -d ":" -f 2-|sed -e 's/^[ ]*//')
}
function split_op_and_loc()
{
OP=$(echo $1|cut -d " " -f 1)
LOC=$(echo $1|cut -d " " -f 2-|sed -e 's/^[ ]*//')
}
function extract_repo_url()
{
REPO=$(svn info|grep "URL:"|cut -d ":" -f 2-|sed -e 's/^[ ]*//')
}
if [ -z "$1" -o "$1" != "-v" ]; then
svn merge --dry-run -r BASE:HEAD $WD
else
IFSO=$IFS
IFS=$'\n'
FILES=$(svn merge --dry-run -r BASE:HEAD $WD)
extract_repo_url
for FILE in $FILES; do
split_op_and_loc $FILE
case "$OP" in
A)
echo "***** NEW FILE: ${LOC}"
;;
U)
echo "***** UPDATE: ${LOC}"
extract_revision $LOC
;;
C)
echo "***** CONFLICT: ${LOC}"
extract_revision $LOC
;;
*)
echo "Couldn't understand: ${OP} ${LOC}"
esac
if [ ! -z "$REV" ]; then
svn diff -r $REV:HEAD $REPO/$LOC
unset REV
fi
done
IFS=$IFSO
fi
@nikcorg
Copy link
Author

nikcorg commented Mar 9, 2012

Doesn't understand other than A, U and C statuses, because that's all I needed so far, but they can be easily added. Also only works based on your current working directory.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment