Created
March 9, 2012 09:50
-
-
Save nikcorg/2005881 to your computer and use it in GitHub Desktop.
Preview what will happen when you svn update
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.