From patchwork Tue Aug 25 14:13:01 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: [3, of, 3] templatefilters: remove redundant 'date' and 'strip' filters From: Yuya Nishihara X-Patchwork-Id: 10272 Message-Id: To: mercurial-devel@selenic.com Date: Tue, 25 Aug 2015 23:13:01 +0900 # HG changeset patch # User Yuya Nishihara # Date 1435993662 -32400 # Sat Jul 04 16:07:42 2015 +0900 # Node ID ec8901eb6255b57d51b165eadcd6afcd1455fd21 # Parent 072f8e2e919778a783a8548fe303910bb485c397 templatefilters: remove redundant 'date' and 'strip' filters These filters are defined as 'date()' and 'strip()' functions. Help messages are moved to the corresponding functions. diff --git a/mercurial/templatefilters.py b/mercurial/templatefilters.py --- a/mercurial/templatefilters.py +++ b/mercurial/templatefilters.py @@ -81,12 +81,6 @@ def count(i): """:count: List or text. Returns the length as an integer.""" return len(i) -def datefilter(text): - """:date: Date. Returns a date in a Unix date format, including the - timezone: "Mon Sep 04 15:13:13 2006 0700". - """ - return util.datestr(text) - def domain(author): """:domain: Any text. Finds the first string that looks like an email address, and extracts just the domain component. Example: ``User @@ -348,10 +342,6 @@ def stringify(thing): return "" return str(thing) -def strip(text): - """:strip: Any text. Strips all leading and trailing whitespace.""" - return text.strip() - def stripdir(text): """:stripdir: Treat the text as path and strip a directory level, if possible. For example, "foo" and "foo/bar" becomes "foo". @@ -401,7 +391,6 @@ filters = { "age": age, "basename": basename, "count": count, - "date": datefilter, "domain": domain, "email": email, "escape": escape, @@ -429,7 +418,6 @@ filters = { "splitlines": splitlines, "stringescape": stringescape, "stringify": stringify, - "strip": strip, "stripdir": stripdir, "tabindent": tabindent, "upper": upper, diff --git a/mercurial/templater.py b/mercurial/templater.py --- a/mercurial/templater.py +++ b/mercurial/templater.py @@ -313,7 +313,8 @@ def buildfunc(exp, context): def date(context, mapping, args): """:date(date[, fmt]): Format a date. See :hg:`help dates` for formatting - strings.""" + strings. The default is a Unix date format, including the timezone: + "Mon Sep 04 15:13:13 2006 0700".""" if not (1 <= len(args) <= 2): # i18n: "date" is a keyword raise error.ParseError(_("date expects one or two arguments")) @@ -604,7 +605,8 @@ def shortest(context, mapping, args): return shortest def strip(context, mapping, args): - """:strip(text[, chars]): Strip characters from a string.""" + """:strip(text[, chars]): Strip characters from a string. By default, + strips all leading and trailing whitespace.""" if not (1 <= len(args) <= 2): # i18n: "strip" is a keyword raise error.ParseError(_("strip expects one or two arguments")) diff --git a/tests/test-command-template.t b/tests/test-command-template.t --- a/tests/test-command-template.t +++ b/tests/test-command-template.t @@ -2498,7 +2498,7 @@ Behind the scenes, this will throw Attri Behind the scenes, this will throw ValueError $ hg tip --template '{author|email|date}\n' - abort: template filter 'datefilter' is not compatible with keyword 'author' + hg: parse error: date expects a date information [255] Error in nested template: