diff --git a/mercurial/help.py b/mercurial/help.py --- a/mercurial/help.py +++ b/mercurial/help.py @@ -8,7 +8,6 @@ from __future__ import absolute_import import itertools -import os import re import textwrap @@ -37,6 +36,9 @@ from .hgweb import ( webcommands, ) +from .utils import ( + procutil, +) _exclkeywords = { "(ADVANCED)", @@ -291,13 +293,19 @@ """Return a delayed loader for help/topic.txt.""" def loader(ui): - docdir = os.path.join(util.datapath, 'help') + reader = procutil.resourcereader('mercurial') + if subdir: - docdir = os.path.join(docdir, subdir) - path = os.path.join(docdir, topic + ".txt") - doc = gettext(util.readfile(path)) + resource = b'help/%s/%s.txt' % (subdir, topic) + else: + resource = b'help/%s.txt' % topic + + with reader.open_resource(resource) as fh: + doc = gettext(fh.read()) + for rewriter in helphooks.get(topic, []): doc = rewriter(ui, topic, doc) + return doc return loader