Mercurial > public > mercurial-scm > hg
comparison mercurial/templateutil.py @ 37225:e70a90a72b80
templatefuncs: use evaldate() where seems appropriate
This means date("today") is allowed.
Also fixes evaldate() to forcibly use the custom error message if specified.
author | Yuya Nishihara <yuya@tcha.org> |
---|---|
date | Sun, 18 Mar 2018 15:58:22 +0900 |
parents | 67efce231633 |
children | 920589f52be9 |
comparison
equal
deleted
inserted
replaced
37224:67efce231633 | 37225:e70a90a72b80 |
---|---|
328 thing = _unwrapvalue(thing) | 328 thing = _unwrapvalue(thing) |
329 try: | 329 try: |
330 return dateutil.parsedate(thing) | 330 return dateutil.parsedate(thing) |
331 except AttributeError: | 331 except AttributeError: |
332 raise error.ParseError(err or _('not a date tuple nor a string')) | 332 raise error.ParseError(err or _('not a date tuple nor a string')) |
333 except error.ParseError: | |
334 if not err: | |
335 raise | |
336 raise error.ParseError(err) | |
333 | 337 |
334 def evalinteger(context, mapping, arg, err=None): | 338 def evalinteger(context, mapping, arg, err=None): |
335 return unwrapinteger(evalrawexp(context, mapping, arg), err) | 339 return unwrapinteger(evalrawexp(context, mapping, arg), err) |
336 | 340 |
337 def unwrapinteger(thing, err=None): | 341 def unwrapinteger(thing, err=None): |