mercurial/cmdutil.py
changeset 7643 9a1ea6587557
parent 7404 07cb58b8c843
child 7667 bd5c37d792e6
equal deleted inserted replaced
7642:84346894def8 7643:9a1ea6587557
     6 # of the GNU General Public License, incorporated herein by reference.
     6 # of the GNU General Public License, incorporated herein by reference.
     7 
     7 
     8 from node import hex, nullid, nullrev, short
     8 from node import hex, nullid, nullrev, short
     9 from i18n import _
     9 from i18n import _
    10 import os, sys, bisect, stat
    10 import os, sys, bisect, stat
    11 import mdiff, bdiff, util, templater, templatefilters, patch, errno
    11 import mdiff, bdiff, util, templater, templatefilters, patch, errno, error
    12 import match as _match
    12 import match as _match
    13 
    13 
    14 revrangesep = ':'
    14 revrangesep = ':'
    15 
       
    16 class UnknownCommand(Exception):
       
    17     """Exception raised if command is not in the command table."""
       
    18 class AmbiguousCommand(Exception):
       
    19     """Exception raised if command shortcut matches more than one command."""
       
    20 
    15 
    21 def findpossible(cmd, table, strict=False):
    16 def findpossible(cmd, table, strict=False):
    22     """
    17     """
    23     Return cmd -> (aliases, command table entry)
    18     Return cmd -> (aliases, command table entry)
    24     for each matching command.
    19     for each matching command.
    55         return choice[cmd]
    50         return choice[cmd]
    56 
    51 
    57     if len(choice) > 1:
    52     if len(choice) > 1:
    58         clist = choice.keys()
    53         clist = choice.keys()
    59         clist.sort()
    54         clist.sort()
    60         raise AmbiguousCommand(cmd, clist)
    55         raise error.AmbiguousCommand(cmd, clist)
    61 
    56 
    62     if choice:
    57     if choice:
    63         return choice.values()[0]
    58         return choice.values()[0]
    64 
    59 
    65     raise UnknownCommand(cmd)
    60     raise error.UnknownCommand(cmd)
    66 
    61 
    67 def bail_if_changed(repo):
    62 def bail_if_changed(repo):
    68     if repo.dirstate.parents()[1] != nullid:
    63     if repo.dirstate.parents()[1] != nullid:
    69         raise util.Abort(_('outstanding uncommitted merge'))
    64         raise util.Abort(_('outstanding uncommitted merge'))
    70     modified, added, removed, deleted = repo.status()[:4]
    65     modified, added, removed, deleted = repo.status()[:4]