diff mercurial/revlog.py @ 5369:7530334bf301

revlog: generate trivial deltas against null revision To avoid extra memory usage and performance issues with large files, generate a trivial delta header for deltas against the null revision rather than calling the usual delta generator. We append the delta header to meta rather than prepending it to data to avoid a large allocate and copy.
author Matt Mackall <mpm@selenic.com>
date Wed, 03 Oct 2007 17:17:27 -0500
parents f87685355c9c
children 61462e7d62ed
line wrap: on
line diff
--- a/mercurial/revlog.py
+++ b/mercurial/revlog.py
@@ -1087,9 +1087,13 @@ class revlog(object):
             if infocollect is not None:
                 infocollect(nb)
 
-            d = self.revdiff(a, b)
             p = self.parents(nb)
             meta = nb + p[0] + p[1] + lookup(nb)
+            if a == -1:
+                d = self.revision(nb)
+                meta += mdiff.trivialdiffheader(len(d))
+            else:
+                d = self.revdiff(a, b)
             yield changegroup.genchunk("%s%s" % (meta, d))
 
         yield changegroup.closechunk()