##// END OF EJS Templates
templatefilters: remove redundant 'date' and 'strip' filters...
Yuya Nishihara -
r26106:c568c4db default
parent child Browse files
Show More
@@ -81,12 +81,6 b' def count(i):'
81 """:count: List or text. Returns the length as an integer."""
81 """:count: List or text. Returns the length as an integer."""
82 return len(i)
82 return len(i)
83
83
84 def datefilter(text):
85 """:date: Date. Returns a date in a Unix date format, including the
86 timezone: "Mon Sep 04 15:13:13 2006 0700".
87 """
88 return util.datestr(text)
89
90 def domain(author):
84 def domain(author):
91 """:domain: Any text. Finds the first string that looks like an email
85 """:domain: Any text. Finds the first string that looks like an email
92 address, and extracts just the domain component. Example: ``User
86 address, and extracts just the domain component. Example: ``User
@@ -348,10 +342,6 b' def stringify(thing):'
348 return ""
342 return ""
349 return str(thing)
343 return str(thing)
350
344
351 def strip(text):
352 """:strip: Any text. Strips all leading and trailing whitespace."""
353 return text.strip()
354
355 def stripdir(text):
345 def stripdir(text):
356 """:stripdir: Treat the text as path and strip a directory level, if
346 """:stripdir: Treat the text as path and strip a directory level, if
357 possible. For example, "foo" and "foo/bar" becomes "foo".
347 possible. For example, "foo" and "foo/bar" becomes "foo".
@@ -401,7 +391,6 b' filters = {'
401 "age": age,
391 "age": age,
402 "basename": basename,
392 "basename": basename,
403 "count": count,
393 "count": count,
404 "date": datefilter,
405 "domain": domain,
394 "domain": domain,
406 "email": email,
395 "email": email,
407 "escape": escape,
396 "escape": escape,
@@ -429,7 +418,6 b' filters = {'
429 "splitlines": splitlines,
418 "splitlines": splitlines,
430 "stringescape": stringescape,
419 "stringescape": stringescape,
431 "stringify": stringify,
420 "stringify": stringify,
432 "strip": strip,
433 "stripdir": stripdir,
421 "stripdir": stripdir,
434 "tabindent": tabindent,
422 "tabindent": tabindent,
435 "upper": upper,
423 "upper": upper,
@@ -313,7 +313,8 b' def buildfunc(exp, context):'
313
313
314 def date(context, mapping, args):
314 def date(context, mapping, args):
315 """:date(date[, fmt]): Format a date. See :hg:`help dates` for formatting
315 """:date(date[, fmt]): Format a date. See :hg:`help dates` for formatting
316 strings."""
316 strings. The default is a Unix date format, including the timezone:
317 "Mon Sep 04 15:13:13 2006 0700"."""
317 if not (1 <= len(args) <= 2):
318 if not (1 <= len(args) <= 2):
318 # i18n: "date" is a keyword
319 # i18n: "date" is a keyword
319 raise error.ParseError(_("date expects one or two arguments"))
320 raise error.ParseError(_("date expects one or two arguments"))
@@ -604,7 +605,8 b' def shortest(context, mapping, args):'
604 return shortest
605 return shortest
605
606
606 def strip(context, mapping, args):
607 def strip(context, mapping, args):
607 """:strip(text[, chars]): Strip characters from a string."""
608 """:strip(text[, chars]): Strip characters from a string. By default,
609 strips all leading and trailing whitespace."""
608 if not (1 <= len(args) <= 2):
610 if not (1 <= len(args) <= 2):
609 # i18n: "strip" is a keyword
611 # i18n: "strip" is a keyword
610 raise error.ParseError(_("strip expects one or two arguments"))
612 raise error.ParseError(_("strip expects one or two arguments"))
@@ -2498,7 +2498,7 b' Behind the scenes, this will throw Attri'
2498 Behind the scenes, this will throw ValueError
2498 Behind the scenes, this will throw ValueError
2499
2499
2500 $ hg tip --template '{author|email|date}\n'
2500 $ hg tip --template '{author|email|date}\n'
2501 abort: template filter 'datefilter' is not compatible with keyword 'author'
2501 hg: parse error: date expects a date information
2502 [255]
2502 [255]
2503
2503
2504 Error in nested template:
2504 Error in nested template:
General Comments 0
You need to be logged in to leave comments. Login now