Mercurial > public > mercurial-scm > hg
comparison mercurial/formatter.py @ 45309:65a812ed9e9f
templater: replace templatepath() with function that also opens the file
For frozen binaries, such as those created by PyOxidizer, I plan to
make it so the templatespec can keep an opened file/resource to read
from instead of needing a file path. Having `templatepath()` return an
opened file should help with that. At this point, it's just a wasteful
extra opening of mapfiles that we'll open again later. I'll update the
read-side next so it reads from the file-like object without opening
the file again.
Differential Revision: https://phab.mercurial-scm.org/D8892
author | Martin von Zweigbergk <martinvonz@google.com> |
---|---|
date | Tue, 04 Aug 2020 13:21:29 -0700 |
parents | 215f08c8006c |
children | f3481e4fcc3a |
comparison
equal
deleted
inserted
replaced
45308:dc10bcd5c08d | 45309:65a812ed9e9f |
---|---|
597 templater.parseexpr(tmpl) # make sure syntax errors are confined | 597 templater.parseexpr(tmpl) # make sure syntax errors are confined |
598 return reference_templatespec(func, refargs=ftail[:-1]) | 598 return reference_templatespec(func, refargs=ftail[:-1]) |
599 | 599 |
600 # perhaps a stock style? | 600 # perhaps a stock style? |
601 if not os.path.split(tmpl)[0]: | 601 if not os.path.split(tmpl)[0]: |
602 mapname = templater.templatepath( | 602 (mapname, fp) = templater.open_template( |
603 b'map-cmdline.' + tmpl | 603 b'map-cmdline.' + tmpl |
604 ) or templater.templatepath(tmpl) | 604 ) or templater.open_template(tmpl) |
605 if mapname: | 605 if mapname: |
606 return mapfile_templatespec(topic, mapname) | 606 return mapfile_templatespec(topic, mapname) |
607 | 607 |
608 # perhaps it's a reference to [templates] | 608 # perhaps it's a reference to [templates] |
609 if ui.config(b'templates', tmpl): | 609 if ui.config(b'templates', tmpl): |