summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTzafrir Cohen <tzafrir@cohens.org.il>2010-04-24 12:41:39 +0300
committerTzafrir Cohen <tzafrir@cohens.org.il>2010-04-24 12:41:39 +0300
commita5bef393150fe8ac6a520cb062aea612704f1917 (patch)
treeb80596465ad1a6ea52d5bb87dcb33a2d3cdbb9c3
parentcbbf98c40787e3e5ee7c8a2f8d440031713db6a6 (diff)
rb-branch: generate a local branch from a review
-rwxr-xr-xrb-branch33
1 files changed, 33 insertions, 0 deletions
diff --git a/rb-branch b/rb-branch
new file mode 100755
index 0000000..804b815
--- /dev/null
+++ b/rb-branch
@@ -0,0 +1,33 @@
+#!/bin/sh
+
+error() {
+ me=`basename $0`
+ echo >&2"$me: Error: $*"
+ exit 1
+}
+
+set -e
+
+tmp_patch_file="rb-tmp.diff"
+svn_branch_prefix=""
+
+dir=`dirname $0`
+rb_patch="$dir/rb-patch"
+if [ ! -x "$rb_patch" ]; then
+ error "rb-patch exxecutable not available. Tried: $rb_patch."
+fi
+
+$rb_patch "$@" >"$tmp_patch_file"
+branch=`grep '^Svn-Branch:' $tmp_patch_file | sed -e 's|.*/||'`
+svn_branch="${svn_branch_prefix}svn_$branch"
+review_num=`awk '/^Review:/ {print $2}' $tmp_patch_file`
+diff_num=`awk '/^Diff:/ {print $2}' $tmp_patch_file`
+svn_revision=`awk '/^Svn-Revision:/ {print $2}' $tmp_patch_file`
+
+
+# We may need an older version from that branch.
+# Sadly I don't know how to get that specific revision from git-svn
+new_branch="$branch-rb-r$review_num-d$diff_num"
+git checkout -b "$new_branch" "$svn_branch"
+git am "$tmp_patch_file"
+rm "$tmp_patch_file"