hadoop-common-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From t...@apache.org
Subject svn commit: r1135633 - in /hadoop/common/trunk/common: CHANGES.txt src/test/bin/smart-apply-patch.sh src/test/bin/test-patch.sh
Date Tue, 14 Jun 2011 15:05:39 GMT
Author: todd
Date: Tue Jun 14 15:05:39 2011
New Revision: 1135633

URL: http://svn.apache.org/viewvc?rev=1135633&view=rev
Log:
HADOOP-7384. Allow test-patch to be more flexible about patch format. Contributed by Todd
Lipcon.

Added:
    hadoop/common/trunk/common/src/test/bin/smart-apply-patch.sh
Modified:
    hadoop/common/trunk/common/CHANGES.txt
    hadoop/common/trunk/common/src/test/bin/test-patch.sh

Modified: hadoop/common/trunk/common/CHANGES.txt
URL: http://svn.apache.org/viewvc/hadoop/common/trunk/common/CHANGES.txt?rev=1135633&r1=1135632&r2=1135633&view=diff
==============================================================================
--- hadoop/common/trunk/common/CHANGES.txt (original)
+++ hadoop/common/trunk/common/CHANGES.txt Tue Jun 14 15:05:39 2011
@@ -217,6 +217,8 @@ Trunk (unreleased changes)
 
     HADOOP-6605. Add JAVA_HOME detection to hadoop-config. (eli)
 
+    HADOOP-7384. Allow test-patch to be more flexible about patch format. (todd)
+
   OPTIMIZATIONS
   
     HADOOP-7333. Performance improvement in PureJavaCrc32. (Eric Caspole

Added: hadoop/common/trunk/common/src/test/bin/smart-apply-patch.sh
URL: http://svn.apache.org/viewvc/hadoop/common/trunk/common/src/test/bin/smart-apply-patch.sh?rev=1135633&view=auto
==============================================================================
--- hadoop/common/trunk/common/src/test/bin/smart-apply-patch.sh (added)
+++ hadoop/common/trunk/common/src/test/bin/smart-apply-patch.sh Tue Jun 14 15:05:39 2011
@@ -0,0 +1,72 @@
+#!/usr/bin/env bash
+#   Licensed under the Apache License, Version 2.0 (the "License");
+#   you may not use this file except in compliance with the License.
+#   You may obtain a copy of the License at
+#
+#       http://www.apache.org/licenses/LICENSE-2.0
+#
+#   Unless required by applicable law or agreed to in writing, software
+#   distributed under the License is distributed on an "AS IS" BASIS,
+#   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+#   See the License for the specific language governing permissions and
+#   limitations under the License.
+
+set -e
+
+PATCH_FILE=$1
+if [ -z "$PATCH_FILE" ]; then
+  echo usage: $0 patch-file
+  exit 1
+fi
+
+PATCH=${PATCH:-patch} # allow overriding patch binary
+
+# Cleanup handler for temporary files
+TOCLEAN=""
+cleanup() {
+  rm $TOCLEAN
+  exit $1
+}
+trap "cleanup 1" HUP INT QUIT TERM
+
+# Allow passing "-" for stdin patches
+if [ "$PATCH_FILE" == "-" ]; then
+  PATCH_FILE=/tmp/tmp.in.$$
+  cat /dev/fd/0 > $PATCH_FILE
+  TOCLEAN="$TOCLEAN $PATCH_FILE"
+fi
+
+# Come up with a list of changed files into $TMP
+TMP=/tmp/tmp.paths.$$
+TOCLEAN="$TOCLEAN $TMP"
+grep '^+++\|^---' $PATCH_FILE | cut -c '5-' | grep -v /dev/null | sort | uniq > $TMP
+
+# Assume p0 to start
+PLEVEL=0
+
+# if all of the lines start with a/ or b/, then this is a git patch that
+# was generated without --no-prefix
+if ! grep -qv '^a/\|^b/' $TMP ; then
+  echo Looks like this is a git patch. Stripping a/ and b/ prefixes
+  echo and incrementing PLEVEL
+  PLEVEL=$[$PLEVEL + 1]
+  sed -i -e 's,^[ab]/,,' $TMP
+fi
+
+# if all of the lines start with common/, hdfs/, or mapreduce/, this is
+# relative to the hadoop root instead of the subproject root, so we need
+# to chop off another layer
+PREFIX_DIRS=$(cut -d '/' -f 1 $TMP | sort | uniq)
+if [[ "$PREFIX_DIRS" =~ ^(hdfs|common|mapreduce)$ ]]; then
+
+  echo Looks like this is relative to project root. Increasing PLEVEL
+  PLEVEL=$[$PLEVEL + 1]
+elif ! echo "$PREFIX_DIRS" | grep -vxq 'common\|hdfs\|mapreduce' ; then
+  echo Looks like this is a cross-subproject patch. Not supported!
+  exit 1
+fi
+
+echo Going to apply patch with: $PATCH -p$PLEVEL
+$PATCH -p$PLEVEL -E < $PATCH_FILE
+
+cleanup 0

Modified: hadoop/common/trunk/common/src/test/bin/test-patch.sh
URL: http://svn.apache.org/viewvc/hadoop/common/trunk/common/src/test/bin/test-patch.sh?rev=1135633&r1=1135632&r2=1135633&view=diff
==============================================================================
--- hadoop/common/trunk/common/src/test/bin/test-patch.sh (original)
+++ hadoop/common/trunk/common/src/test/bin/test-patch.sh Tue Jun 14 15:05:39 2011
@@ -18,7 +18,8 @@ ulimit -n 1024
 ### Setup some variables.  
 ### SVN_REVISION and BUILD_URL are set by Hudson if it is run by patch process
 ### Read variables from properties file
-. `dirname $0`/../test-patch.properties
+bindir=$(dirname $0)
+. $bindir/../test-patch.properties
 
 ###############################################################################
 parseArgs() {
@@ -270,7 +271,8 @@ applyPatch () {
   echo "======================================================================"
   echo ""
   echo ""
-  $PATCH -E -p0 < $PATCH_DIR/patch
+  export PATCH
+  $bindir/smart-apply-patch.sh $PATCH_DIR/patch
   if [[ $? != 0 ]] ; then
     echo "PATCH APPLICATION FAILED"
     JIRA_COMMENT="$JIRA_COMMENT



Mime
View raw message