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

yuja (Yuya Nishihara) phabricator at mercurial-scm.org
Wed Apr 11 10:34:51 EDT 2018


yuja added a comment.


  It's just a few-line patch after removal of the current worddiff, and can be
  simplified further.
  
  Anyway, I can clean up later.
  
    diff --git a/mercurial/patch.py b/mercurial/patch.py
    --- a/mercurial/patch.py
    +++ b/mercurial/patch.py
    @@ -2490,10 +2490,8 @@ def difflabel(func, *args, **kw):
                         ('+', 'diff.inserted')]
         head = False
         for chunk in func(*args, **kw):
    -        lines = chunk.split('\n')
    -        for i, line in enumerate(lines):
    -            if i != 0:
    -                yield ('\n', '')
    +        for rawline in mdiff.splitnewlines(chunk):
    +            line = rawline.rstrip('\n')
                 if head:
                     if line.startswith('@'):
                         head = False
    @@ -2526,6 +2524,8 @@ def difflabel(func, *args, **kw):
                     yield (line, '')
                 if line != stripline:
                     yield (line[len(stripline):], 'diff.trailingwhitespace')
    +            if rawline != line:
    +                yield (rawline[len(line):], '')
     
     def diffui(*args, **kw):
         '''like diff(), but yields 2-tuples of (output, label) for ui.write()'''

REPOSITORY
  rHG Mercurial

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

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


More information about the Mercurial-devel mailing list