[PATCH V5] templater: introduce indent function
Yuya Nishihara
yuya at tcha.org
Sat Jun 6 08:20:25 CDT 2015
On Fri, 5 Jun 2015 17:16:08 -0700, Ryan McElroy wrote:
> # HG changeset patch
> # User Ryan McElroy <rmcelroy at fb.com>
> # Date 1428134632 25200
> # Sat Apr 04 01:03:52 2015 -0700
> # Node ID 8e77e317b0c651b9cbd9bee054f9b9a7d6912c1e
> # Parent c39640d26a4c7546faef00b9e5c02af45ab8bf5e
> templater: introduce indent function
>
> diff --git a/mercurial/templater.py b/mercurial/templater.py
> --- a/mercurial/templater.py
> +++ b/mercurial/templater.py
> @@ -327,6 +327,30 @@ def pad(context, mapping, args):
> else:
> return text.ljust(width, fillchar)
>
> +def indent(context, mapping, args):
> + """
> + :indent(text, indentchars, firstline): Indents all non-empty lines
> + with the characters given in the indentchars string. An optional
> + third parameter will override the indent for the first line only
> + if present.
> +
> + Example: indent('hello\\n\\nworld', ' ', '> ') == "> hello\\n\\n world"
> + """
> + if 2 > len(args) > 3:
> + # i18n: "indent" is a keyword
> + raise error.ParseError(_("indent() expects two or three arguments"))
It will never be True, should be "not (2 <= len(args) <= 3)".
https://docs.python.org/2/reference/expressions.html#not-in
More information about the Mercurial-devel
mailing list