Show More
@@ -15,7 +15,7 b' platform-specific details from the core.' | |||||
15 | from i18n import _ |
|
15 | from i18n import _ | |
16 | import cStringIO, errno, getpass, popen2, re, shutil, sys, tempfile, strutil |
|
16 | import cStringIO, errno, getpass, popen2, re, shutil, sys, tempfile, strutil | |
17 | import os, stat, threading, time, calendar, ConfigParser, locale, glob, osutil |
|
17 | import os, stat, threading, time, calendar, ConfigParser, locale, glob, osutil | |
18 | import re, urlparse |
|
18 | import re, urlparse, imp | |
19 |
|
19 | |||
20 | try: |
|
20 | try: | |
21 | set = set |
|
21 | set = set | |
@@ -553,13 +553,28 b' def _matcher(canonroot, cwd, names, inc,' | |||||
553 |
|
553 | |||
554 | _hgexecutable = None |
|
554 | _hgexecutable = None | |
555 |
|
555 | |||
|
556 | def main_is_frozen(): | |||
|
557 | """return True if we are a frozen executable. | |||
|
558 | ||||
|
559 | The code supports py2exe (most common, Windows only) and tools/freeze | |||
|
560 | (portable, not much used). | |||
|
561 | """ | |||
|
562 | return (hasattr(sys, "frozen") or # new py2exe | |||
|
563 | hasattr(sys, "importers") or # old py2exe | |||
|
564 | imp.is_frozen("__main__")) # tools/freeze | |||
|
565 | ||||
556 | def hgexecutable(): |
|
566 | def hgexecutable(): | |
557 | """return location of the 'hg' executable. |
|
567 | """return location of the 'hg' executable. | |
558 |
|
568 | |||
559 | Defaults to $HG or 'hg' in the search path. |
|
569 | Defaults to $HG or 'hg' in the search path. | |
560 | """ |
|
570 | """ | |
561 | if _hgexecutable is None: |
|
571 | if _hgexecutable is None: | |
562 | set_hgexecutable(os.environ.get('HG') or find_exe('hg', 'hg')) |
|
572 | if os.environ.has_key('HG'): | |
|
573 | set_hgexecutable(os.environ.get('HG')) | |||
|
574 | elif main_is_frozen(): | |||
|
575 | set_hgexecutable(sys.executable) | |||
|
576 | else: | |||
|
577 | sel_hgexecutable(find_exe('hg', 'hg')) | |||
563 | return _hgexecutable |
|
578 | return _hgexecutable | |
564 |
|
579 | |||
565 | def set_hgexecutable(path): |
|
580 | def set_hgexecutable(path): |
General Comments 0
You need to be logged in to leave comments.
Login now