comparison contrib/perf.py @ 42063:912d82daeda3

perf: make perf.run-limits code work with Python 3 We need b'' because perf.py isn't run through the source transformer. We need to cast the exception to bytes using pycompat.bytestr() because ValueError can't be %s formatted due to built-in exceptions lacking __bytes__. We need to pycompat.sysstr() before the float() and int() cast so the ValueError message doesn't have b'' in it. Even with that, it looks like the error message for the ValueError for float casts added quotes, so we need to account for that in test output. Differential Revision: https://phab.mercurial-scm.org/D6200
author Gregory Szorc <gregory.szorc@gmail.com>
date Thu, 04 Apr 2019 17:47:25 -0700
parents 4c700c847aa2
children caebe5e7f4bd
comparison
equal deleted inserted replaced
42062:8de1b5a009ee 42063:912d82daeda3
314 314
315 # experimental config: perf.run-limits 315 # experimental config: perf.run-limits
316 limitspec = ui.configlist(b"perf", b"run-limits", []) 316 limitspec = ui.configlist(b"perf", b"run-limits", [])
317 limits = [] 317 limits = []
318 for item in limitspec: 318 for item in limitspec:
319 parts = item.split('-', 1) 319 parts = item.split(b'-', 1)
320 if len(parts) < 2: 320 if len(parts) < 2:
321 ui.warn(('malformatted run limit entry, missing "-": %s\n' 321 ui.warn((b'malformatted run limit entry, missing "-": %s\n'
322 % item)) 322 % item))
323 continue 323 continue
324 try: 324 try:
325 time_limit = float(parts[0]) 325 time_limit = float(pycompat.sysstr(parts[0]))
326 except ValueError as e: 326 except ValueError as e:
327 ui.warn(('malformatted run limit entry, %s: %s\n' 327 ui.warn((b'malformatted run limit entry, %s: %s\n'
328 % (e, item))) 328 % (pycompat.bytestr(e), item)))
329 continue 329 continue
330 try: 330 try:
331 run_limit = int(parts[1]) 331 run_limit = int(pycompat.sysstr(parts[1]))
332 except ValueError as e: 332 except ValueError as e:
333 ui.warn(('malformatted run limit entry, %s: %s\n' 333 ui.warn((b'malformatted run limit entry, %s: %s\n'
334 % (e, item))) 334 % (pycompat.bytestr(e), item)))
335 continue 335 continue
336 limits.append((time_limit, run_limit)) 336 limits.append((time_limit, run_limit))
337 if not limits: 337 if not limits:
338 limits = DEFAULTLIMITS 338 limits = DEFAULTLIMITS
339 339