comparison mercurial/util.py @ 22633:92b54547ac5d

util: introduce datapath for getting the location of supporting data files templates, help and locale data is normally stored as sub folders in the directory containing the source of the mercurial module. In a frozen build they live as sub folders next to 'hg.exe' and 'library.zip'. These different kind of data were handled in different ways. Unify that by introducing util.datapath. The value is computed from the environment and is always used, so we just calculate the value on module load.
author Mads Kiilerich <madski@unity3d.com>
date Sun, 28 Sep 2014 16:57:06 +0200
parents db15bb2d6323
children 0d0350cfc7ab
comparison
equal deleted inserted replaced
22632:db15bb2d6323 22633:92b54547ac5d
458 """ 458 """
459 return (safehasattr(sys, "frozen") or # new py2exe 459 return (safehasattr(sys, "frozen") or # new py2exe
460 safehasattr(sys, "importers") or # old py2exe 460 safehasattr(sys, "importers") or # old py2exe
461 imp.is_frozen("__main__")) # tools/freeze 461 imp.is_frozen("__main__")) # tools/freeze
462 462
463 # the location of data files matching the source code
464 if mainfrozen():
465 # executable version (py2exe) doesn't support __file__
466 datapath = os.path.dirname(sys.executable)
467 else:
468 datapath = os.path.dirname(__file__)
469
463 _hgexecutable = None 470 _hgexecutable = None
464 471
465 def hgexecutable(): 472 def hgexecutable():
466 """return location of the 'hg' executable. 473 """return location of the 'hg' executable.
467 474