mercurial/mdiff.py
changeset 6470 ac0bcd951c2c
parent 6467 65029a3aafc2
child 6871 13fe85fe396b
equal deleted inserted replaced
6469:fb502719c75c 6470:ac0bcd951c2c
     4 #
     4 #
     5 # This software may be used and distributed according to the terms
     5 # This software may be used and distributed according to the terms
     6 # of the GNU General Public License, incorporated herein by reference.
     6 # of the GNU General Public License, incorporated herein by reference.
     7 
     7 
     8 from i18n import _
     8 from i18n import _
     9 import bdiff, mpatch, re, struct, util, md5
     9 import bdiff, mpatch, re, struct, util
    10 
    10 
    11 def splitnewlines(text):
    11 def splitnewlines(text):
    12     '''like str.splitlines, but only split on newlines.'''
    12     '''like str.splitlines, but only split on newlines.'''
    13     lines = [l + '\n' for l in text.split('\n')]
    13     lines = [l + '\n' for l in text.split('\n')]
    14     if lines:
    14     if lines:
    78     epoch = util.datestr((0, 0))
    78     epoch = util.datestr((0, 0))
    79 
    79 
    80     if not opts.text and (util.binary(a) or util.binary(b)):
    80     if not opts.text and (util.binary(a) or util.binary(b)):
    81         def h(v):
    81         def h(v):
    82             # md5 is used instead of sha1 because md5 is supposedly faster
    82             # md5 is used instead of sha1 because md5 is supposedly faster
    83             return md5.new(v).digest()
    83             return util.md5(v).digest()
    84         if a and b and len(a) == len(b) and h(a) == h(b):
    84         if a and b and len(a) == len(b) and h(a) == h(b):
    85             return ""
    85             return ""
    86         l = ['Binary file %s has changed\n' % fn1]
    86         l = ['Binary file %s has changed\n' % fn1]
    87     elif not a:
    87     elif not a:
    88         b = splitnewlines(b)
    88         b = splitnewlines(b)