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

Pierre-Yves David pierre-yves.david at ens-lyon.org
Wed Dec 2 02:37:24 CST 2015


# HG changeset patch
# User Pierre-Yves David <pierre-yves.david at 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.

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)


More information about the Mercurial-devel mailing list