Patchwork [1,of,2,mainline] scmutil: extract general delta config handling in a function

login
register
mail settings
Submitter Pierre-Yves David
Date Nov. 6, 2015, 3:47 p.m.
Message ID <69c64edb25dd96a23564.1446824835@marginatus.alto.octopoid.net>
Download mbox | patch
Permalink /patch/11301/
State Superseded
Headers show

Comments

Pierre-Yves David - Nov. 6, 2015, 3:47 p.m.
# HG changeset patch
# User Pierre-Yves David <pierre-yves.david@fb.com>
# Date 1446483154 0
#      Mon Nov 02 16:52:34 2015 +0000
# Node ID 69c64edb25dd96a23564db5b23b8b432b343ec88
# Parent  9850e1f19c056631f30cff7ed1667aebc7b468ae
# EXP-Topic generaldelta
# Available At http://hg.netv6.net/marmoute-wip/mercurial/
#              hg pull http://hg.netv6.net/marmoute-wip/mercurial/ -r 69c64edb25dd
scmutil: extract general delta config handling in a function

This is currently a single boolean, but we want to add a "accept" value that
will trigger general delta format without being aggressive about re-computation
of delta for incoming bundle.

We extract the logic in a function while it is simple.

Patch

diff --git a/mercurial/localrepo.py b/mercurial/localrepo.py
--- a/mercurial/localrepo.py
+++ b/mercurial/localrepo.py
@@ -256,12 +256,11 @@  class localrepository(object):
                     self.vfs.append(
                         "00changelog.i",
                         '\0\0\0\2' # represents revlogv2
                         ' dummy changelog to prevent using the old repo layout'
                     )
-                # experimental config: format.generaldelta
-                if self.ui.configbool('format', 'generaldelta', False):
+                if scmutil.gdconfig(self.ui):
                     self.requirements.add("generaldelta")
                 if self.ui.configbool('experimental', 'treemanifest', False):
                     self.requirements.add("treemanifest")
                 if self.ui.configbool('experimental', 'manifestv2', False):
                     self.requirements.add("manifestv2")
diff --git a/mercurial/scmutil.py b/mercurial/scmutil.py
--- a/mercurial/scmutil.py
+++ b/mercurial/scmutil.py
@@ -1168,5 +1168,13 @@  def wlocksub(repo, cmd, *args, **kwargs)
     This can only be called while the wlock is held. This takes all the
     arguments that ui.system does, and returns the exit code of the
     subprocess."""
     return _locksub(repo, repo.currentwlock(), 'HG_WLOCK_LOCKER', cmd, *args,
                     **kwargs)
+
+def gdconfig(ui):
+    """helper function to retrieve general delta setting
+
+    The need for such function is triggered by a soon to come third possible
+    value to the config option."""
+    # experimental config: format.generaldelta
+    return ui.configbool('format', 'generaldelta', False)