Return-Path: X-Original-To: apmail-hadoop-common-commits-archive@www.apache.org Delivered-To: apmail-hadoop-common-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 96D5B10936 for ; Fri, 10 Apr 2015 04:25:09 +0000 (UTC) Received: (qmail 83147 invoked by uid 500); 10 Apr 2015 04:25:01 -0000 Delivered-To: apmail-hadoop-common-commits-archive@hadoop.apache.org Received: (qmail 82764 invoked by uid 500); 10 Apr 2015 04:25:01 -0000 Mailing-List: contact common-commits-help@hadoop.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: common-dev@hadoop.apache.org Delivered-To: mailing list common-commits@hadoop.apache.org Received: (qmail 79649 invoked by uid 99); 10 Apr 2015 04:24:59 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 10 Apr 2015 04:24:59 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id 10BAAE022E; Fri, 10 Apr 2015 04:24:58 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: zjshen@apache.org To: common-commits@hadoop.apache.org Date: Fri, 10 Apr 2015 04:25:16 -0000 Message-Id: <94c705fdeb5c40189ab8d657a5ffb573@git.apache.org> In-Reply-To: References: X-Mailer: ASF-Git Admin Mailer Subject: [20/47] hadoop git commit: HADOOP-11781. fix race conditions and add URL support to smart-apply-patch.sh (Raymie Stata via aw) 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/b6434b15 Tree: http://git-wip-us.apache.org/repos/asf/hadoop/tree/b6434b15 Diff: http://git-wip-us.apache.org/repos/asf/hadoop/diff/b6434b15 Branch: refs/heads/YARN-2928 Commit: b6434b15f92ad0d250d60e3580807bd8dc37e55b Parents: 0a4a296 Author: Allen Wittenauer Authored: Wed Apr 8 10:05:25 2015 -0700 Committer: Zhijie Shen Committed: Thu Apr 9 20:55:59 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/b6434b15/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/b6434b15/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