Patchwork [4,of,4] templater: make date() use helper function to evaluate argument

login
register
mail settings
Submitter Yuya Nishihara
Date March 2, 2016, 3:35 p.m.
Message ID <df8d4064c60de72b2204.1456932904@mimosa>
Download mbox | patch
Permalink /patch/13537/
State Accepted
Headers show

Comments

Yuya Nishihara - March 2, 2016, 3:35 p.m.
# HG changeset patch
# User Yuya Nishihara <yuya@tcha.org>
# Date 1455424610 -32400
#      Sun Feb 14 13:36:50 2016 +0900
# Node ID df8d4064c60de72b2204c714917f835ac0266270
# Parent  93252935f1b4490e6061865c45245173855bfb02
templater: make date() use helper function to evaluate argument

A date argument should never be a generator, but using evalfuncarg() should
be good for consistency.
Sean Farley - March 2, 2016, 10:30 p.m.
Yuya Nishihara <yuya@tcha.org> writes:

> # HG changeset patch
> # User Yuya Nishihara <yuya@tcha.org>
> # Date 1455424610 -32400
> #      Sun Feb 14 13:36:50 2016 +0900
> # Node ID df8d4064c60de72b2204c714917f835ac0266270
> # Parent  93252935f1b4490e6061865c45245173855bfb02
> templater: make date() use helper function to evaluate argument
>
> A date argument should never be a generator, but using evalfuncarg() should
> be good for consistency.

This series looks good to me. Thanks for the tests, too!
Yuya Nishihara - March 4, 2016, 2:16 p.m.
On Wed, 02 Mar 2016 14:30:53 -0800, Sean Farley wrote:
> Yuya Nishihara <yuya@tcha.org> writes:
> > # HG changeset patch
> > # User Yuya Nishihara <yuya@tcha.org>
> > # Date 1455424610 -32400
> > #      Sun Feb 14 13:36:50 2016 +0900
> > # Node ID df8d4064c60de72b2204c714917f835ac0266270
> > # Parent  93252935f1b4490e6061865c45245173855bfb02
> > templater: make date() use helper function to evaluate argument
> >
> > A date argument should never be a generator, but using evalfuncarg() should
> > be good for consistency.
> 
> This series looks good to me. Thanks for the tests, too!

Thanks. I'm sure these patches are trivial bug fixes, so queued by myself.

Patch

diff --git a/mercurial/templater.py b/mercurial/templater.py
--- a/mercurial/templater.py
+++ b/mercurial/templater.py
@@ -329,7 +329,7 @@  def date(context, mapping, args):
         # i18n: "date" is a keyword
         raise error.ParseError(_("date expects one or two arguments"))
 
-    date = args[0][0](context, mapping, args[0][1])
+    date = evalfuncarg(context, mapping, args[0])
     fmt = None
     if len(args) == 2:
         fmt = stringify(args[1][0](context, mapping, args[1][1]))