changeset 350:b4e0e20646bb

Merge with TAH -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Merge with TAH manifest hash: ec82cc2d7b7357fd7db4917e09d7d6865482de58 -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.0 (GNU/Linux) iD8DBQFCr+f1ywK+sNU5EO8RAuPtAJ0WilDBo3iG4S/dmIabhzYW987TtgCgkjkM 8OmatsrjG01iJAhkKJj+XnQ= =mOLr -----END PGP SIGNATURE-----
author mpm@selenic.com
date Wed, 15 Jun 2005 00:33:57 -0800
parents f69a5d2d4fe1 (current diff) b2293093b89e (diff)
children 9525208e1c1d
files contrib/hgit hgeditor mercurial/commands.py mercurial/hg.py mercurial/hgweb.py mercurial/ui.py tests/README tests/run-tests tests/test-basic tests/test-basic.out tests/test-help tests/test-help.out tests/test-pull tests/test-pull.out tests/test-simple-update tests/test-simple-update.out tests/test-undo tests/test-undo.out tests/test-up-local-change tests/test-up-local-change.out
diffstat 2 files changed, 39 insertions(+), 18 deletions(-) [+]
line wrap: on
line diff
--- a/hgeditor	Wed Jun 15 00:27:20 2005 -0800
+++ b/hgeditor	Wed Jun 15 00:33:57 2005 -0800
@@ -3,19 +3,40 @@
 # This is an example of using HGEDITOR to automate the signing of
 # commits and so on.
 
-MANIFEST=`grep '^HG: manifest hash' $1 | cut -b 19-`
-if grep -q "^HG: merge resolve" $1 ; then
+T1=""; T2=""
+cleanup_exit() {
+    rm -f "$T1" "$T2"
+    exit $1
+}
+
+case "${EDITOR:=vi}" in
+    emacs)
+        EDITOR="$EDITOR -nw"
+        ;;
+    gvim|vim)
+        EDITOR="$EDITOR -f -o"
+        ;;
+esac
+
+if grep -q "^HG: merge resolve" "$1" ; then
     # we don't sign merges
-    $EDITOR $1
+    exec $EDITOR "$1"
 else
-    T=`mktemp`
-    CHANGED=`grep '^HG: changed' $1 | cut -b 13-`
-    # show a diff so writing commit comments is easier
-    hg diff $CHANGED >> $T
-    echo -e "\n\nmanifest hash: $MANIFEST" > $1
-    emacs -nw $T $1 
-    head -1 $1 > $T
-    echo >> $T
-    gpg -a -u $HGUSER -o - --clearsign $1 >> $T
-    mv $T $1
+    T1=`mktemp`; T2=`mktemp`
+    MANIFEST=`grep '^HG: manifest hash' "$1" | cut -b 19-`
+
+    echo -e "\n\nmanifest hash: $MANIFEST" >> "$T1"
+    grep -vE '^(HG: manifest hash .*)?$' "$1" >> "$T1"
+    hg diff >> "$T2"
+
+    CHECKSUM=`md5sum "$T1"`
+    $EDITOR "$T1" "$T2" || cleanup_exit $?
+    echo "$CHECKSUM" | md5sum -c 2>/dev/null && cleanup_exit 0
+    {
+        head -1 "$T1"
+        echo
+        grep -v "^HG:" "$T1" | gpg -a -u "${HGUSER:-$EMAIL}" --clearsign
+    } > "$T2" && mv "$T2" "$1"
+    cleanup_exit $?
 fi
+
--- a/mercurial/commands.py	Wed Jun 15 00:27:20 2005 -0800
+++ b/mercurial/commands.py	Wed Jun 15 00:33:57 2005 -0800
@@ -81,8 +81,8 @@
         changerev = filelog.linkrev(filenode)
         changenode = changenode or changelog.node(changerev)
     else:
+        log = changelog
         changerev = rev
-        log = changelog
         if changenode is None:
             changenode = changelog.node(changerev)
         elif not changerev:
@@ -94,7 +94,6 @@
         return
 
     changes = changelog.read(changenode)
-    description = changes[4].strip().splitlines()
 
     parents = [(log.rev(parent), hg.hex(parent))
                for parent in log.parents(node)
@@ -117,13 +116,14 @@
     ui.status("date:        %s\n" % time.asctime(
         time.localtime(float(changes[2].split(' ')[0]))))
     ui.note("files:       %s\n" % " ".join(changes[3]))
+    description = changes[4].strip()
     if description:
         if ui.verbose:
             ui.status("description:\n")
-            ui.status(changes[4].strip())
-            ui.status("\n")
+            ui.status(description)
+            ui.status("\n\n")
         else:
-            ui.status("summary:     %s\n" % description[0])
+            ui.status("summary:     %s\n" % description.splitlines()[0])
     ui.status("\n")
 
 def help(ui, cmd=None):