]> granicus.if.org Git - mutt/commitdiff
Make hg commit less clever
authorBrendan Cully <brendan@kublai.com>
Tue, 6 Mar 2007 23:43:21 +0000 (15:43 -0800)
committerBrendan Cully <brendan@kublai.com>
Tue, 6 Mar 2007 23:43:21 +0000 (15:43 -0800)
hg-commit

index be86a33e11a6e41ef71dc9d177415a593d0c69c5..220272bbaf6a33d106fab357e1b3f459ea4d0d01 100755 (executable)
--- a/hg-commit
+++ b/hg-commit
@@ -1,30 +1,31 @@
 #!/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