Patchwork [2,of,3,fix-default] addrevision: handle code path not producing delta

login
register
mail settings
Submitter Pierre-Yves David
Date Dec. 2, 2015, 8:37 a.m.
Message ID <31aafeaa7ac49cbc98d3.1449045444@marginatus.alto.octopoid.net>
Download mbox | patch
Permalink /patch/11740/
State Accepted
Headers show

Comments

Pierre-Yves David - Dec. 2, 2015, 8:37 a.m.
# HG changeset patch
# User Pierre-Yves David <pierre-yves.david@fb.com>
# Date 1449015769 28800
#      Tue Dec 01 16:22:49 2015 -0800
# Node ID 31aafeaa7ac49cbc98d3b526b6ae67f98cc803d2
# Parent  ebf8b06f9dbfe03e28776032f5dc3d64db18579b
# EXP-Topic generaldelta
# Available At http://hg.netv6.net/marmoute-wip/mercurial/
#              hg pull http://hg.netv6.net/marmoute-wip/mercurial/ -r 31aafeaa7ac4
addrevision: handle code path not producing delta

We would like to be able to exit the delta generation block without a valid
delta (for a more flexible control flow). So we make sure we do not expand the
"delta" content unless we actually have a delta.

We can do it one level lower because 'delta' is initialised at None anyway. Not
adding a level to the assignment prevent a line length issue.

Patch

diff --git a/mercurial/revlog.py b/mercurial/revlog.py
--- a/mercurial/revlog.py
+++ b/mercurial/revlog.py
@@ -1457,10 +1457,11 @@  class revlog(object):
                     # give it one last try against prev.
                     if drev != prev and not self._isgooddelta(delta, textlen):
                         delta = builddelta(prev)
             else:
                 delta = builddelta(prev)
+        if delta is not None:
             dist, l, data, base, chainbase, chainlen, compresseddeltalen = delta
 
         if not self._isgooddelta(delta, textlen):
             text = buildtext()
             data = self.compress(text)