From 64111d3ac61a8d0f8b28de26511525d20cd72124 Mon Sep 17 00:00:00 2001 From: Henrik Levkowetz Date: Sat, 14 Mar 2020 19:00:27 +0000 Subject: [PATCH] Added automatic naming to bin/mkpatch when changeset or revision range is given. - Legacy-Id: 17440 --- bin/mkpatch | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/bin/mkpatch b/bin/mkpatch index 075eadb3a..7a3218c40 100755 --- a/bin/mkpatch +++ b/bin/mkpatch @@ -71,8 +71,8 @@ trap 'echo "$program($LINENO): Command failed with error code $? ([$$] $0 $*)"; # Option parsing # Options -shortopts=c:r:hvV -longopts=change=,revision=,help,verbose,version +shortopts=c:or:hvV +longopts=change=,overwrite,revision=,help,verbose,version # Default values @@ -92,6 +92,7 @@ fi while true ; do case "$1" in -c| --change) CHG="$2"; shift;; # the change made by revision ARG + -o| --overwrite) OVER=1;; # overwrite any existing patch file -r| --revision) REV="$2"; shift;; # the change made between revisions REV -h| --help) usage; exit;; # Show this help, then exit -v| --verbose) VERBOSE=1;; # Be more talkative @@ -105,14 +106,20 @@ done # ---------------------------------------------------------------------- # The program itself -if [ $# -lt 2 ]; then die "Expected patch name and file list on the command line."; fi -if [[ $1 =~ / ]]; then die "Expected a patch name, but the first argument to $program seems to be a file path: '$1'"; fi - -name=$1; shift; -if [ "$CHG" ]; then name="$name-c$CHG"; fi +if [ "$CHG" ]; then + name=$(svn log -c $CHG | sed -r -e '/^---/d' -e '/^r[0-9]+/d' -e '/^$/d' -e 's/(.*)/\L\1/' -e 's/[^[:alnum:]]/-/g' -e 's/-+/-/g' | cut -c 1-32) + name="$name-c$CHG" +elif [ "$REV" ]; then + name=$(echo $(svn log -r $REV | sed -r -e '/^---/d' -e '/^r[0-9]+/d' -e '/^$/d') | sed -r -e 's/(.*)/\L\1/g' -e 's/[^[:alnum:]]/-/g' -e 's/-+/-/g' | cut -c 1-32) + name="$name-r${REV/:/-}" +else + if [ $# -lt 2 ]; then die "Expected patch name and file list on the command line."; fi + if [[ $1 =~ / ]]; then die "Expected a patch name, but the first argument to $program seems to be a file path: '$1'"; fi + name=$1; shift; +fi patchfile=$progdir/../../patches/$(date +%Y-%m-%d)-$name.patch -if [ -e $patchfile ]; then die "Patchfile $patchfile already exists"; fi +if [ -e $patchfile -a ! -n "$OVER" ]; then die "Patchfile $patchfile already exists"; fi svn diff ${CHG:+ -c $CHG} ${REV:+ -r $REV} "$@" > $patchfile less $patchfile echo ""