changeset 43672:9fb85668ee15

util: move definition of datapath to resourceutil Since this means moving the function into a subdirectory, we have to compensate by adding another layer of os.path.dirname(). Differential Revision: https://phab.mercurial-scm.org/D7434
author Martin von Zweigbergk <martinvonz@google.com>
date Thu, 14 Nov 2019 12:33:10 -0800
parents 664e24207728
children f0bee3b1b847
files mercurial/util.py mercurial/utils/resourceutil.py
diffstat 2 files changed, 10 insertions(+), 7 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/util.py	Thu Nov 14 11:52:22 2019 -0800
+++ b/mercurial/util.py	Thu Nov 14 12:33:10 2019 -0800
@@ -1823,13 +1823,7 @@
     return pycompat.ossep.join(([b'..'] * len(a)) + b) or b'.'
 
 
-# the location of data files matching the source code
-if resourceutil.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 = resourceutil.datapath
 i18n.setdatapath(datapath)
 
 
--- a/mercurial/utils/resourceutil.py	Thu Nov 14 11:52:22 2019 -0800
+++ b/mercurial/utils/resourceutil.py	Thu Nov 14 12:33:10 2019 -0800
@@ -10,6 +10,7 @@
 from __future__ import absolute_import
 
 import imp
+import os
 import sys
 
 from .. import pycompat
@@ -26,3 +27,11 @@
         or pycompat.safehasattr(sys, "importers")  # new py2exe
         or imp.is_frozen("__main__")  # old py2exe
     )  # tools/freeze
+
+
+# the location of data files matching the source code
+if 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(os.path.dirname(pycompat.fsencode(__file__)))