Mercurial > public > mercurial-scm > hg
comparison hgext/patchbomb.py @ 45264:8cce9f77ca73
templatespec: create a factory function for each type there is
Most of the arguments to the `templatespec` constructor are mutually
exclusive, so each combination creates a different type of
templatespec. Let's clarify that by creating factory functions.
I've left the callers in `logcmdutil` unchanged for now because they
are more complex and `logcmdutil.templatespec()` is slightly higher
level in that it is specific to changesets.
My larger goal is to add support frozen binaries (specifically
PyOxidizer) by adding a specific type of `templatespec` for built-in
templates. That will get its own factory function.
Differential Revision: https://phab.mercurial-scm.org/D8845
author | Martin von Zweigbergk <martinvonz@google.com> |
---|---|
date | Thu, 16 Jul 2020 13:33:46 -0700 |
parents | 3781da40eaa6 |
children | 89a2afe31e82 |
comparison
equal
deleted
inserted
replaced
45263:b7444cfc2c05 | 45264:8cce9f77ca73 |
---|---|
205 """build flag string optionally by template""" | 205 """build flag string optionally by template""" |
206 tmpl = ui.config(b'patchbomb', b'flagtemplate') | 206 tmpl = ui.config(b'patchbomb', b'flagtemplate') |
207 if not tmpl: | 207 if not tmpl: |
208 return b' '.join(flags) | 208 return b' '.join(flags) |
209 out = util.stringio() | 209 out = util.stringio() |
210 spec = formatter.templatespec(b'', templater.unquotestring(tmpl), None) | 210 spec = formatter.literal_templatespec(templater.unquotestring(tmpl)) |
211 with formatter.templateformatter(ui, out, b'patchbombflag', {}, spec) as fm: | 211 with formatter.templateformatter(ui, out, b'patchbombflag', {}, spec) as fm: |
212 fm.startitem() | 212 fm.startitem() |
213 fm.context(ctx=repo[rev]) | 213 fm.context(ctx=repo[rev]) |
214 fm.write(b'flags', b'%s', fm.formatlist(flags, name=b'flag')) | 214 fm.write(b'flags', b'%s', fm.formatlist(flags, name=b'flag')) |
215 return out.getvalue() | 215 return out.getvalue() |