Show More
@@ -226,10 +226,17 b' def date(context, mapping, args):' | |||||
226 | raise error.ParseError(_("date expects one or two arguments")) |
|
226 | raise error.ParseError(_("date expects one or two arguments")) | |
227 |
|
227 | |||
228 | date = args[0][0](context, mapping, args[0][1]) |
|
228 | date = args[0][0](context, mapping, args[0][1]) | |
|
229 | fmt = None | |||
229 | if len(args) == 2: |
|
230 | if len(args) == 2: | |
230 | fmt = stringify(args[1][0](context, mapping, args[1][1])) |
|
231 | fmt = stringify(args[1][0](context, mapping, args[1][1])) | |
231 | return util.datestr(date, fmt) |
|
232 | try: | |
232 | return util.datestr(date) |
|
233 | if fmt is None: | |
|
234 | return util.datestr(date) | |||
|
235 | else: | |||
|
236 | return util.datestr(date, fmt) | |||
|
237 | except (TypeError, ValueError): | |||
|
238 | # i18n: "date" is a keyword | |||
|
239 | raise error.ParseError(_("date expects a date information")) | |||
233 |
|
240 | |||
234 | def diff(context, mapping, args): |
|
241 | def diff(context, mapping, args): | |
235 | """:diff([includepattern [, excludepattern]]): Show a diff, optionally |
|
242 | """:diff([includepattern [, excludepattern]]): Show a diff, optionally |
@@ -2236,6 +2236,12 b' Test date format:' | |||||
2236 | date: 70 01 01 01 +0000 |
|
2236 | date: 70 01 01 01 +0000 | |
2237 | date: 70 01 01 00 +0000 |
|
2237 | date: 70 01 01 00 +0000 | |
2238 |
|
2238 | |||
|
2239 | Test invalid date: | |||
|
2240 | ||||
|
2241 | $ hg log -R latesttag -T '{date(rev)}\n' | |||
|
2242 | hg: parse error: date expects a date information | |||
|
2243 | [255] | |||
|
2244 | ||||
2239 | Test string escaping: |
|
2245 | Test string escaping: | |
2240 |
|
2246 | |||
2241 | $ hg log -R latesttag -r 0 --template '>\n<>\\n<{if(rev, "[>\n<>\\n<]")}>\n<>\\n<\n' |
|
2247 | $ hg log -R latesttag -r 0 --template '>\n<>\\n<{if(rev, "[>\n<>\\n<]")}>\n<>\\n<\n' |
General Comments 0
You need to be logged in to leave comments.
Login now