Mercurial > hg > mercurial-source
diff mercurial/templater.py @ 25191:09124cce913f stable
templater: fix crash by passing invalid object to date() function
"date information" is somewhat obscure, but we call it that way in
templatekw.showdate().
author | Yuya Nishihara <yuya@tcha.org> |
---|---|
date | Sun, 03 May 2015 17:33:14 +0900 |
parents | 10a13da8840d |
children | df59a9be0d21 8e4947af3fe5 db7463aa080f |
line wrap: on
line diff
--- a/mercurial/templater.py +++ b/mercurial/templater.py @@ -226,10 +226,17 @@ raise error.ParseError(_("date expects one or two arguments")) date = args[0][0](context, mapping, args[0][1]) + fmt = None if len(args) == 2: fmt = stringify(args[1][0](context, mapping, args[1][1])) - return util.datestr(date, fmt) - return util.datestr(date) + try: + if fmt is None: + return util.datestr(date) + else: + return util.datestr(date, fmt) + except (TypeError, ValueError): + # i18n: "date" is a keyword + raise error.ParseError(_("date expects a date information")) def diff(context, mapping, args): """:diff([includepattern [, excludepattern]]): Show a diff, optionally