contrib-perf: update the config registration
authorBoris Feld <boris.feld@octobus.net>
Fri, 13 Oct 2017 21:31:24 +0200
changeset 34749 acdc574cb8d7
parent 34748 8c1d0fe1f431
child 34750 caf6c446cbe3
contrib-perf: update the config registration There are various issue with the previous code, all hidden by the try-except clause. These are fixed now.
contrib/perf.py
--- a/contrib/perf.py	Thu Oct 12 00:20:41 2017 +0200
+++ b/contrib/perf.py	Fri Oct 13 21:31:24 2017 +0200
@@ -140,17 +140,21 @@
         return decorator
 
 try:
-    import registrar
+    import mercurial.registrar
+    import mercurial.configitems
     configtable = {}
-    configitem = registrar.configitem(configtable)
+    configitem = mercurial.registrar.configitem(configtable)
+    configitem('perf', 'presleep',
+        default=mercurial.configitems.dynamicdefault,
+    )
     configitem('perf', 'stub',
-        default=False,
+        default=mercurial.configitems.dynamicdefault,
     )
 except (ImportError, AttributeError):
     pass
 
 def getlen(ui):
-    if ui.configbool("perf", "stub"):
+    if ui.configbool("perf", "stub", False):
         return lambda x: 1
     return len
 
@@ -213,7 +217,7 @@
 
     # stub function, runs code only once instead of in a loop
     # experimental config: perf.stub
-    if ui.configbool("perf", "stub"):
+    if ui.configbool("perf", "stub", False):
         return functools.partial(stub_timer, fm), fm
     return functools.partial(_timer, fm), fm