crecord: properly handle files with No newline at eof (issue5268) stable
authortimeless <timeless@mozdev.org>
Fri, 02 Sep 2016 20:15:37 +0000
branchstable
changeset 29862 e7766022a61a
parent 29861 2f6d5c60f6fc
child 29937 2c302c654451
child 30009 7fa011555046
crecord: properly handle files with No newline at eof (issue5268) Yes, this bug was a single character with the wrong case...
mercurial/crecord.py
tests/test-commit-interactive-curses.t
--- a/mercurial/crecord.py	Fri Sep 02 15:20:59 2016 +0100
+++ b/mercurial/crecord.py	Fri Sep 02 20:15:37 2016 +0000
@@ -387,7 +387,7 @@
 
         contextlen = (len(self.before) + len(self.after) +
                       removedconvertedtocontext)
-        if self.after and self.after[-1] == '\\ no newline at end of file\n':
+        if self.after and self.after[-1] == '\\ No newline at end of file\n':
             contextlen -= 1
         fromlen = contextlen + self.removed
         tolen = contextlen + self.added
--- a/tests/test-commit-interactive-curses.t	Fri Sep 02 15:20:59 2016 +0100
+++ b/tests/test-commit-interactive-curses.t	Fri Sep 02 20:15:37 2016 +0000
@@ -9,6 +9,21 @@
   > crecordtest = testModeCommands
   > EOF
 
+Record with noeol at eof (issue5268)
+  $ hg init noeol
+  $ cd noeol
+  $ printf '0' > a
+  $ printf '0\n' > b
+  $ hg ci -Aqm initial
+  $ printf '1\n0' > a
+  $ printf '1\n0\n' > b
+  $ cat <<EOF >testModeCommands
+  > c
+  > EOF
+  $ HGEDITOR="\"sh\" \"`pwd`/editor.sh\"" hg commit  -i -m "add hunks" -d "0 0"
+  $ cd ..
+
+Normal repo
   $ hg init a
   $ cd a