diff mercurial/help.py @ 22633:92b54547ac5d

util: introduce datapath for getting the location of supporting data files templates, help and locale data is normally stored as sub folders in the directory containing the source of the mercurial module. In a frozen build they live as sub folders next to 'hg.exe' and 'library.zip'. These different kind of data were handled in different ways. Unify that by introducing util.datapath. The value is computed from the environment and is always used, so we just calculate the value on module load.
author Mads Kiilerich <madski@unity3d.com>
date Sun, 28 Sep 2014 16:57:06 +0200
parents c5df4af17110
children 149141c3a25f
line wrap: on
line diff
--- a/mercurial/help.py	Sun Sep 28 16:57:06 2014 +0200
+++ b/mercurial/help.py	Sun Sep 28 16:57:06 2014 +0200
@@ -6,7 +6,7 @@
 # GNU General Public License version 2 or any later version.
 
 from i18n import gettext, _
-import itertools, sys, os
+import itertools, os
 import error
 import extensions, revset, fileset, templatekw, templatefilters, filemerge
 import encoding, util, minirst
@@ -129,14 +129,8 @@
     """Return a delayed loader for help/topic.txt."""
 
     def loader():
-        if util.mainfrozen():
-            module = sys.executable
-        else:
-            module = __file__
-        base = os.path.dirname(module)
-
         for dir in ('.', '..'):
-            docdir = os.path.join(base, dir, 'help')
+            docdir = os.path.join(util.datapath, dir, 'help')
             if os.path.isdir(docdir):
                 break