comparison mercurial/hgweb/hgweb_mod.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 1a4f925f72c3
children d2e1dcd4490d
comparison
equal deleted inserted replaced
45319:6e6fe826ba69 45320:4aa484efc926
76 ): 76 ):
77 continue 77 continue
78 locations = (os.path.join(style, b'map'), b'map-' + style, b'map') 78 locations = (os.path.join(style, b'map'), b'map-' + style, b'map')
79 79
80 for location in locations: 80 for location in locations:
81 mapfile, fp = templater.open_template(location, path) 81 mapfile, fp = templater.try_open_template(location, path)
82 if mapfile: 82 if mapfile:
83 return style, mapfile, fp 83 return style, mapfile, fp
84 84
85 raise RuntimeError(b"No hgweb templates found in %r" % path) 85 raise RuntimeError(b"No hgweb templates found in %r" % path)
86 86