Skip to content

Commit 64111d3

Browse files
committed
Added automatic naming to bin/mkpatch when changeset or revision range is given.
- Legacy-Id: 17440
1 parent e6e0b16 commit 64111d3

1 file changed

Lines changed: 15 additions & 8 deletions

File tree

bin/mkpatch

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -71,8 +71,8 @@ trap 'echo "$program($LINENO): Command failed with error code $? ([$$] $0 $*)";
7171
# Option parsing
7272

7373
# Options
74-
shortopts=c:r:hvV
75-
longopts=change=,revision=,help,verbose,version
74+
shortopts=c:or:hvV
75+
longopts=change=,overwrite,revision=,help,verbose,version
7676

7777
# Default values
7878

@@ -92,6 +92,7 @@ fi
9292
while true ; do
9393
case "$1" in
9494
-c| --change) CHG="$2"; shift;; # the change made by revision ARG
95+
-o| --overwrite) OVER=1;; # overwrite any existing patch file
9596
-r| --revision) REV="$2"; shift;; # the change made between revisions REV
9697
-h| --help) usage; exit;; # Show this help, then exit
9798
-v| --verbose) VERBOSE=1;; # Be more talkative
@@ -105,14 +106,20 @@ done
105106
# ----------------------------------------------------------------------
106107
# The program itself
107108

108-
if [ $# -lt 2 ]; then die "Expected patch name and file list on the command line."; fi
109-
if [[ $1 =~ / ]]; then die "Expected a patch name, but the first argument to $program seems to be a file path: '$1'"; fi
110-
111-
name=$1; shift;
112-
if [ "$CHG" ]; then name="$name-c$CHG"; fi
109+
if [ "$CHG" ]; then
110+
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)
111+
name="$name-c$CHG"
112+
elif [ "$REV" ]; then
113+
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)
114+
name="$name-r${REV/:/-}"
115+
else
116+
if [ $# -lt 2 ]; then die "Expected patch name and file list on the command line."; fi
117+
if [[ $1 =~ / ]]; then die "Expected a patch name, but the first argument to $program seems to be a file path: '$1'"; fi
118+
name=$1; shift;
119+
fi
113120

114121
patchfile=$progdir/../../patches/$(date +%Y-%m-%d)-$name.patch
115-
if [ -e $patchfile ]; then die "Patchfile $patchfile already exists"; fi
122+
if [ -e $patchfile -a ! -n "$OVER" ]; then die "Patchfile $patchfile already exists"; fi
116123
svn diff ${CHG:+ -c $CHG} ${REV:+ -r $REV} "$@" > $patchfile
117124
less $patchfile
118125
echo ""

0 commit comments

Comments
 (0)