Patchwork D7417: procutil: extract executable-relative resources test

login
register
mail settings
Submitter phabricator
Date Nov. 15, 2019, 3:58 a.m.
Message ID <differential-rev-PHID-DREV-ig3g5rg3ner22nzx6ypt-req@mercurial-scm.org>
Download mbox | patch
Permalink /patch/43253/
State New
Headers show

Comments

phabricator - Nov. 15, 2019, 3:58 a.m.
indygreg created this revision.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.

REVISION SUMMARY
  We'll want to test for this in the new resource reading API.

REPOSITORY
  rHG Mercurial

BRANCH
  default

REVISION DETAIL
  https://phab.mercurial-scm.org/D7417

AFFECTED FILES
  mercurial/utils/procutil.py

CHANGE DETAILS




To: indygreg, #hg-reviewers
Cc: mercurial-devel

Patch

diff --git a/mercurial/utils/procutil.py b/mercurial/utils/procutil.py
--- a/mercurial/utils/procutil.py
+++ b/mercurial/utils/procutil.py
@@ -537,9 +537,13 @@ 
             # continue the hg process here.
             os._exit(returncode)
 
+def executablerelativeresources():
+    """Whether data/resource files are relative to the current executable."""
+    return mainfrozen() and getattr(sys, 'frozen', None) != 'macosx_app'
+
 def datapath():
     """Return location of data/resource files that are part of the source."""
-    if mainfrozen() and getattr(sys, 'frozen', None) != 'macosx_app':
+    if executablerelativeresources():
         # executable version (py2exe) doesn't support __file__
         return os.path.dirname(pycompat.sysexecutable)
     else: