Show More
@@ -131,7 +131,7 b' def gettimer(ui, opts=None):' | |||||
131 |
|
131 | |||
132 | # enforce an idle period before execution to counteract power management |
|
132 | # enforce an idle period before execution to counteract power management | |
133 | # experimental config: perf.presleep |
|
133 | # experimental config: perf.presleep | |
134 |
time.sleep(ui |
|
134 | time.sleep(getint(ui, "perf", "presleep", 1)) | |
135 |
|
135 | |||
136 | if opts is None: |
|
136 | if opts is None: | |
137 | opts = {} |
|
137 | opts = {} | |
@@ -222,6 +222,18 b' def _timer(fm, func, title=None):' | |||||
222 |
|
222 | |||
223 | # utilities for historical portability |
|
223 | # utilities for historical portability | |
224 |
|
224 | |||
|
225 | def getint(ui, section, name, default): | |||
|
226 | # for "historical portability": | |||
|
227 | # ui.configint has been available since 1.9 (or fa2b596db182) | |||
|
228 | v = ui.config(section, name, None) | |||
|
229 | if v is None: | |||
|
230 | return default | |||
|
231 | try: | |||
|
232 | return int(v) | |||
|
233 | except ValueError: | |||
|
234 | raise error.ConfigError(("%s.%s is not an integer ('%s')") | |||
|
235 | % (section, name, v)) | |||
|
236 | ||||
225 | def safeattrsetter(obj, name, ignoremissing=False): |
|
237 | def safeattrsetter(obj, name, ignoremissing=False): | |
226 | """Ensure that 'obj' has 'name' attribute before subsequent setattr |
|
238 | """Ensure that 'obj' has 'name' attribute before subsequent setattr | |
227 |
|
239 | |||
@@ -569,7 +581,7 b' def perfparents(ui, repo, **opts):' | |||||
569 | timer, fm = gettimer(ui, opts) |
|
581 | timer, fm = gettimer(ui, opts) | |
570 | # control the number of commits perfparents iterates over |
|
582 | # control the number of commits perfparents iterates over | |
571 | # experimental config: perf.parentscount |
|
583 | # experimental config: perf.parentscount | |
572 |
count = ui |
|
584 | count = getint(ui, "perf", "parentscount", 1000) | |
573 | if len(repo.changelog) < count: |
|
585 | if len(repo.changelog) < count: | |
574 | raise error.Abort("repo needs %d commits for this test" % count) |
|
586 | raise error.Abort("repo needs %d commits for this test" % count) | |
575 | repo = repo.unfiltered() |
|
587 | repo = repo.unfiltered() |
@@ -14,6 +14,8 b' perfpypats = [' | |||||
14 | "use getbranchmapsubsettable() for early Mercurial"), |
|
14 | "use getbranchmapsubsettable() for early Mercurial"), | |
15 | (r'\.(vfs|svfs|opener|sopener)', |
|
15 | (r'\.(vfs|svfs|opener|sopener)', | |
16 | "use getvfs()/getsvfs() for early Mercurial"), |
|
16 | "use getvfs()/getsvfs() for early Mercurial"), | |
|
17 | (r'ui\.configint', | |||
|
18 | "use getint() instead of ui.configint() for early Mercurial"), | |||
17 | ], |
|
19 | ], | |
18 | # warnings |
|
20 | # warnings | |
19 | [ |
|
21 | [ |
General Comments 0
You need to be logged in to leave comments.
Login now