mercurial/diffhelpers.py
changeset 37573 49b82cdb5983
parent 37572 c6b8d614690a
child 37574 a1bcc7ff0eac
equal deleted inserted replaced
37572:c6b8d614690a 37573:49b82cdb5983
     4 #
     4 #
     5 # This software may be used and distributed according to the terms of the
     5 # This software may be used and distributed according to the terms of the
     6 # GNU General Public License version 2 or any later version.
     6 # GNU General Public License version 2 or any later version.
     7 
     7 
     8 from __future__ import absolute_import
     8 from __future__ import absolute_import
       
     9 
       
    10 from .i18n import _
       
    11 
       
    12 from . import (
       
    13     error,
       
    14 )
     9 
    15 
    10 def addlines(fp, hunk, lena, lenb, a, b):
    16 def addlines(fp, hunk, lena, lenb, a, b):
    11     """Read lines from fp into the hunk
    17     """Read lines from fp into the hunk
    12 
    18 
    13     The hunk is parsed into two arrays, a and b. a gets the old state of
    19     The hunk is parsed into two arrays, a and b. a gets the old state of
    20         num = max(todoa, todob)
    26         num = max(todoa, todob)
    21         if num == 0:
    27         if num == 0:
    22             break
    28             break
    23         for i in xrange(num):
    29         for i in xrange(num):
    24             s = fp.readline()
    30             s = fp.readline()
       
    31             if not s:
       
    32                 raise error.ParseError(_('incomplete hunk'))
    25             if s == "\\ No newline at end of file\n":
    33             if s == "\\ No newline at end of file\n":
    26                 fixnewline(hunk, a, b)
    34                 fixnewline(hunk, a, b)
    27                 continue
    35                 continue
    28             if s == "\n":
    36             if s == "\n":
    29                 # Some patches may be missing the control char
    37                 # Some patches may be missing the control char