[PATCH 2 of 2 evolve-ext] configitems: move the default values to the registrar decorator

Matt Harbison mharbison72 at gmail.com
Fri Jan 4 00:13:57 EST 2019


# HG changeset patch
# User Matt Harbison <matt_harbison at yahoo.com>
# Date 1546578644 18000
#      Fri Jan 04 00:10:44 2019 -0500
# Node ID be10354c1022e62daf9bb2d646fc7e82dbce6179
# Parent  1c6f2cc21682164dde57f581f55e2affb0c1d709
configitems: move the default values to the registrar decorator

The exthelper refactoring of configitems stopped registering dynamicdefault for
everything, which in turn causes a lot of warnings about mismatched defaults.

There are a few stragglers- I didn't fix topic-mode because I wasn't sure what
the default should be, and the alias for odiff was explicitly given a default
for compatibility.

diff --git a/hgext3rd/evolve/__init__.py b/hgext3rd/evolve/__init__.py
--- a/hgext3rd/evolve/__init__.py
+++ b/hgext3rd/evolve/__init__.py
@@ -371,13 +371,9 @@
 configtable = eh.configtable
 
 # Configuration
-eh.configitem('experimental', 'evolutioncommands')
-eh.configitem('experimental', 'evolution.allnewcommands')
-eh.configitem('experimental', 'prunestrip')
-
-# hack around because we need an actual default there
-if configtable:
-    configtable['experimental']['evolution.allnewcommands'].default = None
+eh.configitem('experimental', 'evolutioncommands', [])
+eh.configitem('experimental', 'evolution.allnewcommands', None)
+eh.configitem('experimental', 'prunestrip', False)
 
 # pre hg 4.0 compat
 
@@ -435,7 +431,7 @@
     # This must be in the same function as the option configuration above to
     # guarantee it happens after the above configuration, but before the
     # extsetup functions.
-    evolvecommands = ui.configlist('experimental', 'evolutioncommands', [])
+    evolvecommands = ui.configlist('experimental', 'evolutioncommands')
     evolveopts = ui.configlist('experimental', 'evolution')
     if evolveopts and (commandopt not in evolveopts
                        and 'all' not in evolveopts):
@@ -1252,7 +1248,7 @@
                            "backup bundle")),
     ])
 def stripwrapper(orig, ui, repo, *revs, **kwargs):
-    if (not ui.configbool('experimental', 'prunestrip', False)
+    if (not ui.configbool('experimental', 'prunestrip')
         or kwargs.get('bundle', False)):
         return orig(ui, repo, *revs, **kwargs)
 
diff --git a/hgext3rd/evolve/obsdiscovery.py b/hgext3rd/evolve/obsdiscovery.py
--- a/hgext3rd/evolve/obsdiscovery.py
+++ b/hgext3rd/evolve/obsdiscovery.py
@@ -74,11 +74,11 @@
 obsexcmsg = utility.obsexcmsg
 
 # Config
-eh.configitem('experimental', 'evolution.obsdiscovery')
-eh.configitem('experimental', 'obshashrange')
-eh.configitem('experimental', 'obshashrange.warm-cache')
-eh.configitem('experimental', 'obshashrange.max-revs')
-eh.configitem('experimental', 'obshashrange.lru-size')
+eh.configitem('experimental', 'evolution.obsdiscovery', True)
+eh.configitem('experimental', 'obshashrange', True)
+eh.configitem('experimental', 'obshashrange.warm-cache', 'auto')
+eh.configitem('experimental', 'obshashrange.max-revs', None)
+eh.configitem('experimental', 'obshashrange.lru-size', 2000)
 
 ##################################
 ###  Code performing discovery ###
@@ -775,9 +775,9 @@
     return encodelist(hashes)
 
 def _useobshashrange(repo):
-    base = repo.ui.configbool('experimental', 'obshashrange', True)
+    base = repo.ui.configbool('experimental', 'obshashrange')
     if base:
-        maxrevs = repo.ui.configint('experimental', 'obshashrange.max-revs', None)
+        maxrevs = repo.ui.configint('experimental', 'obshashrange.max-revs')
         if maxrevs is not None and maxrevs < len(repo.unfiltered()):
             base = False
     return base
@@ -945,7 +945,7 @@
     """wrapper to advertise new capability"""
     caps = orig(repo, proto)
     if (obsolete.isenabled(repo, obsolete.exchangeopt)
-        and repo.ui.configbool('experimental', 'evolution.obsdiscovery', True)):
+        and repo.ui.configbool('experimental', 'evolution.obsdiscovery')):
 
         # Compat hg 4.6+ (2f7290555c96)
         bytesresponse = False
@@ -1015,7 +1015,7 @@
 """
 
 def usediscovery(repo):
-    return repo.ui.configbool('experimental', 'evolution.obsdiscovery', True)
+    return repo.ui.configbool('experimental', 'evolution.obsdiscovery')
 
 @eh.wrapfunction(exchange, '_pushdiscoveryobsmarkers')
 def _pushdiscoveryobsmarkers(orig, pushop):
diff --git a/hgext3rd/evolve/obsexchange.py b/hgext3rd/evolve/obsexchange.py
--- a/hgext3rd/evolve/obsexchange.py
+++ b/hgext3rd/evolve/obsexchange.py
@@ -39,7 +39,7 @@
 obsexcmsg = utility.obsexcmsg
 obsexcprg = utility.obsexcprg
 
-eh.configitem('experimental', 'verbose-obsolescence-exchange')
+eh.configitem('experimental', 'verbose-obsolescence-exchange', False)
 
 _bestformat = max(obsolete.formats.keys())
 
diff --git a/hgext3rd/evolve/safeguard.py b/hgext3rd/evolve/safeguard.py
--- a/hgext3rd/evolve/safeguard.py
+++ b/hgext3rd/evolve/safeguard.py
@@ -22,7 +22,7 @@
 # hg <= 4.8
 if 'auto-publish' not in configitems.coreitems.get('experimental', {}):
 
-    eh.configitem('experimental', 'auto-publish')
+    eh.configitem('experimental', 'auto-publish', 'publish')
 
     @eh.reposetup
     def setuppublishprevention(ui, repo):
@@ -31,7 +31,7 @@
 
             def checkpush(self, pushop):
                 super(noautopublishrepo, self).checkpush(pushop)
-                behavior = self.ui.config('experimental', 'auto-publish', 'publish')
+                behavior = self.ui.config('experimental', 'auto-publish')
                 nocheck = behavior not in ('warn', 'abort')
                 if nocheck or getattr(pushop, 'publish', False):
                     return
diff --git a/hgext3rd/evolve/utility.py b/hgext3rd/evolve/utility.py
--- a/hgext3rd/evolve/utility.py
+++ b/hgext3rd/evolve/utility.py
@@ -17,8 +17,7 @@
 stacktemplate = """[{label('evolve.rev', if(topicidx, "s{topicidx}", rev))}] {desc|firstline}\n"""
 
 def obsexcmsg(ui, message, important=False):
-    verbose = ui.configbool('experimental', 'verbose-obsolescence-exchange',
-                            False)
+    verbose = ui.configbool('experimental', 'verbose-obsolescence-exchange')
     if verbose:
         message = 'OBSEXC: ' + message
     if important or verbose:
@@ -26,7 +25,7 @@
 
 def obsexcprg(ui, *args, **kwargs):
     topic = 'obsmarkers exchange'
-    if ui.configbool('experimental', 'verbose-obsolescence-exchange', False):
+    if ui.configbool('experimental', 'verbose-obsolescence-exchange'):
         topic = 'OBSEXC'
     ui.progress(topic, *args, **kwargs)
 
@@ -63,12 +62,12 @@
         warm = autocase
     else:
         # note: we should not get to the default case
-        warm = configbool('experimental', 'obshashrange.warm-cache', True)
-    if not configbool('experimental', 'obshashrange', True):
+        warm = configbool('experimental', 'obshashrange.warm-cache')
+    if not configbool('experimental', 'obshashrange'):
         return False
     if not warm:
         return False
-    maxrevs = repo.ui.configint('experimental', 'obshashrange.max-revs', None)
+    maxrevs = repo.ui.configint('experimental', 'obshashrange.max-revs')
     if maxrevs is not None and maxrevs < len(repo.unfiltered()):
         return False
     return True


More information about the Mercurial-devel mailing list