Submitter | phabricator |
---|---|
Date | Nov. 15, 2019, 3:59 a.m. |
Message ID | <differential-rev-PHID-DREV-lv5pskfnrcvnq3vt4yzs-req@mercurial-scm.org> |
Download | mbox | patch |
Permalink | /patch/43256/ |
State | Superseded |
Headers | show |
Comments
indygreg added a comment. indygreg added a subscriber: mharbison72. indygreg planned changes to this revision. This is an old series I had authored a few months back as part of preliminary PyOxidizer porting. It demonstrates an alternate approach to loading files with the resources API. Essentially, I was trying to abstract the resources API so that in the future once we are Python 3.7+ native we could use `importlib.resources` directly and perform all resources I/O using a resources abstraction. This series is in desperate need of a rebase. Please take a look @mharbison72 and consider taking ownership of these patches under your own name. REPOSITORY rHG Mercurial CHANGES SINCE LAST ACTION https://phab.mercurial-scm.org/D7415/new/ REVISION DETAIL https://phab.mercurial-scm.org/D7415 To: indygreg, #hg-reviewers Cc: mharbison72, mercurial-devel
martinvonz added a comment. Also see D7433 <https://phab.mercurial-scm.org/D7433>-D7436, which move this code to a new module so the `i18n` module can depend on this code. REPOSITORY rHG Mercurial CHANGES SINCE LAST ACTION https://phab.mercurial-scm.org/D7415/new/ REVISION DETAIL https://phab.mercurial-scm.org/D7415 To: indygreg, #hg-reviewers Cc: martinvonz, mharbison72, mercurial-devel
indygreg added a comment. indygreg abandoned this revision. This patch is now irrelevant due to D7434 <https://phab.mercurial-scm.org/D7434>. REPOSITORY rHG Mercurial CHANGES SINCE LAST ACTION https://phab.mercurial-scm.org/D7415/new/ REVISION DETAIL https://phab.mercurial-scm.org/D7415 To: indygreg, #hg-reviewers Cc: martinvonz, mharbison72, 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 @@ -535,3 +535,12 @@ # mission accomplished, this child needs to exit and not # continue the hg process here. os._exit(returncode) + +def datapath(): + """Return location of data/resource files that are part of the source.""" + if mainfrozen() and getattr(sys, 'frozen', None) != 'macosx_app': + # executable version (py2exe) doesn't support __file__ + return os.path.dirname(pycompat.sysexecutable) + else: + return os.path.dirname( + os.path.dirname(pycompat.fsencode(__file__))) diff --git a/mercurial/util.py b/mercurial/util.py --- a/mercurial/util.py +++ b/mercurial/util.py @@ -1660,13 +1660,7 @@ b.reverse() return pycompat.ossep.join((['..'] * len(a)) + b) or '.' -# the location of data files matching the source code -if procutil.mainfrozen() and getattr(sys, 'frozen', None) != 'macosx_app': - # executable version (py2exe) doesn't support __file__ - datapath = os.path.dirname(pycompat.sysexecutable) -else: - datapath = os.path.dirname(pycompat.fsencode(__file__)) - +datapath = procutil.datapath() i18n.setdatapath(datapath) def checksignature(func):