mercurial/patch.py
changeset 37730 8d730f96e792
parent 37621 5537d8f5e989
child 37731 5471348921c1
--- a/mercurial/patch.py	Mon Apr 16 09:39:40 2018 -0700
+++ b/mercurial/patch.py	Mon Mar 19 04:28:29 2018 -0700
@@ -2505,9 +2505,8 @@
         matches = {}
         if inlinecolor:
             matches = _findmatches(lines)
+        linecount = len(lines)
         for i, line in enumerate(lines):
-            if i != 0:
-                yield ('\n', '')
             if head:
                 if line.startswith('@'):
                     head = False
@@ -2546,6 +2545,8 @@
                 yield (line, '')
             if line != stripline:
                 yield (line[len(stripline):], 'diff.trailingwhitespace')
+            if i + 1 < linecount:
+                yield ('\n', '')
 
 def _findmatches(slist):
     '''Look for insertion matches to deletion and returns a dict of