Show More
@@ -1668,8 +1668,8 b' def debuginstall(ui, **opts):' | |||||
1668 | fm.data(re2=bool(util._re2)) |
|
1668 | fm.data(re2=bool(util._re2)) | |
1669 |
|
1669 | |||
1670 | # templates |
|
1670 | # templates | |
1671 |
p = templater.template |
|
1671 | p = templater.templatedir() | |
1672 |
fm.write(b'templatedirs', b'checking templates (%s)...\n', |
|
1672 | fm.write(b'templatedirs', b'checking templates (%s)...\n', p) | |
1673 | fm.condwrite(not p, b'', _(b" no template directories found\n")) |
|
1673 | fm.condwrite(not p, b'', _(b" no template directories found\n")) | |
1674 | if p: |
|
1674 | if p: | |
1675 | m = templater.templatepath(b"map-cmdline.default") |
|
1675 | m = templater.templatepath(b"map-cmdline.default") |
@@ -414,7 +414,7 b' class hgwebdir(object):' | |||||
414 | fname = req.qsparams[b'static'] |
|
414 | fname = req.qsparams[b'static'] | |
415 | static = self.ui.config(b"web", b"static", untrusted=False) |
|
415 | static = self.ui.config(b"web", b"static", untrusted=False) | |
416 | if not static: |
|
416 | if not static: | |
417 |
tp = self.templatepath or templater.template |
|
417 | tp = self.templatepath or templater.templatedir() | |
418 | if isinstance(tp, bytes): |
|
418 | if isinstance(tp, bytes): | |
419 | tp = [tp] |
|
419 | tp = [tp] | |
420 | static = [os.path.join(p, b'static') for p in tp] |
|
420 | static = [os.path.join(p, b'static') for p in tp] |
@@ -1319,7 +1319,7 b' def static(web):' | |||||
1319 | # readable by the user running the CGI script |
|
1319 | # readable by the user running the CGI script | |
1320 | static = web.config(b"web", b"static", untrusted=False) |
|
1320 | static = web.config(b"web", b"static", untrusted=False) | |
1321 | if not static: |
|
1321 | if not static: | |
1322 |
tp = web.templatepath or templater.template |
|
1322 | tp = web.templatepath or templater.templatedir() | |
1323 | if isinstance(tp, bytes): |
|
1323 | if isinstance(tp, bytes): | |
1324 | tp = [tp] |
|
1324 | tp = [tp] | |
1325 | static = [os.path.join(p, b'static') for p in tp] |
|
1325 | static = [os.path.join(p, b'static') for p in tp] |
@@ -800,10 +800,10 b' class engine(object):' | |||||
800 |
|
800 | |||
801 |
|
801 | |||
802 | def stylelist(): |
|
802 | def stylelist(): | |
803 |
path |
|
803 | path = templatedir() | |
804 |
if not path |
|
804 | if not path: | |
805 | return _(b'no templates found, try `hg debuginstall` for more info') |
|
805 | return _(b'no templates found, try `hg debuginstall` for more info') | |
806 |
dirlist = os.listdir(path |
|
806 | dirlist = os.listdir(path) | |
807 | stylelist = [] |
|
807 | stylelist = [] | |
808 | for file in dirlist: |
|
808 | for file in dirlist: | |
809 | split = file.split(b".") |
|
809 | split = file.split(b".") | |
@@ -823,7 +823,7 b' def _readmapfile(mapfile):' | |||||
823 | ) |
|
823 | ) | |
824 |
|
824 | |||
825 | base = os.path.dirname(mapfile) |
|
825 | base = os.path.dirname(mapfile) | |
826 |
conf = config.config(includepaths=template |
|
826 | conf = config.config(includepaths=[templatedir()]) | |
827 | conf.read(mapfile, remap={b'': b'templates'}) |
|
827 | conf.read(mapfile, remap={b'': b'templates'}) | |
828 |
|
828 | |||
829 | cache = {} |
|
829 | cache = {} | |
@@ -837,15 +837,13 b' def _readmapfile(mapfile):' | |||||
837 |
|
837 | |||
838 | # fallback check in template paths |
|
838 | # fallback check in template paths | |
839 | if not os.path.exists(path): |
|
839 | if not os.path.exists(path): | |
840 | for p in templatepaths(): |
|
840 | p2 = util.normpath(os.path.join(templatedir(), val)) | |
841 | p2 = util.normpath(os.path.join(p, val)) |
|
841 | if os.path.isfile(p2): | |
842 |
|
|
842 | path = p2 | |
843 | path = p2 |
|
843 | else: | |
844 | break |
|
|||
845 | p3 = util.normpath(os.path.join(p2, b"map")) |
|
844 | p3 = util.normpath(os.path.join(p2, b"map")) | |
846 | if os.path.isfile(p3): |
|
845 | if os.path.isfile(p3): | |
847 | path = p3 |
|
846 | path = p3 | |
848 | break |
|
|||
849 |
|
847 | |||
850 | cache, tmap, aliases = _readmapfile(path) |
|
848 | cache, tmap, aliases = _readmapfile(path) | |
851 |
|
849 | |||
@@ -1045,18 +1043,17 b' class templater(object):' | |||||
1045 | return stream |
|
1043 | return stream | |
1046 |
|
1044 | |||
1047 |
|
1045 | |||
1048 |
def template |
|
1046 | def templatedir(): | |
1049 |
'''return |
|
1047 | '''return the directory used for template files, or None.''' | |
1050 | path = os.path.normpath(os.path.join(resourceutil.datapath, b'templates')) |
|
1048 | path = os.path.normpath(os.path.join(resourceutil.datapath, b'templates')) | |
1051 |
return |
|
1049 | return path if os.path.isdir(path) else None | |
1052 |
|
1050 | |||
1053 |
|
1051 | |||
1054 | def templatepath(name): |
|
1052 | def templatepath(name): | |
1055 | '''return location of template file. returns None if not found.''' |
|
1053 | '''return location of template file. returns None if not found.''' | |
1056 | for p in templatepaths(): |
|
1054 | f = os.path.join(templatedir(), name) | |
1057 | f = os.path.join(p, name) |
|
1055 | if f and os.path.exists(f): | |
1058 | if os.path.exists(f): |
|
1056 | return f | |
1059 | return f |
|
|||
1060 | return None |
|
1057 | return None | |
1061 |
|
1058 | |||
1062 |
|
1059 | |||
@@ -1070,7 +1067,7 b' def stylemap(styles, paths=None):' | |||||
1070 | """ |
|
1067 | """ | |
1071 |
|
1068 | |||
1072 | if paths is None: |
|
1069 | if paths is None: | |
1073 |
paths = template |
|
1070 | paths = [templatedir()] | |
1074 | elif isinstance(paths, bytes): |
|
1071 | elif isinstance(paths, bytes): | |
1075 | paths = [paths] |
|
1072 | paths = [paths] | |
1076 |
|
1073 |
General Comments 0
You need to be logged in to leave comments.
Login now