Commit 38c40ad3 authored by gejun's avatar gejun

tools/patch_from_svn can generate diff from a SVN directory directly

Change-Id: I3abc602627575901d75fde42f73d73675522ee2a
parent b0b02620
#!/bin/bash
if [ -z "$1" ]; then
echo "Usage: patch_from_svn some.patch"
echo "The patch should be generated by 'svn diff -c <REV>'"
echo "Usage1: patch_from_svn PATCHFILE (generated by 'svn diff -c REVISION')"
echo "Usage2: patch_from_svn SVN_DIR REVISION"
exit 1
fi
cat $1 |sed -e 's/src\/baidu\/rpc\//brpc\//g' \
PATCHFILE=$1
if [ -d "$1/.svn" ]; then
if [ -z "$2" ]; then
echo "Second argument must be a SVN revision"
exit 1
fi
SVN_DIR=$1
REV=$2
PATCHFILE=$REV.patch
echo "*** Generating diff of $SVN_DIR@$REV"
svn diff $SVN_DIR -c $REV > $PATCHFILE
fi
MODIFIED_PATCHFILE="$(basename $PATCHFILE).brpc_os"
cat $PATCHFILE | sed -e 's/src\/baidu\/rpc\//brpc\//g' \
-e 's/\<baidu\/rpc\//brpc\//g' \
-e 's/brpc\/test\/test_\(.*\)\.cpp/test\/brpc_\1_unittest.cpp/g' \
-e 's/\<namespace \+baidu *{/namespace brpc {/g' \
......@@ -26,10 +41,11 @@ cat $1 |sed -e 's/src\/baidu\/rpc\//brpc\//g' \
-e 's/<\(base\/[^>]*\)>/"\1"/g' \
-e 's/<\(bthread\/[^>]*\)>/"\1"/g' \
-e 's/<\(mcpack2pb\/[^>]*\)>/"\1"/g' \
> $1.brpc_os
> $MODIFIED_PATCHFILE
EXTRA_ARGS=
if [ -z "$DO_RUN" ]; then
EXTRA_ARGS="--dry-run $EXTRA_ARGS"
echo "*** This is a dry-run. To really apply, run: DO_RUN=1 tools/patch_from_svn $1"
fi
patch -p0 -u $EXTRA_ARGS < $1.brpc_os
patch -p0 -u $EXTRA_ARGS < $MODIFIED_PATCHFILE
rm $MODIFIED_PATCHFILE
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment