git binary patches: use hashes to detect identical files
authorAlexis S. L. Carvalho <alexis@cecm.usp.br>
Sat, 17 Feb 2007 09:54:59 -0200
changeset 4105 ed46895aa38c
parent 4104 0934fef871f3
child 4106 797dbdd4d7e1
git binary patches: use hashes to detect identical files
mercurial/patch.py
--- a/mercurial/patch.py	Sat Feb 17 09:54:58 2007 -0200
+++ b/mercurial/patch.py	Sat Feb 17 09:54:59 2007 -0200
@@ -412,12 +412,13 @@
             yield text[i:i+csize]
             i += csize
 
-    if to == tn:
+    tohash = gitindex(to)
+    tnhash = gitindex(tn)
+    if tohash == tnhash:
         return
     # TODO: deltas
-    l = len(tn)
     fp.write('index %s..%s\nGIT binary patch\nliteral %s\n' %
-             (gitindex(to), gitindex(tn), len(tn)))
+             (tohash, tnhash, len(tn)))
 
     tn = ''.join([fmtline(l) for l in chunk(zlib.compress(tn))])
     fp.write(tn)