Patchwork [7,of,8] revlog: use a symbolic constant for the deltas/text ration

login
register
mail settings
Submitter Boris Feld
Date Aug. 14, 2018, 4:39 p.m.
Message ID <64d463474e20f07d434f.1534264757@FB-lair>
Download mbox | patch
Permalink /patch/33726/
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 1532780936 -7200
#      Sat Jul 28 14:28:56 2018 +0200
# Node ID 64d463474e20f07d434f7d47add49da27233aec4
# Parent  e7eddd3944f5a2dd8235f372c175b3688a17ef0c
# EXP-Topic sparse-snapshot
# Available At https://bitbucket.org/octobus/mercurial-devel/
#              hg pull https://bitbucket.org/octobus/mercurial-devel/ -r 64d463474e20
revlog: use a symbolic constant for the deltas/text ration

We are about to use it somewhere else, we should as well make it easier to
access and change.

Patch

diff --git a/mercurial/revlog.py b/mercurial/revlog.py
--- a/mercurial/revlog.py
+++ b/mercurial/revlog.py
@@ -809,6 +809,9 @@  class revlogoldindex(list):
             return (0, 0, 0, -1, -1, -1, -1, nullid)
         return list.__getitem__(self, i)
 
+# maximum <delta-chain-data>/<revision-text-length> ration
+LIMIT_DELTA2TEXT = 2
+
 class revlogoldio(object):
     def __init__(self):
         self.size = indexformatv0.size
@@ -2498,7 +2501,7 @@  class revlog(object):
         # Bad delta from cumulated payload size:
         #
         #   If the sum of delta get larger than K * target text length.
-        if (textlen * 2  < deltainfo.compresseddeltalen):
+        if (textlen * LIMIT_DELTA2TEXT  < deltainfo.compresseddeltalen):
             return False
 
         # Bad delta from chain length: