diff mercurial/mdiff.py @ 27711:7a678a12a5cf

mdiff: don't emit a diff header for empty trivial deltas An empty trivial delta, coded as (0, 0, 0) makes the delta application do nothing, but still takes 12 bytes, while skipping it altogether works as much, without taking any space at all.
author Mike Hommey <mh@glandium.org>
date Mon, 11 Jan 2016 22:00:07 -0500
parents 0d7635dca691
children 30789efb1e5e
line wrap: on
line diff
--- a/mercurial/mdiff.py	Mon Jan 11 09:49:48 2016 -0800
+++ b/mercurial/mdiff.py	Mon Jan 11 22:00:07 2016 -0500
@@ -376,7 +376,7 @@
     return [(d[0], d[2], d[1] - d[0]) for d in bdiff.blocks(a, b)]
 
 def trivialdiffheader(length):
-    return struct.pack(">lll", 0, 0, length)
+    return struct.pack(">lll", 0, 0, length) if length else ''
 
 def replacediffheader(oldlen, newlen):
     return struct.pack(">lll", 0, oldlen, newlen)