mercurial/templater.py
branchstable
changeset 24903 09124cce913f
parent 24886 10a13da8840d
child 24948 db7463aa080f
equal deleted inserted replaced
24902:986a5c23b1c1 24903:09124cce913f
   224     if not (1 <= len(args) <= 2):
   224     if not (1 <= len(args) <= 2):
   225         # i18n: "date" is a keyword
   225         # i18n: "date" is a keyword
   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
   236     specifying files to include or exclude."""
   243     specifying files to include or exclude."""
   237     if len(args) > 2:
   244     if len(args) > 2: