Mercurial > hg
comparison mercurial/util.py @ 6501:4f7feeb6d6ee
Merge
author | Bryan O'Sullivan <bos@serpentine.com> |
---|---|
date | Wed, 09 Apr 2008 15:28:30 -0700 |
parents | ac0bcd951c2c a3175cd7dbec |
children | 9699864de219 |
comparison
equal
deleted
inserted
replaced
6498:315548fcc76b | 6501:4f7feeb6d6ee |
---|---|
13 """ | 13 """ |
14 | 14 |
15 from i18n import _ | 15 from i18n import _ |
16 import cStringIO, errno, getpass, re, shutil, sys, tempfile | 16 import cStringIO, errno, getpass, re, shutil, sys, tempfile |
17 import os, stat, threading, time, calendar, ConfigParser, locale, glob, osutil | 17 import os, stat, threading, time, calendar, ConfigParser, locale, glob, osutil |
18 import urlparse | 18 import imp, urlparse |
19 | 19 |
20 # Python compatibility | 20 # Python compatibility |
21 | 21 |
22 try: | 22 try: |
23 set = set | 23 set = set |
561 | 561 |
562 return (roots, match, (inc or exc or anypats) and True) | 562 return (roots, match, (inc or exc or anypats) and True) |
563 | 563 |
564 _hgexecutable = None | 564 _hgexecutable = None |
565 | 565 |
566 def main_is_frozen(): | |
567 """return True if we are a frozen executable. | |
568 | |
569 The code supports py2exe (most common, Windows only) and tools/freeze | |
570 (portable, not much used). | |
571 """ | |
572 return (hasattr(sys, "frozen") or # new py2exe | |
573 hasattr(sys, "importers") or # old py2exe | |
574 imp.is_frozen("__main__")) # tools/freeze | |
575 | |
566 def hgexecutable(): | 576 def hgexecutable(): |
567 """return location of the 'hg' executable. | 577 """return location of the 'hg' executable. |
568 | 578 |
569 Defaults to $HG or 'hg' in the search path. | 579 Defaults to $HG or 'hg' in the search path. |
570 """ | 580 """ |
571 if _hgexecutable is None: | 581 if _hgexecutable is None: |
572 set_hgexecutable(os.environ.get('HG') or find_exe('hg', 'hg')) | 582 hg = os.environ.get('HG') |
583 if hg: | |
584 set_hgexecutable(hg) | |
585 elif main_is_frozen(): | |
586 set_hgexecutable(sys.executable) | |
587 else: | |
588 set_hgexecutable(find_exe('hg', 'hg')) | |
573 return _hgexecutable | 589 return _hgexecutable |
574 | 590 |
575 def set_hgexecutable(path): | 591 def set_hgexecutable(path): |
576 """set location of the 'hg' executable""" | 592 """set location of the 'hg' executable""" |
577 global _hgexecutable | 593 global _hgexecutable |