commit: write last-message.txt with no content modifications.
authorGreg Ward <greg-hg@gerg.ca>
Fri, 27 Nov 2009 11:50:52 -0500
changeset 9949 bc3f762af82e
parent 9948 e5b44a7986d0
child 9950 af5f99d8195e
commit: write last-message.txt with no content modifications. This assumes the user will use either a sane editor (anything but Notepad) or the same editor again: even Notepad should be able to read what it previously wrote.
mercurial/localrepo.py
tests/test-rollback
--- a/mercurial/localrepo.py	Thu Nov 26 10:47:39 2009 +0200
+++ b/mercurial/localrepo.py	Fri Nov 27 11:50:52 2009 -0500
@@ -837,12 +837,10 @@
                 subrepo.writestate(self, state)
 
             # Save commit message in case this transaction gets rolled back
-            # (e.g. by a pretxncommit hook).  (Save in text mode in case a
-            # Windows user wants to edit it with Notepad.  Normalize
-            # trailing whitespace so the file always looks the same --
-            # makes testing easier.)
-            msgfile = self.opener('last-message.txt', 'w')
-            msgfile.write(cctx._text.rstrip() + '\n')
+            # (e.g. by a pretxncommit hook).  Leave the content alone on
+            # the assumption that the user will use the same editor again.
+            msgfile = self.opener('last-message.txt', 'wb')
+            msgfile.write(cctx._text)
             msgfile.close()
 
             try:
--- a/tests/test-rollback	Thu Nov 26 10:47:39 2009 +0200
+++ b/tests/test-rollback	Fri Nov 27 11:50:52 2009 -0500
@@ -22,7 +22,7 @@
 
 echo '% Test issue 1635 (commit message saved)'
 echo '.hg/last-message.txt:'
-cat .hg/last-message.txt
+cat .hg/last-message.txt ; echo
 
 echo % Test rollback of hg before issue 902 was fixed
 hg commit -m "test3"
@@ -35,7 +35,7 @@
 echo a >> a
 hg --config hooks.pretxncommit=/bin/false commit -m"precious commit message"
 echo '.hg/last-message.txt:'
-cat .hg/last-message.txt
+cat .hg/last-message.txt ; echo
 
 echo '% same thing, but run $EDITOR'
 cat > $HGTMP/editor <<'__EOF__'