# HG changeset patch # User Matt Mackall # Date 1224714848 18000 # Node ID b4c035057d3414b70d3f5eef73a2698f7fc9ec5a # Parent 402d317778d31fb4e4ca36d0c7b19950bc733deb findcmd: have dispatch look up strict flag diff -r 402d317778d3 -r b4c035057d34 hgext/alias.py --- a/hgext/alias.py Wed Oct 22 17:00:05 2008 -0500 +++ b/hgext/alias.py Wed Oct 22 17:34:08 2008 -0500 @@ -43,7 +43,7 @@ return try: - self._cmd = findcmd(self._ui, self._target, commands.table)[1] + self._cmd = findcmd(self._target, commands.table, False)[1] if self._cmd == self: raise RecursiveCommand() if self._target in commands.norepo.split(' '): diff -r 402d317778d3 -r b4c035057d34 hgext/color.py --- a/hgext/color.py Wed Oct 22 17:00:05 2008 -0500 +++ b/hgext/color.py Wed Oct 22 17:34:08 2008 -0500 @@ -198,7 +198,7 @@ def _cmdtableitem(ui, cmd, table): '''Return key, value from table for cmd, or None if not found.''' - aliases, entry = cmdutil.findcmd(ui, cmd, table) + aliases, entry = cmdutil.findcmd(cmd, table) for candidatekey, candidateentry in table.iteritems(): if candidateentry is entry: return candidatekey, entry diff -r 402d317778d3 -r b4c035057d34 hgext/mq.py --- a/hgext/mq.py Wed Oct 22 17:00:05 2008 -0500 +++ b/hgext/mq.py Wed Oct 22 17:34:08 2008 -0500 @@ -2368,7 +2368,7 @@ def uisetup(ui): # override import to disallow importing over patch - importalias, importcmd = cmdutil.findcmd(ui, 'import', commands.table) + importalias, importcmd = cmdutil.findcmd('import', commands.table) for alias, cmd in commands.table.iteritems(): if cmd is importcmd: importkey = alias diff -r 402d317778d3 -r b4c035057d34 hgext/rebase.py --- a/hgext/rebase.py Wed Oct 22 17:00:05 2008 -0500 +++ b/hgext/rebase.py Wed Oct 22 17:34:08 2008 -0500 @@ -370,7 +370,7 @@ def uisetup(ui): 'Replace pull with a decorator to provide --rebase option' # cribbed from color.py - aliases, entry = cmdutil.findcmd(ui, 'pull', commands.table) + aliases, entry = cmdutil.findcmd('pull', commands.table) for candidatekey, candidateentry in commands.table.iteritems(): if candidateentry is entry: cmdkey, cmdentry = candidatekey, entry diff -r 402d317778d3 -r b4c035057d34 mercurial/cmdutil.py --- a/mercurial/cmdutil.py Wed Oct 22 17:00:05 2008 -0500 +++ b/mercurial/cmdutil.py Wed Oct 22 17:34:08 2008 -0500 @@ -18,7 +18,7 @@ class AmbiguousCommand(Exception): """Exception raised if command shortcut matches more than one command.""" -def findpossible(ui, cmd, table): +def findpossible(cmd, table, strict=False): """ Return cmd -> (aliases, command table entry) for each matching command. @@ -31,7 +31,7 @@ found = None if cmd in aliases: found = cmd - elif not ui.config("ui", "strict"): + elif not strict: for a in aliases: if a.startswith(cmd): found = a @@ -47,9 +47,9 @@ return choice -def findcmd(ui, cmd, table): +def findcmd(cmd, table, strict=True): """Return (aliases, command table entry) for command string.""" - choice = findpossible(ui, cmd, table) + choice = findpossible(cmd, table, strict) if cmd in choice: return choice[cmd] diff -r 402d317778d3 -r b4c035057d34 mercurial/commands.py --- a/mercurial/commands.py Wed Oct 22 17:00:05 2008 -0500 +++ b/mercurial/commands.py Wed Oct 22 17:34:08 2008 -0500 @@ -655,7 +655,7 @@ options = [] otables = [globalopts] if cmd: - aliases, entry = cmdutil.findcmd(ui, cmd, table) + aliases, entry = cmdutil.findcmd(cmd, table, False) otables.append(entry[1]) for t in otables: for o in t: @@ -665,7 +665,7 @@ ui.write("%s\n" % "\n".join(options)) return - ui.write("%s\n" % "\n".join(util.sort(cmdutil.findpossible(ui, cmd, table)))) + ui.write("%s\n" % "\n".join(util.sort(cmdutil.findpossible(cmd, table)))) def debugfsinfo(ui, path = "."): file('.debugfsinfo', 'w').write('') @@ -1272,7 +1272,7 @@ ui.write('\n') try: - aliases, i = cmdutil.findcmd(ui, name, table) + aliases, i = cmdutil.findcmd(name, table, False) except cmdutil.AmbiguousCommand, inst: select = lambda c: c.lstrip('^').startswith(inst.args[0]) helplist(_('list of commands:\n\n'), select) diff -r 402d317778d3 -r b4c035057d34 mercurial/dispatch.py --- a/mercurial/dispatch.py Wed Oct 22 17:00:05 2008 -0500 +++ b/mercurial/dispatch.py Wed Oct 22 17:34:08 2008 -0500 @@ -171,7 +171,8 @@ if args: cmd, args = args[0], args[1:] - aliases, i = cmdutil.findcmd(ui, cmd, commands.table) + aliases, i = cmdutil.findcmd(cmd, commands.table, + ui.config("ui","strict")) cmd = aliases[0] defaults = ui.config("defaults", cmd) if defaults: