#!/bin/bash
-hg commit "$@"
-
lrev=$(hg log --limit 1 --template '{rev}' ChangeLog)
trev=$(hg tip --template '{rev'})
-if [ $lrev = $trev ]; then exit 0; fi
-
-declare -a nopts
+if [ $lrev = $trev ]
+then
+ exec hg commit "$@"
+fi
-while [ $# -gt 0 ]
+# Include ChangeLog if given any explicit file names
+i=0
+while [[ $i -lt $# ]]
do
- case "$1" in
- -m|-l) shift ;;
- -*) nopts[${#nopts[*]}]="$1" ;;
- # Include ChangeLog if given any explicit file names
- *) nopts[${#nopts[*]}]="$1"; cl=ChangeLog ;;
+ i=$((i+1))
+ case "${!i}" in
+ # no-argument options
+ -A) continue ;;
+ # one-argument options
+ -?) i=$((i+1)); continue ;;
+ # one-argument options with no space
+ -*) continue ;;
+ *) cl=ChangeLog ;;
esac
- shift
done
-clog=$(hg tip --template '{desc}')
-
{
hg log --style=./hg-changelog-map -r tip:$lrev
hg cat ChangeLog
} > ChangeLog
-hg rollback
-hg commit -m "$clog" "${nopts[@]}" $cl
+hg commit "$@" $cl