12e5b6d6dSopenharmony_ci#!/bin/bash 22e5b6d6dSopenharmony_ci# 32e5b6d6dSopenharmony_ci# Copyright (C) 2017 and later: Unicode, Inc. and others. 42e5b6d6dSopenharmony_ci# License & terms of use: http://www.unicode.org/copyright.html 52e5b6d6dSopenharmony_ci# 62e5b6d6dSopenharmony_ci# Copyright (c) 2012-2014, International Business Machines Corporation and others. All Rights Reserved. 72e5b6d6dSopenharmony_ci# for fixing misticketted 82e5b6d6dSopenharmony_ci# see http://bugs.icu-project.org/trac/wiki/MisTicketted 92e5b6d6dSopenharmony_ci# TODO: cleanup ${TMPF}* 102e5b6d6dSopenharmony_ci 112e5b6d6dSopenharmony_ci 122e5b6d6dSopenharmony_ci 132e5b6d6dSopenharmony_cirev= 142e5b6d6dSopenharmony_cifrom= 152e5b6d6dSopenharmony_cito= 162e5b6d6dSopenharmony_ci 172e5b6d6dSopenharmony_ciusage() 182e5b6d6dSopenharmony_ci{ 192e5b6d6dSopenharmony_ci echo "$0 -r rev -f frombug -t tobug" 202e5b6d6dSopenharmony_ci} 212e5b6d6dSopenharmony_ci 222e5b6d6dSopenharmony_ciwhile getopts "r:f:t:" opt; do 232e5b6d6dSopenharmony_ci case $opt in 242e5b6d6dSopenharmony_ci r) 252e5b6d6dSopenharmony_ci rev=$OPTARG 262e5b6d6dSopenharmony_ci ;; 272e5b6d6dSopenharmony_ci f) 282e5b6d6dSopenharmony_ci from=$OPTARG 292e5b6d6dSopenharmony_ci ;; 302e5b6d6dSopenharmony_ci t) 312e5b6d6dSopenharmony_ci to=$OPTARG 322e5b6d6dSopenharmony_ci ;; 332e5b6d6dSopenharmony_ci \?) 342e5b6d6dSopenharmony_ci echo "Invalid: -$OPTARG" >&2 352e5b6d6dSopenharmony_ci usage 362e5b6d6dSopenharmony_ci exit 1 372e5b6d6dSopenharmony_ci ;; 382e5b6d6dSopenharmony_ci esac 392e5b6d6dSopenharmony_cidone 402e5b6d6dSopenharmony_ci 412e5b6d6dSopenharmony_ciif [[ ! $rev ]]; 422e5b6d6dSopenharmony_cithen 432e5b6d6dSopenharmony_ci echo "need -r rev option" >&2 442e5b6d6dSopenharmony_ci usage 452e5b6d6dSopenharmony_ci exit 1 462e5b6d6dSopenharmony_cifi 472e5b6d6dSopenharmony_ci 482e5b6d6dSopenharmony_ciif [[ ! $from ]]; 492e5b6d6dSopenharmony_cithen 502e5b6d6dSopenharmony_ci echo "need -f oldbug option" >&2 512e5b6d6dSopenharmony_ci usage 522e5b6d6dSopenharmony_ci exit 1 532e5b6d6dSopenharmony_cifi 542e5b6d6dSopenharmony_ci 552e5b6d6dSopenharmony_ciif [[ ! $to ]]; 562e5b6d6dSopenharmony_cithen 572e5b6d6dSopenharmony_ci echo "need -t newbug option" >&2 582e5b6d6dSopenharmony_ci usage 592e5b6d6dSopenharmony_ci exit 1 602e5b6d6dSopenharmony_cifi 612e5b6d6dSopenharmony_ci 622e5b6d6dSopenharmony_ciif [[ ! -d .svn ]]; 632e5b6d6dSopenharmony_cithen 642e5b6d6dSopenharmony_ci echo ".svn is not a directory. Please cd somewhere else." >&2 652e5b6d6dSopenharmony_ci exit 1 662e5b6d6dSopenharmony_cifi 672e5b6d6dSopenharmony_ci 682e5b6d6dSopenharmony_ciif [[ ! -d ${TMPDIR} ]]; 692e5b6d6dSopenharmony_cithen 702e5b6d6dSopenharmony_ci TMPDIR=/tmp 712e5b6d6dSopenharmony_cifi 722e5b6d6dSopenharmony_ci 732e5b6d6dSopenharmony_ciTMPF=${TMPDIR}/reticket.r${rev}.f${from}.t${to}.txt 742e5b6d6dSopenharmony_ci 752e5b6d6dSopenharmony_ciecho "Getting log for r${rev}" >&2 762e5b6d6dSopenharmony_ci( svn pg svn:log --revprop -r ${rev} . | tee ${TMPF} | sed -e 's%^%< %g' ) || exit 1 772e5b6d6dSopenharmony_ci 782e5b6d6dSopenharmony_cihead -1 ${TMPF} > ${TMPF}.1 792e5b6d6dSopenharmony_ci 802e5b6d6dSopenharmony_ciif grep -q "^ticket:${from}[^0-9]" ${TMPF}.1; 812e5b6d6dSopenharmony_cithen 822e5b6d6dSopenharmony_ci echo "-- old/new --" 832e5b6d6dSopenharmony_cielse 842e5b6d6dSopenharmony_ci if grep -q "^ticket:${to}[^0-9]" ${TMPF}.1; 852e5b6d6dSopenharmony_ci then 862e5b6d6dSopenharmony_ci echo "r${rev} already references ticket:${to} - exiting." >&2 872e5b6d6dSopenharmony_ci exit 0 882e5b6d6dSopenharmony_ci else 892e5b6d6dSopenharmony_ci echo "Error: r${rev} doesn't pertain to ticket:${from} - was this already fixed?" >&2 902e5b6d6dSopenharmony_ci exit 1 912e5b6d6dSopenharmony_ci fi 922e5b6d6dSopenharmony_cifi 932e5b6d6dSopenharmony_ci 942e5b6d6dSopenharmony_ci( ( sed -e "s%^ticket:${from}%ticket:${to}%" ${TMPF}.1 && tail -n +2 ${TMPF} ) || exit 2 ) | tee ${TMPF}.fix | sed -e 's%^%> %g' 952e5b6d6dSopenharmony_ci 962e5b6d6dSopenharmony_ciCMD="svn ps svn:log --revprop -r ${rev} -F ${TMPF}.fix" 972e5b6d6dSopenharmony_ciecho "# ${CMD}" 982e5b6d6dSopenharmony_ciecho "type YES to do, ^C to kill" 992e5b6d6dSopenharmony_ciread foo 1002e5b6d6dSopenharmony_ciif [[ $foo = "YES" ]]; 1012e5b6d6dSopenharmony_cithen 1022e5b6d6dSopenharmony_ci echo "## Remember the server still needs to be resynced. See http://bugs.icu-project.org/trac/wiki/FixingMisTicketted" 1032e5b6d6dSopenharmony_ci exec ${CMD} 1042e5b6d6dSopenharmony_cielse 1052e5b6d6dSopenharmony_ci exit 0 1062e5b6d6dSopenharmony_cifi 1072e5b6d6dSopenharmony_ci 108