hadoop-common-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From a.@apache.org
Subject hadoop git commit: HADOOP-11781. fix race conditions and add URL support to smart-apply-patch.sh (Raymie Stata via aw)
Date Wed, 08 Apr 2015 17:05:36 GMT
Repository: hadoop
Updated Branches:
  refs/heads/trunk dd852f5b8 -> f4b3fc562


HADOOP-11781. fix race conditions and add URL support to smart-apply-patch.sh (Raymie Stata
via aw)


Project: http://git-wip-us.apache.org/repos/asf/hadoop/repo
Commit: http://git-wip-us.apache.org/repos/asf/hadoop/commit/f4b3fc56
Tree: http://git-wip-us.apache.org/repos/asf/hadoop/tree/f4b3fc56
Diff: http://git-wip-us.apache.org/repos/asf/hadoop/diff/f4b3fc56

Branch: refs/heads/trunk
Commit: f4b3fc56210824037344d403f1ad0f033961a2db
Parents: dd852f5
Author: Allen Wittenauer <aw@apache.org>
Authored: Wed Apr 8 10:05:25 2015 -0700
Committer: Allen Wittenauer <aw@apache.org>
Committed: Wed Apr 8 10:05:25 2015 -0700

----------------------------------------------------------------------
 dev-support/smart-apply-patch.sh                | 45 ++++++++++++++++----
 hadoop-common-project/hadoop-common/CHANGES.txt |  3 ++
 2 files changed, 40 insertions(+), 8 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/hadoop/blob/f4b3fc56/dev-support/smart-apply-patch.sh
----------------------------------------------------------------------
diff --git a/dev-support/smart-apply-patch.sh b/dev-support/smart-apply-patch.sh
index 03bc4f8..449fc22 100755
--- a/dev-support/smart-apply-patch.sh
+++ b/dev-support/smart-apply-patch.sh
@@ -11,8 +11,6 @@
 #   See the License for the specific language governing permissions and
 #   limitations under the License.
 
-set -e
-
 #
 # Determine if the patch file is a git diff file with prefixes.
 # These files are generated via "git diff" *without* the --no-prefix option.
@@ -54,6 +52,7 @@ if [ -z "$PATCH_FILE" ]; then
   exit 1
 fi
 
+TMPDIR=${TMPDIR:-/tmp}
 PATCH=${PATCH:-patch} # allow overriding patch binary
 
 # Cleanup handler for temporary files
@@ -66,11 +65,41 @@ trap "cleanup 1" HUP INT QUIT TERM
 
 # Allow passing "-" for stdin patches
 if [ "$PATCH_FILE" == "-" ]; then
-  PATCH_FILE=/tmp/tmp.in.$$
+  PATCH_FILE="$TMPDIR/smart-apply.in.$RANDOM"
   cat /dev/fd/0 > $PATCH_FILE
   TOCLEAN="$TOCLEAN $PATCH_FILE"
 fi
 
+ISSUE_RE='^(HADOOP|YARN|MAPREDUCE|HDFS)-[0-9]+$'
+if [[ ${PATCH_FILE} =~ ^http || ${PATCH_FILE} =~ ${ISSUE_RE} ]]; then
+  # Allow downloading of patches
+  PFILE="$TMPDIR/smart-apply.in.$RANDOM"
+  TOCLEAN="$TOCLEAN $PFILE"
+  if [[ ${PATCH_FILE} =~ ^http ]]; then
+    patchURL="${PATCH_FILE}"
+  else # Get URL of patch from JIRA
+    wget -q -O "${PFILE}" "http://issues.apache.org/jira/browse/${PATCH_FILE}"
+    if [[ $? != 0 ]]; then
+      echo "Unable to determine what ${PATCH_FILE} may reference." 1>&2
+      cleanup 1
+    elif [[ $(grep -c 'Patch Available' "${PFILE}") == 0 ]]; then
+      echo "${PATCH_FILE} is not \"Patch Available\".  Exiting." 1>&2
+      cleanup 1
+    fi
+    relativePatchURL=$(grep -o '"/jira/secure/attachment/[0-9]*/[^"]*' "${PFILE}" | grep
-v -e 'htm[l]*$' | sort | tail -1 | grep -o '/jira/secure/attachment/[0-9]*/[^"]*')
+    patchURL="http://issues.apache.org${relativePatchURL}"
+  fi
+  if [[ -n $DRY_RUN ]]; then
+    echo "Downloading ${patchURL}"
+  fi
+  wget -q -O "${PFILE}" "${patchURL}"
+  if [[ $? != 0 ]]; then
+    echo "${PATCH_FILE} could not be downloaded." 1>&2
+    cleanup 1
+  fi
+  PATCH_FILE="${PFILE}"
+fi
+
 # Special case for git-diff patches without --no-prefix
 if is_git_diff_with_prefix "$PATCH_FILE"; then
   GIT_FLAGS="--binary -p1 -v"
@@ -85,7 +114,7 @@ if is_git_diff_with_prefix "$PATCH_FILE"; then
 fi
 
 # Come up with a list of changed files into $TMP
-TMP=/tmp/tmp.paths.$$
+TMP="$TMPDIR/smart-apply.paths.$RANDOM"
 TOCLEAN="$TOCLEAN $TMP"
 
 if $PATCH -p0 -E --dry-run < $PATCH_FILE 2>&1 > $TMP; then
@@ -94,10 +123,10 @@ if $PATCH -p0 -E --dry-run < $PATCH_FILE 2>&1 > $TMP; then
   # is adding new files and they would apply anywhere. So try to guess the
   # correct place to put those files.
 
-  TMP2=/tmp/tmp.paths.2.$$
+  TMP2="$TMPDIR/smart-apply.paths.2.$RANDOM"
   TOCLEAN="$TOCLEAN $TMP2"
 
-  egrep '^patching file |^checking file ' $TMP | awk '{print $3}' | grep -v /dev/null | sort
| uniq > $TMP2
+  egrep '^patching file |^checking file ' $TMP | awk '{print $3}' | grep -v /dev/null | sort
-u > $TMP2
 
   if [ ! -s $TMP2 ]; then
     echo "Error: Patch dryrun couldn't detect changes the patch would make. Exiting."
@@ -125,8 +154,8 @@ if $PATCH -p0 -E --dry-run < $PATCH_FILE 2>&1 > $TMP; then
       sed -i -e 's,^[ab]/,,' $TMP2
     fi
 
-    PREFIX_DIRS_AND_FILES=$(cut -d '/' -f 1 | sort | uniq)
-
+    PREFIX_DIRS_AND_FILES=$(cut -d '/' -f 1 $TMP2 | sort -u)
+ 
     # if we are at the project root then nothing more to do
     if [[ -d hadoop-common-project ]]; then
       echo Looks like this is being run at project root

http://git-wip-us.apache.org/repos/asf/hadoop/blob/f4b3fc56/hadoop-common-project/hadoop-common/CHANGES.txt
----------------------------------------------------------------------
diff --git a/hadoop-common-project/hadoop-common/CHANGES.txt b/hadoop-common-project/hadoop-common/CHANGES.txt
index 412bad7..ce292b2 100644
--- a/hadoop-common-project/hadoop-common/CHANGES.txt
+++ b/hadoop-common-project/hadoop-common/CHANGES.txt
@@ -194,6 +194,9 @@ Trunk (Unreleased)
     HADOOP-11524. hadoop_do_classpath_subcommand throws a shellcheck warning.
     (cnauroth)
 
+    HADOOP-11781. fix race conditions and add URL support to
+    smart-apply-patch.sh (Raymie Stata via aw)
+
   BUG FIXES
 
     HADOOP-11473. test-patch says "-1 overall" even when all checks are +1


Mime
View raw message