comparison mercurial/commands.py @ 7590:e5703ec08e64

bisect: improve hg bisect -c (relative paths, error handling) hg bisect -c failed with a relative path or when the executable wasn't found. Use util.find_exe()+os.spawnl() instead of os.spawnlp() and improve the handling of errors (killed process, exe not found). Thanks to Georg Brandl for reporting it.
author Benoit Boissinot <benoit.boissinot@ens-lyon.org>
date Sun, 04 Jan 2009 19:38:41 +0100
parents e05aa73ce2b7
children 0be97ee2309d
comparison
equal deleted inserted replaced
7589:de16a665754c 7590:e5703ec08e64
326 return 326 return
327 327
328 state = hbisect.load_state(repo) 328 state = hbisect.load_state(repo)
329 329
330 if command: 330 if command:
331 commandpath = util.find_exe(command)
331 changesets = 1 332 changesets = 1
332 while changesets: 333 try:
333 # update state 334 while changesets:
334 status = os.spawnlp(os.P_WAIT, command) 335 # update state
335 node = repo.lookup(rev or '.') 336 status = os.spawnl(os.P_WAIT, commandpath)
336 if status == 125: 337 if status == 125:
337 transition = "skip" 338 transition = "skip"
338 elif status == 0: 339 elif status == 0:
339 transition = "good" 340 transition = "good"
340 # status < 0 means process was killed 341 # status < 0 means process was killed
341 elif status == 127 or status < 0: 342 elif status == 127:
342 break 343 raise util.Abort(_("failed to execute %s") % command)
343 else: 344 elif status < 0:
344 transition = "bad" 345 raise util.Abort(_("%s killed") % command)
345 state[transition].append(node) 346 else:
346 ui.note(_('Changeset %s: %s\n') % (short(node), transition)) 347 transition = "bad"
347 check_state(state, interactive=False) 348 node = repo.lookup(rev or '.')
348 # bisect 349 state[transition].append(node)
349 nodes, changesets, good = hbisect.bisect(repo.changelog, state) 350 ui.note(_('Changeset %s: %s\n') % (short(node), transition))
350 # update to next check 351 check_state(state, interactive=False)
351 cmdutil.bail_if_changed(repo) 352 # bisect
352 hg.clean(repo, nodes[0], show_stats=False) 353 nodes, changesets, good = hbisect.bisect(repo.changelog, state)
353 hbisect.save_state(repo, state) 354 # update to next check
355 cmdutil.bail_if_changed(repo)
356 hg.clean(repo, nodes[0], show_stats=False)
357 finally:
358 hbisect.save_state(repo, state)
354 return print_result(nodes, not status) 359 return print_result(nodes, not status)
355 360
356 # update state 361 # update state
357 node = repo.lookup(rev or '.') 362 node = repo.lookup(rev or '.')
358 if good: 363 if good: