Mercurial > public > mercurial-scm > hg-stable
comparison 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 |
comparison
equal
deleted
inserted
replaced
22632:db15bb2d6323 | 22633:92b54547ac5d |
---|---|
4 # | 4 # |
5 # This software may be used and distributed according to the terms of the | 5 # This software may be used and distributed according to the terms of the |
6 # GNU General Public License version 2 or any later version. | 6 # GNU General Public License version 2 or any later version. |
7 | 7 |
8 from i18n import gettext, _ | 8 from i18n import gettext, _ |
9 import itertools, sys, os | 9 import itertools, os |
10 import error | 10 import error |
11 import extensions, revset, fileset, templatekw, templatefilters, filemerge | 11 import extensions, revset, fileset, templatekw, templatefilters, filemerge |
12 import encoding, util, minirst | 12 import encoding, util, minirst |
13 import cmdutil | 13 import cmdutil |
14 | 14 |
127 | 127 |
128 def loaddoc(topic): | 128 def loaddoc(topic): |
129 """Return a delayed loader for help/topic.txt.""" | 129 """Return a delayed loader for help/topic.txt.""" |
130 | 130 |
131 def loader(): | 131 def loader(): |
132 if util.mainfrozen(): | |
133 module = sys.executable | |
134 else: | |
135 module = __file__ | |
136 base = os.path.dirname(module) | |
137 | |
138 for dir in ('.', '..'): | 132 for dir in ('.', '..'): |
139 docdir = os.path.join(base, dir, 'help') | 133 docdir = os.path.join(util.datapath, dir, 'help') |
140 if os.path.isdir(docdir): | 134 if os.path.isdir(docdir): |
141 break | 135 break |
142 | 136 |
143 path = os.path.join(docdir, topic + ".txt") | 137 path = os.path.join(docdir, topic + ".txt") |
144 doc = gettext(util.readfile(path)) | 138 doc = gettext(util.readfile(path)) |