hgmerge
changeset 831 232d0616a80a
parent 830 ca080d28d0af
child 836 1fe3b14c7044
equal deleted inserted replaced
830:ca080d28d0af 831:232d0616a80a
    55 fi
    55 fi
    56 
    56 
    57 HGTMP=""
    57 HGTMP=""
    58 cleanup_exit() {
    58 cleanup_exit() {
    59     rm -rf "$HGTMP"
    59     rm -rf "$HGTMP"
    60     exit $1
       
    61 }
    60 }
    62 
    61 
    63 # attempt to manually merge with diff and patch
    62 # attempt to manually merge with diff and patch
    64 if type diff > /dev/null 2>&1 && type patch > /dev/null 2>&1; then
    63 if type diff > /dev/null 2>&1 && type patch > /dev/null 2>&1; then
    65     # Remove temporary files even if we get interrupted
    64     # Remove temporary files even if we get interrupted
    66     trap "cleanup_exit 1" TERM KILL INT QUIT ABRT
    65     trap "cleanup_exit" 0 # normal exit
       
    66     trap "exit 1" 1 2 3 6 15 # HUP INT QUIT ABRT TERM
    67 
    67 
    68     HGTMP="${TMPDIR-/tmp}/hgmerge.$RANDOM.$RANDOM.$RANDOM.$$"
    68     HGTMP="${TMPDIR-/tmp}/hgmerge.$RANDOM.$RANDOM.$RANDOM.$$"
    69     (umask 077 && mkdir "$HGTMP") || {
    69     (umask 077 && mkdir "$HGTMP") || {
    70 	echo "Could not create temporary directory! Exiting." 1>&2
    70 	echo "Could not create temporary directory! Exiting." 1>&2
    71 	exit 1
    71 	exit 1
    72     }
    72     }
    73 
    73 
    74     diff -u "$BASE" "$OTHER" > "$HGTMP/diff"
    74     diff -u "$BASE" "$OTHER" > "$HGTMP/diff"
    75     if patch "$LOCAL" < "$HGTMP/diff"; then
    75     if patch "$LOCAL" < "$HGTMP/diff"; then
    76 	cleanup_exit 0
    76 	exit 0
    77     else
    77     else
    78 	# If rejects are empty after using the editor, merge was ok
    78 	# If rejects are empty after using the editor, merge was ok
    79 	$EDITOR "$LOCAL" "$LOCAL.rej" && test -s "$LOCAL.rej" || cleanup_exit 0
    79 	$EDITOR "$LOCAL" "$LOCAL.rej" && test -s "$LOCAL.rej" || exit 0
    80     fi
    80     fi
    81     cleanup_exit 1
    81     exit 1
    82 fi
    82 fi
    83 
    83 
    84 echo "hgmerge: unable to find merge, tkdiff, kdiff3, or diff+patch!"
    84 echo "hgmerge: unable to find merge, tkdiff, kdiff3, or diff+patch!"
    85 exit 1
    85 exit 1