comparison mercurial/commands.py @ 7228:9b72c732ed2f

bisect with command: ability to skip revision or abort bisection
author Alexander Solovyov <piranha@piranha.org.ua>
date Thu, 16 Oct 2008 19:40:09 +0300
parents e1afb50ec2aa
children 261a9f47b44b
comparison
equal deleted inserted replaced
7227:e1afb50ec2aa 7228:9b72c732ed2f
274 or announce that it has found the bad revision. 274 or announce that it has found the bad revision.
275 275
276 As a shortcut, you can also use the revision argument to mark a 276 As a shortcut, you can also use the revision argument to mark a
277 revision as good or bad without checking it out first. 277 revision as good or bad without checking it out first.
278 278
279 If you supply a command it will be used for automatic bisection. Its 279 If you supply a command it will be used for automatic bisection. Its exit
280 exit status will be used as flag to mark revision as bad or good (good 280 status will be used as flag to mark revision as bad or good. In case exit
281 in case of 0 and bad in any other case). 281 status is 0 the revision is marked as good, 125 - skipped, 127 (command not
282 found) - bisection will be aborted and any other status bigger than 0 will
283 mark revision as bad.
282 """ 284 """
283 def print_result(nodes, good): 285 def print_result(nodes, good):
284 displayer = cmdutil.show_changeset(ui, repo, {}) 286 displayer = cmdutil.show_changeset(ui, repo, {})
285 transition = (good and "good" or "bad") 287 transition = (good and "good" or "bad")
286 if len(nodes) == 1: 288 if len(nodes) == 1:
326 state = hbisect.load_state(repo) 328 state = hbisect.load_state(repo)
327 329
328 if command: 330 if command:
329 changesets = 1 331 changesets = 1
330 while changesets: 332 while changesets:
331 # check state 333 # update state
332 status = bool(list(os.popen3(command)[2])) 334 status = os.spawnlp(os.P_WAIT, command)
333 node = repo.lookup(rev or '.') 335 node = repo.lookup(rev or '.')
334 transition = (status and 'bad' or 'good') 336 if status == 125:
337 transition = "skip"
338 elif status == 0:
339 transition = "good"
340 # status < 0 means process was killed
341 elif status == 127 or status < 0:
342 break
343 else:
344 transition = "bad"
335 state[transition].append(node) 345 state[transition].append(node)
336 ui.note(_('Changeset %s: %s\n') % (short(node), transition)) 346 ui.note(_('Changeset %s: %s\n') % (short(node), transition))
337 check_state(state, interactive=False) 347 check_state(state, interactive=False)
338 # bisect 348 # bisect
339 nodes, changesets, good = hbisect.bisect(repo.changelog, state) 349 nodes, changesets, good = hbisect.bisect(repo.changelog, state)