# HG changeset patch # User Matt Mackall # Date 1198821340 21600 # Node ID 9079081b89826ef0a856748bf82c76e2c0f67986 # Parent 944b231fa0e71ce3c7eaab08435bcb77b21a845c bisect: use more standard command syntax and help diff -r 944b231fa0e7 -r 9079081b8982 hgext/hbisect.py --- a/hgext/hbisect.py Thu Dec 27 23:55:40 2007 -0600 +++ b/hgext/hbisect.py Thu Dec 27 23:55:40 2007 -0600 @@ -151,7 +151,8 @@ self.write() return self.next() -def bisect_run(ui, repo, cmd=None, *args): +def bisect_run(ui, repo, node=None, extra=None, + reset=None, good=None, bad=None, skip=None): """Subdivision search of changesets This extension helps to find changesets which introduce problems. @@ -166,48 +167,37 @@ If you are looking for the point at which a problem was fixed, then make the problem-free state "bad" and the problematic state "good." -For subcommands see "hg bisect help\" """ - def help_(cmd=None, *args): - """show help for a given bisect subcommand or all subcommands""" - cmdtable = bisectcmdtable - if cmd: - doc = cmdtable[cmd][0].__doc__ - synopsis = cmdtable[cmd][2] - ui.write(synopsis + "\n") - ui.write("\n" + doc + "\n") - return - ui.write(_("list of subcommands for the bisect extension\n\n")) - cmds = cmdtable.keys() - cmds.sort() - m = max([len(c) for c in cmds]) - for cmd in cmds: - doc = cmdtable[cmd][0].__doc__.splitlines(0)[0].rstrip() - ui.write(" %-*s %s\n" % (m, cmd, doc)) + # backward compatibility + if node in "good bad reset init".split(): + ui.warn(_("(use of 'hg bisect ' is deprecated)\n")) + cmd, node, extra = node, extra, None + if cmd == "good": + good = True + elif cmd == "bad": + bad = True + else: + reset = True + elif extra or good + bad + skip + reset > 1: + raise util.Abort("Incompatible arguments") b = bisect(ui, repo) - bisectcmdtable = { - "init": (b.init, 0, _("hg bisect init")), - "bad": (b.bad, 1, _("hg bisect bad []")), - "good": (b.good, 1, _("hg bisect good []")), - "skip": (b.skip, 1, _("hg bisect skip []")), - "next": (b.next, 0, _("hg bisect next")), - "help": (help_, 1, _("hg bisect help []")), - } - - if cmd == "reset": - cmd = "init" - - if not bisectcmdtable.has_key(cmd): - ui.warn(_("bisect: Unknown sub-command\n")) - return help_() - if len(args) > bisectcmdtable[cmd][1]: - ui.warn(_("bisect: Too many arguments\n")) - return help_() - ret = bisectcmdtable[cmd][0](*args) - return ret + if good: + return b.good(node) + elif bad: + return b.bad(node) + elif skip: + return b.skip(node) + elif reset: + return b.init() + else: + return b.next() cmdtable = { - "bisect": (bisect_run, [], _("hg bisect [help|init|reset|next|good|bad]")), - #"bisect-test": (test, [], "hg bisect-test rev"), + "bisect": (bisect_run, + [('r', 'reset', False, _('reset bisect state')), + ('g', 'good', False, _('mark changeset good')), + ('b', 'bad', False, _('mark changeset bad')), + ('s', 'skip', False, _('skip testing changeset'))], + _("hg bisect [-gbsr] [REV]")) } diff -r 944b231fa0e7 -r 9079081b8982 tests/test-bisect --- a/tests/test-bisect Thu Dec 27 23:55:40 2007 -0600 +++ b/tests/test-bisect Thu Dec 27 23:55:40 2007 -0600 @@ -26,11 +26,11 @@ hg up -C echo % bisect test -hg bisect init -hg bisect bad -hg bisect good 1 -hg bisect good -hg bisect good -hg bisect good -hg bisect bad -hg bisect good +hg bisect -r +hg bisect -b +hg bisect -g 1 +hg bisect -g +hg bisect -g +hg bisect -g +hg bisect -b +hg bisect -g