# HG changeset patch # User Martin Geisler # Date 2008-08-09 00:10:22 # Node ID 13fe85fe396bbabcef5a69d172c92325fd194234 # Parent 974f5263f5466c18f0342fe7de2a807fccb61698 mdiff: compare content of binary files directly A plain Python string comparison stops when the first mismatch is found, whereas the call to md5 would need to compute the hash over the entire string and only then do the comparison. diff --git a/mercurial/mdiff.py b/mercurial/mdiff.py --- a/mercurial/mdiff.py +++ b/mercurial/mdiff.py @@ -78,10 +78,7 @@ def unidiff(a, ad, b, bd, fn1, fn2, r=No epoch = util.datestr((0, 0)) if not opts.text and (util.binary(a) or util.binary(b)): - def h(v): - # md5 is used instead of sha1 because md5 is supposedly faster - return util.md5(v).digest() - if a and b and len(a) == len(b) and h(a) == h(b): + if a and b and len(a) == len(b) and a == b: return "" l = ['Binary file %s has changed\n' % fn1] elif not a: