Patchwork D7436: util: remove datapath and swith users over to resourceutil

login
register
mail settings
Submitter phabricator
Date Nov. 15, 2019, 7:13 p.m.
Message ID <differential-rev-PHID-DREV-ithsjo3frbucda2gygfw-req@mercurial-scm.org>
Download mbox | patch
Permalink /patch/43283/
State Superseded
Headers show

Comments

phabricator - Nov. 15, 2019, 7:13 p.m.
martinvonz created this revision.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.

REVISION SUMMARY
  The util module no longer needs the datapath for injecting it into the
  i18n module, so we can remove it from there and update other users.

REPOSITORY
  rHG Mercurial

BRANCH
  default

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

AFFECTED FILES
  mercurial/help.py
  mercurial/rcutil.py
  mercurial/templater.py
  mercurial/util.py

CHANGE DETAILS




To: martinvonz, #hg-reviewers
Cc: mercurial-devel
phabricator - Nov. 16, 2019, 7:09 p.m.
This revision is now accepted and ready to land.
indygreg added a comment.
indygreg accepted this revision.


  Nice series!

REPOSITORY
  rHG Mercurial

BRANCH
  default

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

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

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

Patch

diff --git a/mercurial/util.py b/mercurial/util.py
--- a/mercurial/util.py
+++ b/mercurial/util.py
@@ -54,7 +54,6 @@ 
 from .utils import (
     compression,
     procutil,
-    resourceutil,
     stringutil,
 )
 
@@ -1823,9 +1822,6 @@ 
     return pycompat.ossep.join(([b'..'] * len(a)) + b) or b'.'
 
 
-datapath = resourceutil.datapath
-
-
 def checksignature(func):
     '''wrap a function with code to check for calling errors'''
 
diff --git a/mercurial/templater.py b/mercurial/templater.py
--- a/mercurial/templater.py
+++ b/mercurial/templater.py
@@ -80,7 +80,10 @@ 
     templateutil,
     util,
 )
-from .utils import stringutil
+from .utils import (
+    resourceutil,
+    stringutil,
+)
 
 # template parsing
 
@@ -1042,7 +1045,10 @@ 
 def templatepaths():
     '''return locations used for template files.'''
     pathsrel = [b'templates']
-    paths = [os.path.normpath(os.path.join(util.datapath, f)) for f in pathsrel]
+    paths = [
+        os.path.normpath(os.path.join(resourceutil.datapath, f))
+        for f in pathsrel
+    ]
     return [p for p in paths if os.path.isdir(p)]
 
 
diff --git a/mercurial/rcutil.py b/mercurial/rcutil.py
--- a/mercurial/rcutil.py
+++ b/mercurial/rcutil.py
@@ -15,6 +15,8 @@ 
     util,
 )
 
+from .utils import resourceutil
+
 if pycompat.iswindows:
     from . import scmwindows as scmplatform
 else:
@@ -62,7 +64,7 @@ 
 def defaultrcpath():
     '''return rc paths in defaultrc'''
     path = []
-    defaultpath = os.path.join(util.datapath, b'defaultrc')
+    defaultpath = os.path.join(resourceutil.datapath, b'defaultrc')
     if os.path.isdir(defaultpath):
         path = _expandrcpath(defaultpath)
     return path
diff --git a/mercurial/help.py b/mercurial/help.py
--- a/mercurial/help.py
+++ b/mercurial/help.py
@@ -36,7 +36,10 @@ 
     util,
 )
 from .hgweb import webcommands
-from .utils import compression
+from .utils import (
+    compression,
+    resourceutil,
+)
 
 _exclkeywords = {
     b"(ADVANCED)",
@@ -311,7 +314,7 @@ 
     """Return a delayed loader for help/topic.txt."""
 
     def loader(ui):
-        docdir = os.path.join(util.datapath, b'helptext')
+        docdir = os.path.join(resourceutil.datapath, b'helptext')
         if subdir:
             docdir = os.path.join(docdir, subdir)
         path = os.path.join(docdir, topic + b".txt")