Patchwork D7434: util: move definition of datapath to resourceutil

login
register
mail settings
Submitter phabricator
Date Nov. 16, 2019, 7:23 p.m.
Message ID <b5d0bc95e95a67983d08db77d14c6609@localhost.localdomain>
Download mbox | patch
Permalink /patch/43306/
State Not Applicable
Headers show

Comments

phabricator - Nov. 16, 2019, 7:23 p.m.
Closed by commit rHG4405d8858259: util: move definition of datapath to resourceutil (authored by martinvonz).
This revision was automatically updated to reflect the committed changes.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D7434?vs=18167&id=18183

CHANGES SINCE LAST ACTION
  https://phab.mercurial-scm.org/D7434/new/

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

AFFECTED FILES
  mercurial/util.py
  mercurial/utils/resourceutil.py

CHANGE DETAILS




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

Patch

diff --git a/mercurial/utils/resourceutil.py b/mercurial/utils/resourceutil.py
--- a/mercurial/utils/resourceutil.py
+++ b/mercurial/utils/resourceutil.py
@@ -10,6 +10,7 @@ 
 from __future__ import absolute_import
 
 import imp
+import os
 import sys
 
 from .. import (
@@ -27,3 +28,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__)))
diff --git a/mercurial/util.py b/mercurial/util.py
--- a/mercurial/util.py
+++ b/mercurial/util.py
@@ -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)