1#!/bin/bash 2# 3# Copyright (C) 2017 and later: Unicode, Inc. and others. 4# License & terms of use: http://www.unicode.org/copyright.html 5# 6# Copyright (c) 2012-2014, International Business Machines Corporation and others. All Rights Reserved. 7# for fixing misticketted 8# see http://bugs.icu-project.org/trac/wiki/MisTicketted 9# TODO: cleanup ${TMPF}* 10 11 12 13rev= 14from= 15to= 16 17usage() 18{ 19 echo "$0 -r rev -f frombug -t tobug" 20} 21 22while getopts "r:f:t:" opt; do 23 case $opt in 24 r) 25 rev=$OPTARG 26 ;; 27 f) 28 from=$OPTARG 29 ;; 30 t) 31 to=$OPTARG 32 ;; 33 \?) 34 echo "Invalid: -$OPTARG" >&2 35 usage 36 exit 1 37 ;; 38 esac 39done 40 41if [[ ! $rev ]]; 42then 43 echo "need -r rev option" >&2 44 usage 45 exit 1 46fi 47 48if [[ ! $from ]]; 49then 50 echo "need -f oldbug option" >&2 51 usage 52 exit 1 53fi 54 55if [[ ! $to ]]; 56then 57 echo "need -t newbug option" >&2 58 usage 59 exit 1 60fi 61 62if [[ ! -d .svn ]]; 63then 64 echo ".svn is not a directory. Please cd somewhere else." >&2 65 exit 1 66fi 67 68if [[ ! -d ${TMPDIR} ]]; 69then 70 TMPDIR=/tmp 71fi 72 73TMPF=${TMPDIR}/reticket.r${rev}.f${from}.t${to}.txt 74 75echo "Getting log for r${rev}" >&2 76( svn pg svn:log --revprop -r ${rev} . | tee ${TMPF} | sed -e 's%^%< %g' ) || exit 1 77 78head -1 ${TMPF} > ${TMPF}.1 79 80if grep -q "^ticket:${from}[^0-9]" ${TMPF}.1; 81then 82 echo "-- old/new --" 83else 84 if grep -q "^ticket:${to}[^0-9]" ${TMPF}.1; 85 then 86 echo "r${rev} already references ticket:${to} - exitting." >&2 87 exit 0 88 else 89 echo "Error: r${rev} doesn't pertain to ticket:${from} - was this already fixed?" >&2 90 exit 1 91 fi 92fi 93 94( ( sed -e "s%^ticket:${from}%ticket:${to}%" ${TMPF}.1 && tail -n +2 ${TMPF} ) || exit 2 ) | tee ${TMPF}.fix | sed -e 's%^%> %g' 95 96CMD="svn ps svn:log --revprop -r ${rev} -F ${TMPF}.fix" 97echo "# ${CMD}" 98echo "type YES to do, ^C to kill" 99read foo 100if [[ $foo = "YES" ]]; 101then 102 echo "## Remember the server still needs to be resynced. See http://bugs.icu-project.org/trac/wiki/FixingMisTicketted" 103 exec ${CMD} 104else 105 exit 0 106fi 107 108