mercurial/cmdutil.py
changeset 5067 3d35c8cb5eb4
parent 4944 10afa3fab6b4
child 5068 d5126a0172ba
child 5236 cbe6e263357b
equal deleted inserted replaced
5061:a49f2a4d5ff7 5067:3d35c8cb5eb4
    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 class ParseError(Exception):
    20 class ParseError(Exception):
    21     """Exception raised on errors in parsing the command line."""
    21     """Exception raised on errors in parsing the command line."""
    22 
    22 
    23 def runcatch(ui, args, argv0=None):
    23 def runcatch(ui, args):
    24     def catchterm(*args):
    24     def catchterm(*args):
    25         raise util.SignalInterrupt
    25         raise util.SignalInterrupt
    26 
    26 
    27     for name in 'SIGBREAK', 'SIGHUP', 'SIGTERM':
    27     for name in 'SIGBREAK', 'SIGHUP', 'SIGTERM':
    28         num = getattr(signal, name, None)
    28         num = getattr(signal, name, None)
    32         try:
    32         try:
    33             # enter the debugger before command execution
    33             # enter the debugger before command execution
    34             if '--debugger' in args:
    34             if '--debugger' in args:
    35                 pdb.set_trace()
    35                 pdb.set_trace()
    36             try:
    36             try:
    37                 return dispatch(ui, args, argv0=argv0)
    37                 return dispatch(ui, args)
    38             finally:
    38             finally:
    39                 ui.flush()
    39                 ui.flush()
    40         except:
    40         except:
    41             # enter the debugger when we hit an exception
    41             # enter the debugger when we hit an exception
    42             if '--debugger' in args:
    42             if '--debugger' in args:
   274             argcount -= 1
   274             argcount -= 1
   275         else:
   275         else:
   276             pos += 1
   276             pos += 1
   277     return values
   277     return values
   278 
   278 
   279 def dispatch(ui, args, argv0=None):
   279 def dispatch(ui, args):
   280     # remember how to call 'hg' before changing the working dir
       
   281     util.set_hgexecutable(argv0)
       
   282 
       
   283     # read --config before doing anything else
   280     # read --config before doing anything else
   284     # (e.g. to change trust settings for reading .hg/hgrc)
   281     # (e.g. to change trust settings for reading .hg/hgrc)
   285     config = earlygetopt(['--config'], args)
   282     config = earlygetopt(['--config'], args)
   286     if config:
   283     if config:
   287         ui.updateopts(config=parseconfig(config))
   284         ui.updateopts(config=parseconfig(config))