Show More
@@ -20,7 +20,7 b' class AmbiguousCommand(Exception):' | |||
|
20 | 20 | class ParseError(Exception): |
|
21 | 21 | """Exception raised on errors in parsing the command line.""" |
|
22 | 22 | |
|
23 | def runcatch(ui, args): | |
|
23 | def runcatch(ui, args, argv0=None): | |
|
24 | 24 | def catchterm(*args): |
|
25 | 25 | raise util.SignalInterrupt |
|
26 | 26 | |
@@ -34,7 +34,7 b' def runcatch(ui, args):' | |||
|
34 | 34 | if '--debugger' in args: |
|
35 | 35 | pdb.set_trace() |
|
36 | 36 | try: |
|
37 | return dispatch(ui, args) | |
|
37 | return dispatch(ui, args, argv0=argv0) | |
|
38 | 38 | finally: |
|
39 | 39 | ui.flush() |
|
40 | 40 | except: |
@@ -255,7 +255,10 b' def earlygetopt(aliases, args):' | |||
|
255 | 255 | return args[args.index(opt) + 1] |
|
256 | 256 | return None |
|
257 | 257 | |
|
258 | def dispatch(ui, args): | |
|
258 | def dispatch(ui, args, argv0=None): | |
|
259 | # remember how to call 'hg' before changing the working dir | |
|
260 | util.set_hgexecutable(argv0) | |
|
261 | ||
|
259 | 262 | # check for cwd first |
|
260 | 263 | cwd = earlygetopt(['--cwd'], args) |
|
261 | 264 | if cwd: |
@@ -3090,13 +3090,13 b' norepo = ("clone init version help debug' | |||
|
3090 | 3090 | " debugindex debugindexdot debugdate debuginstall") |
|
3091 | 3091 | optionalrepo = ("paths serve showconfig") |
|
3092 | 3092 | |
|
3093 | def dispatch(args): | |
|
3093 | def dispatch(args, argv0=None): | |
|
3094 | 3094 | try: |
|
3095 | 3095 | u = ui.ui(traceback='--traceback' in args) |
|
3096 | 3096 | except util.Abort, inst: |
|
3097 | 3097 | sys.stderr.write(_("abort: %s\n") % inst) |
|
3098 | 3098 | return -1 |
|
3099 | return cmdutil.runcatch(u, args) | |
|
3099 | return cmdutil.runcatch(u, args, argv0=argv0) | |
|
3100 | 3100 | |
|
3101 | 3101 | def run(): |
|
3102 | sys.exit(dispatch(sys.argv[1:])) | |
|
3102 | sys.exit(dispatch(sys.argv[1:], argv0=sys.argv[0])) |
@@ -37,6 +37,11 b' helptable = {' | |||
|
37 | 37 | |
|
38 | 38 | 'environment|env|Environment Variables': |
|
39 | 39 | r''' |
|
40 | HG:: | |
|
41 | Path to the 'hg' executable, automatically passed when running hooks | |
|
42 | or external tools. Falls back to 'hg' if unset and the value can't be | |
|
43 | autodetected, e.g. when Mercurial is run as a Python module. | |
|
44 | ||
|
40 | 45 | HGEDITOR:: |
|
41 | 46 | This is the name of the editor to use when committing. Defaults to the |
|
42 | 47 | value of EDITOR. |
@@ -537,6 +537,17 b' def _matcher(canonroot, cwd, names, inc,' | |||
|
537 | 537 | |
|
538 | 538 | return (roots, match, (inc or exc or anypats) and True) |
|
539 | 539 | |
|
540 | _hgexecutable = None | |
|
541 | ||
|
542 | def set_hgexecutable(path): | |
|
543 | """remember location of the 'hg' executable if easily possible | |
|
544 | ||
|
545 | path might be None or empty if hg was loaded as a module, | |
|
546 | fall back to 'hg' in this case. | |
|
547 | """ | |
|
548 | global _hgexecutable | |
|
549 | _hgexecutable = path and os.path.abspath(path) or 'hg' | |
|
550 | ||
|
540 | 551 | def system(cmd, environ={}, cwd=None, onerr=None, errprefix=None): |
|
541 | 552 | '''enhanced shell command execution. |
|
542 | 553 | run with environment maybe modified, maybe in different dir. |
@@ -562,6 +573,8 b' def system(cmd, environ={}, cwd=None, on' | |||
|
562 | 573 | try: |
|
563 | 574 | for k, v in environ.iteritems(): |
|
564 | 575 | os.environ[k] = py2shell(v) |
|
576 | if 'HG' not in os.environ: | |
|
577 | os.environ['HG'] = _hgexecutable | |
|
565 | 578 | if cwd is not None and oldcwd != cwd: |
|
566 | 579 | os.chdir(cwd) |
|
567 | 580 | rc = os.system(cmd) |
General Comments 0
You need to be logged in to leave comments.
Login now