comparison mercurial/mdiff.py @ 4107:226df1808f16

merge with crew-stable
author Thomas Arendsen Hein <thomas@intevation.de>
date Tue, 20 Feb 2007 20:55:23 +0100
parents abaee83ce0a6 544838cc1158
children 99c853a1408c
comparison
equal deleted inserted replaced
4101:e2ed92f4c0f7 4107:226df1808f16
3 # Copyright 2005, 2006 Matt Mackall <mpm@selenic.com> 3 # Copyright 2005, 2006 Matt Mackall <mpm@selenic.com>
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 import bdiff, mpatch, re, struct, util 8 import bdiff, mpatch, re, struct, util, md5
9 9
10 def splitnewlines(text): 10 def splitnewlines(text):
11 '''like str.splitlines, but only split on newlines.''' 11 '''like str.splitlines, but only split on newlines.'''
12 lines = [l + '\n' for l in text.split('\n')] 12 lines = [l + '\n' for l in text.split('\n')]
13 if lines: 13 if lines:
55 55
56 if not a and not b: return "" 56 if not a and not b: return ""
57 epoch = util.datestr((0, 0)) 57 epoch = util.datestr((0, 0))
58 58
59 if not opts.text and (util.binary(a) or util.binary(b)): 59 if not opts.text and (util.binary(a) or util.binary(b)):
60 def h(v):
61 # md5 is used instead of sha1 because md5 is supposedly faster
62 return md5.new(v).digest()
63 if a and b and len(a) == len(b) and h(a) == h(b):
64 return ""
60 l = ['Binary file %s has changed\n' % fn] 65 l = ['Binary file %s has changed\n' % fn]
61 elif not a: 66 elif not a:
62 b = splitnewlines(b) 67 b = splitnewlines(b)
63 if a is None: 68 if a is None:
64 l1 = '--- /dev/null%s' % datetag(epoch) 69 l1 = '--- /dev/null%s' % datetag(epoch)