diff --git a/mercurial/patch.py b/mercurial/patch.py --- a/mercurial/patch.py +++ b/mercurial/patch.py @@ -2499,9 +2499,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 @@ -2540,6 +2539,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