view hgeditor @ 13802:49b5a1aaf726

bugzilla: add modified XMLRPC mode that uses email to send bug comments. If Bugzilla has its email interface configured, an email can be used to update bugs. If the From: address in the email matches a valid user email, Bugzillas make the update as that user. So comments attached to a bug appear under the name of the user making the change, and the user does not receive email about the change, exactly as if they had made the change via the web interface. So add a modified XMLRPC mode that uses email to modify bugs. The format of the mails is documented in the Bugzilla email_in.pl specification. Briefly, initial non-blank lines in the message body starting '@<field> = <value> modify bug fields. A blank line signals the end of the command lines, and the rest of the message is used as bug comment. Invoke the same Mercurial user to Bugzilla user email mapping currently used in the MySQL mode. All other processing - checking the bug numbers, checking user ids, etc. continues to be done via XMLRPC.
author Jim Hague <jim.hague@acm.org>
date Wed, 30 Mar 2011 09:49:45 +0100
parents 2b440bb8a66b
children 1aee2ab0f902
line wrap: on
line source

#!/bin/sh
#
# This is an example of using HGEDITOR to create of diff to review the
# changes while commiting.

# If you want to pass your favourite editor some other parameters
# only for Mercurial, modify this:
case "${EDITOR}" in
    "")
        EDITOR="vi"
        ;;
    emacs)
        EDITOR="$EDITOR -nw"
        ;;
    gvim|vim)
        EDITOR="$EDITOR -f -o"
        ;;
esac


HGTMP=""
cleanup_exit() {
    rm -rf "$HGTMP"
}

# Remove temporary files even if we get interrupted
trap "cleanup_exit" 0 # normal exit
trap "exit 255" HUP INT QUIT ABRT TERM

HGTMP=$(mktemp -d ${TMPDIR-/tmp}/hgeditor.XXXXXX)
[ x$HGTMP != x -a -d $HGTMP ] || {
  echo "Could not create temporary directory! Exiting." 1>&2
  exit 1
}

(
    grep '^HG: changed' "$1" | cut -b 13- | while read changed; do
        "$HG" diff "$changed" >> "$HGTMP/diff"
    done
)

cat "$1" > "$HGTMP/msg"

MD5=$(which md5sum 2>/dev/null) || \
    MD5=$(which md5 2>/dev/null)
[ -x "${MD5}" ] && CHECKSUM=`${MD5} "$HGTMP/msg"`
if [ -s "$HGTMP/diff" ]; then
    $EDITOR "$HGTMP/msg" "$HGTMP/diff" || exit $?
else
    $EDITOR "$HGTMP/msg" || exit $?
fi
[ -x "${MD5}" ] && (echo "$CHECKSUM" | ${MD5} -c >/dev/null 2>&1 && exit 13)

mv "$HGTMP/msg" "$1"

exit $?