Mercurial > public > mercurial-scm > hg-stable
comparison mercurial/cmdutil.py @ 5062:3d35c8cb5eb4
Simplify/correct finding the hg executable (fixes issue644)
Simply use find_exe('hg') as the default value for $HG and require to manually
set it if you have special requirements.
While the default will not always be 100% correct (i.e. the identical hg
version) for many users it is and for the others the hg executable found in
the PATH should do most things correctly.
Developers or other users with multiple installs can set $HG or run something
like util.set_hgexecutable in their shell or python scripts.
Additionally util.hgexecutable() is now available so extensions can access
the value with a public interface, too.
author | Thomas Arendsen Hein <thomas@intevation.de> |
---|---|
date | Sat, 04 Aug 2007 22:25:12 +0200 |
parents | 10afa3fab6b4 |
children | d5126a0172ba cbe6e263357b |
comparison
equal
deleted
inserted
replaced
5061:a49f2a4d5ff7 | 5062: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)) |