mercurial/mdiff.py
changeset 4107 226df1808f16
parent 3886 abaee83ce0a6
parent 4102 544838cc1158
child 4357 99c853a1408c
--- a/mercurial/mdiff.py
+++ b/mercurial/mdiff.py
@@ -5,7 +5,7 @@
 # This software may be used and distributed according to the terms
 # of the GNU General Public License, incorporated herein by reference.
 
-import bdiff, mpatch, re, struct, util
+import bdiff, mpatch, re, struct, util, md5
 
 def splitnewlines(text):
     '''like str.splitlines, but only split on newlines.'''
@@ -57,6 +57,11 @@ def unidiff(a, ad, b, bd, fn, r=None, op
     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 md5.new(v).digest()
+        if a and b and len(a) == len(b) and h(a) == h(b):
+            return ""
         l = ['Binary file %s has changed\n' % fn]
     elif not a:
         b = splitnewlines(b)