Patchwork D3210: patch: move yielding "\n" to the end of loop

login
register
mail settings
Submitter phabricator
Date April 16, 2018, 11:12 p.m.
Message ID <3850bffea5584b895c088b1991e8cbef@localhost.localdomain>
Download mbox | patch
Permalink /patch/31123/
State Not Applicable
Headers show

Comments

phabricator - April 16, 2018, 11:12 p.m.
This revision was automatically updated to reflect the committed changes.
Closed by commit rHG8d730f96e792: patch: move yielding &quot;\n&quot; to the end of loop (authored by quark, committed by ).

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D3210?vs=7922&id=8333

REVISION DETAIL
  https://phab.mercurial-scm.org/D3210

AFFECTED FILES
  mercurial/patch.py

CHANGE DETAILS




To: quark, #hg-reviewers, durin42
Cc: yuja, mercurial-devel

Patch

diff --git a/mercurial/patch.py b/mercurial/patch.py
--- a/mercurial/patch.py
+++ b/mercurial/patch.py
@@ -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