mercurial/cmdutil.py
changeset 7213 b4c035057d34
parent 7121 b801d6e5dc83
child 7280 810ca383da9c
equal deleted inserted replaced
7212:402d317778d3 7213:b4c035057d34
    16 class UnknownCommand(Exception):
    16 class UnknownCommand(Exception):
    17     """Exception raised if command is not in the command table."""
    17     """Exception raised if command is not in the command table."""
    18 class AmbiguousCommand(Exception):
    18 class AmbiguousCommand(Exception):
    19     """Exception raised if command shortcut matches more than one command."""
    19     """Exception raised if command shortcut matches more than one command."""
    20 
    20 
    21 def findpossible(ui, cmd, table):
    21 def findpossible(cmd, table, strict=False):
    22     """
    22     """
    23     Return cmd -> (aliases, command table entry)
    23     Return cmd -> (aliases, command table entry)
    24     for each matching command.
    24     for each matching command.
    25     Return debug commands (or their aliases) only if no normal command matches.
    25     Return debug commands (or their aliases) only if no normal command matches.
    26     """
    26     """
    29     for e in table.keys():
    29     for e in table.keys():
    30         aliases = e.lstrip("^").split("|")
    30         aliases = e.lstrip("^").split("|")
    31         found = None
    31         found = None
    32         if cmd in aliases:
    32         if cmd in aliases:
    33             found = cmd
    33             found = cmd
    34         elif not ui.config("ui", "strict"):
    34         elif not strict:
    35             for a in aliases:
    35             for a in aliases:
    36                 if a.startswith(cmd):
    36                 if a.startswith(cmd):
    37                     found = a
    37                     found = a
    38                     break
    38                     break
    39         if found is not None:
    39         if found is not None:
    45     if not choice and debugchoice:
    45     if not choice and debugchoice:
    46         choice = debugchoice
    46         choice = debugchoice
    47 
    47 
    48     return choice
    48     return choice
    49 
    49 
    50 def findcmd(ui, cmd, table):
    50 def findcmd(cmd, table, strict=True):
    51     """Return (aliases, command table entry) for command string."""
    51     """Return (aliases, command table entry) for command string."""
    52     choice = findpossible(ui, cmd, table)
    52     choice = findpossible(cmd, table, strict)
    53 
    53 
    54     if cmd in choice:
    54     if cmd in choice:
    55         return choice[cmd]
    55         return choice[cmd]
    56 
    56 
    57     if len(choice) > 1:
    57     if len(choice) > 1: