diff --git a/hgeditor b/hgeditor
index 562404de61fb4a8d32de222a59ead58b392a154a_aGdlZGl0b3I=..e1fbc1982372b66681a871e23e9c0370498f53e5_aGdlZGl0b3I= 100755
--- a/hgeditor
+++ b/hgeditor
@@ -23,5 +23,4 @@
     exec $EDITOR "$1"
 else
     T1=`mktemp`; T2=`mktemp`
-    MANIFEST=`grep '^HG: manifest hash' "$1" | cut -b 19-`
 
@@ -27,6 +26,9 @@
 
-    echo -e "\n\nmanifest hash: $MANIFEST" >> "$T1"
-    grep -vE '^(HG: manifest hash .*)?$' "$1" >> "$T1"
+    # 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"
     (
         cd "`hg root`"
         grep '^HG: changed' "$1" | cut -b 13- | while read changed; do