mercurial/pure/bdiff.py
changeset 31640 6d30699729dd
parent 30042 d24e03da24b5
child 31641 f2b334e6c7e0
equal deleted inserted replaced
31639:84242dce8305 31640:6d30699729dd
     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 
     9 
    10 import array
       
    11 import difflib
    10 import difflib
    12 import re
    11 import re
    13 import struct
    12 import struct
    14 
    13 
    15 from . import policy
    14 from . import policy
    54         prev = a2 + shift, b2 + shift, l2 - shift
    53         prev = a2 + shift, b2 + shift, l2 - shift
    55     r.append(prev)
    54     r.append(prev)
    56     return r
    55     return r
    57 
    56 
    58 def _tostring(c):
    57 def _tostring(c):
    59     if type(c) is array.array:
       
    60         # this copy overhead isn't ideal
       
    61         return c.tostring()
       
    62     return str(c)
    58     return str(c)
    63 
    59 
    64 def bdiff(a, b):
    60 def bdiff(a, b):
    65     a = _tostring(a).splitlines(True)
    61     a = _tostring(a).splitlines(True)
    66     b = _tostring(b).splitlines(True)
    62     b = _tostring(b).splitlines(True)