Add remote merge script.
authorbatt <batt@38d2e660-2303-0410-9eaa-f027e97ec537>
Mon, 6 Oct 2008 17:38:11 +0000 (17:38 +0000)
committerbatt <batt@38d2e660-2303-0410-9eaa-f027e97ec537>
Mon, 6 Oct 2008 17:38:11 +0000 (17:38 +0000)
git-svn-id: https://src.develer.com/svnoss/bertos/trunk@1881 38d2e660-2303-0410-9eaa-f027e97ec537

bertos/remote_merge [new file with mode: 0755]

diff --git a/bertos/remote_merge b/bertos/remote_merge
new file mode 100755 (executable)
index 0000000..1c4e869
--- /dev/null
@@ -0,0 +1,40 @@
+#!/bin/bash
+#set -x
+
+if [ $# -lt 2 ] ; then
+       printf "\nMerge remote url commits into local BeRTOS svn repository.\n"
+       printf "Usage: $0 <REMOTE_URL> <REMOTE_START_REV> [<REMOTE_END_REV>]\n"
+       printf "If remote end revision is not supplied HEAD will be used.\n"
+fi
+
+
+MERGE_URL="$1"
+START_REV="$2"
+if [ z"$3" = z ] ; then
+       END_REV=HEAD
+else
+       END_REV="$3"
+fi
+
+#Get list of revisions to merge.
+REV_LIST=`svn log $MERGE_URL -r$START_REV:$END_REV --quiet 2>&1| perl -ne 'if(m/^r([0-9]+)/) {print $1, "\n";}'`
+
+printf "Merged from external project:\n" > header
+for rev in $REV_LIST
+do
+       #Get commit log message only
+       #svn pg --revprop -r$rev svn:log $MERGE_URL > tmp_msg
+       
+       #Get revision commit log with date and author
+       svn log -r$rev $MERGE_URL > tmp_msg
+       #Replace leading and trailing banners "---------------------..."
+       sed -i 's/^-\+/\*\*\*\*\*\*\*\*\*\*/' tmp_msg
+       #Indent all message
+       sed -i 's/\(^.*\)/\t\1/' tmp_msg
+       cat header tmp_msg > commit_msg
+       #Try to merge ...
+       svn merge $MERGE_URL -c$rev || exit 1
+       #and commit!
+       svn ci -Fcommit_msg
+done
+rm -rf header tmp_msg commit_msg