Mercurial > hg-stable
changeset 5367: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 | ff32b2725651 |
children | 61462e7d62ed |
files | mercurial/mdiff.py mercurial/revlog.py |
diffstat | 2 files changed, 8 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- a/mercurial/mdiff.py Wed Oct 03 16:50:32 2007 -0500 +++ b/mercurial/mdiff.py Wed Oct 03 17:17:27 2007 -0500 @@ -245,6 +245,9 @@ def get_matching_blocks(a, b): 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) + patches = mpatch.patches patchedsize = mpatch.patchedsize textdiff = bdiff.bdiff
--- a/mercurial/revlog.py Wed Oct 03 16:50:32 2007 -0500 +++ b/mercurial/revlog.py Wed Oct 03 17:17:27 2007 -0500 @@ -1087,9 +1087,13 @@ 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()