contrib/perf.py
changeset 30149 d8a2c536dd96
parent 30148 04f2b980df3c
child 30150 c0410814002f
--- a/contrib/perf.py	Sun Oct 09 01:03:19 2016 +0900
+++ b/contrib/perf.py	Sun Oct 09 01:03:19 2016 +0900
@@ -131,7 +131,7 @@
 
     # enforce an idle period before execution to counteract power management
     # experimental config: perf.presleep
-    time.sleep(ui.configint("perf", "presleep", 1))
+    time.sleep(getint(ui, "perf", "presleep", 1))
 
     if opts is None:
         opts = {}
@@ -222,6 +222,18 @@
 
 # utilities for historical portability
 
+def getint(ui, section, name, default):
+    # for "historical portability":
+    # ui.configint has been available since 1.9 (or fa2b596db182)
+    v = ui.config(section, name, None)
+    if v is None:
+        return default
+    try:
+        return int(v)
+    except ValueError:
+        raise error.ConfigError(("%s.%s is not an integer ('%s')")
+                                % (section, name, v))
+
 def safeattrsetter(obj, name, ignoremissing=False):
     """Ensure that 'obj' has 'name' attribute before subsequent setattr
 
@@ -569,7 +581,7 @@
     timer, fm = gettimer(ui, opts)
     # control the number of commits perfparents iterates over
     # experimental config: perf.parentscount
-    count = ui.configint("perf", "parentscount", 1000)
+    count = getint(ui, "perf", "parentscount", 1000)
     if len(repo.changelog) < count:
         raise error.Abort("repo needs %d commits for this test" % count)
     repo = repo.unfiltered()