comparison mercurial/formatter.py @ 45320:4aa484efc926

templater: add exception-raising version of open_template() I'm about to add another caller of `open_template()` (in the template loader). That caller will want to get exceptions instead of `(None, None)` if the template doesn't exist. This patch therefore changes `open_template()` to raise exceptions and adds a new `try_open_template()` that returns the `(None, None)` value. Differential Revision: https://phab.mercurial-scm.org/D8905
author Martin von Zweigbergk <martinvonz@google.com>
date Thu, 06 Aug 2020 09:50:10 -0700
parents f3481e4fcc3a
children 67a2ecea8bd9
comparison
equal deleted inserted replaced
45319:6e6fe826ba69 45320:4aa484efc926
598 templater.parseexpr(tmpl) # make sure syntax errors are confined 598 templater.parseexpr(tmpl) # make sure syntax errors are confined
599 return reference_templatespec(func, refargs=ftail[:-1]) 599 return reference_templatespec(func, refargs=ftail[:-1])
600 600
601 # perhaps a stock style? 601 # perhaps a stock style?
602 if not os.path.split(tmpl)[0]: 602 if not os.path.split(tmpl)[0]:
603 (mapname, fp) = templater.open_template( 603 (mapname, fp) = templater.try_open_template(
604 b'map-cmdline.' + tmpl 604 b'map-cmdline.' + tmpl
605 ) or templater.open_template(tmpl) 605 ) or templater.try_open_template(tmpl)
606 if mapname: 606 if mapname:
607 return mapfile_templatespec(topic, mapname, fp) 607 return mapfile_templatespec(topic, mapname, fp)
608 608
609 # perhaps it's a reference to [templates] 609 # perhaps it's a reference to [templates]
610 if ui.config(b'templates', tmpl): 610 if ui.config(b'templates', tmpl):