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

login
register
mail settings
Submitter Pierre-Yves David
Date Nov. 11, 2015, 1:55 a.m.
Message ID <a21c430969a1159c5903.1447206904@marginatus.alto.octopoid.net>
Download mbox | patch
Permalink /patch/11362/
State Accepted
Headers show

Comments

Pierre-Yves David - Nov. 11, 2015, 1:55 a.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 a21c430969a1159c590394b4f77301e2675f191a
# Parent  8b2fbe3f59b1b969878691cb472369ad0067f165
# EXP-Topic generaldelta
# Available At http://hg.netv6.net/marmoute-wip/mercurial/
#              hg pull http://hg.netv6.net/marmoute-wip/mercurial/ -r a21c430969a1
scmutil: extract general delta config handling in a function

General delta is currently controlled by a single option, we will introduce a
new one in the next changeset.

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.gdinitconfig(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 gdinitconfig(ui):
+    """helper function to know if a repo should be created as general delta
+
+    This currently depends on a single config option but this will get more
+    complicated soon."""
+    # experimental config: format.generaldelta
+    return ui.configbool('format', 'generaldelta', False)