diff --git a/hgeditor b/hgeditor
index d6723636c1726e8b872a5dc8401944aab215e705_aGdlZGl0b3I=..104d2aee3b442f2ee4b2e9d059bc1d8981526e81_aGdlZGl0b3I= 100755
--- a/hgeditor
+++ b/hgeditor
@@ -27,4 +27,5 @@
     # Remove temporary files even if we get interrupted
     trap "cleanup_exit 255" TERM KILL INT QUIT ABRT
     T1=`mktemp`; T2=`mktemp`
+    MANIFEST=`grep '^HG: manifest hash' "$1" | cut -b 19-`
 
@@ -30,9 +31,6 @@
 
-    # Add manifest hash in order to sign whole repository state.
-    # Remove HG: prefix, as we want that to be stored.
-    grep '^HG: manifest hash' "$1" | cut -b 5- >> "$T1"
-    # Add all other state information
-    grep -v '^HG: manifest hash' "$1" >> "$T1"
+    echo -e "\n\nmanifest hash: $MANIFEST" >> "$T1"
+    grep -vE '^(HG: manifest hash .*)?$' "$1" >> "$T1"
     (
         cd "`hg root`"
         grep '^HG: changed' "$1" | cut -b 13- | while read changed; do