hgmerge: add and use ask_if_merged function
authorRadoslaw Szkodzinski <astralstorm@gorzow.mm.pl>
Tue, 21 Feb 2006 15:48:12 -0600
changeset 1771 e22bbca2e82b
parent 1770 4eea6a747c27
child 1772 b1a7fd503a29
hgmerge: add and use ask_if_merged function This patch, unlike the earlier ones, doesn't use unportable select builtin.
hgmerge
--- a/hgmerge	Tue Feb 21 15:48:09 2006 -0600
+++ b/hgmerge	Tue Feb 21 15:48:12 2006 -0600
@@ -70,6 +70,18 @@
     exit 1
 }
 
+# Ask if the merge was successful
+ask_if_merged() {
+    while 1; do
+        echo "$LOCAL seems unchanged. Was the merge successful? [y/n]"
+        read answer
+        case answer in
+            y*|Y*) success;;
+            n*|N*) failure;;
+        esac
+    done
+}
+
 # Clean up when interrupted
 trap "failure" 1 2 3 6 15 # HUP INT QUIT ABRT TERM
 
@@ -98,16 +110,7 @@
     # filemerge prefers the right by default
     $FILEMERGE -left "$OTHER" -right "$LOCAL" -ancestor "$BASE" -merge "$LOCAL"
     [ $? -ne 0 ] && echo "FileMerge failed to launch" && failure
-    if test "$LOCAL" -nt "$CHGTEST"
-    then
-        success
-    else
-        echo "$LOCAL seems unchanged. Was the merge successful?"
-        select answer in yes no
-        do
-            test "$answer" == "yes" && success || failure
-        done
-    fi
+    test "$LOCAL" -nt "$CHGTEST" && success || ask_if_merged
     failure
 fi