Patchwork [6,of,8] revlog: do not search for delta for empty content

login
register
mail settings
Submitter Boris Feld
Date Aug. 14, 2018, 4:39 p.m.
Message ID <e7eddd3944f5a2dd8235.1534264756@FB-lair>
Download mbox | patch
Permalink /patch/33725/
State Accepted
Headers show

Comments

Boris Feld - Aug. 14, 2018, 4:39 p.m.
# HG changeset patch
# User Boris Feld <boris.feld@octobus.net>
# Date 1532695051 -7200
#      Fri Jul 27 14:37:31 2018 +0200
# Node ID e7eddd3944f5a2dd8235f372c175b3688a17ef0c
# Parent  130de8bf42ff740783b99c4996c0f774e27e67cf
# EXP-Topic sparse-snapshot
# Available At https://bitbucket.org/octobus/mercurial-devel/
#              hg pull https://bitbucket.org/octobus/mercurial-devel/ -r e7eddd3944f5
revlog: do not search for delta for empty content

We won't find any useful base to store an empty text. So we should not even try
to.

Patch

diff --git a/mercurial/revlog.py b/mercurial/revlog.py
--- a/mercurial/revlog.py
+++ b/mercurial/revlog.py
@@ -738,6 +738,9 @@  class _deltacomputer(object):
         Returns the first acceptable candidate revision, as ordered by
         _getcandidaterevs
         """
+        if not revinfo.textlen:
+            return None # empty file do not need delta
+
         cachedelta = revinfo.cachedelta
         p1 = revinfo.p1
         p2 = revinfo.p2