Patchwork [3,of,3] template: Change extras to use showlist rather than manual templ call

login
register
mail settings
Submitter Matthew Turk
Date Nov. 15, 2013, 10:52 p.m.
Message ID <47549382f99bd0b753f8.1384555977@ridcully>
Download mbox | patch
Permalink /patch/2954/
State Superseded
Headers show

Comments

Matthew Turk - Nov. 15, 2013, 10:52 p.m.
# HG changeset patch
# User Matthew Turk <matthewturk@gmail.com>
# Date 1384555377 18000
#      Fri Nov 15 17:42:57 2013 -0500
# Node ID 47549382f99bd0b753f8ce7d787050d32f4890f5
# Parent  b78c4813b053fd84eaf19b0df289d96d67e25b48
template: Change extras to use showlist rather than manual templ call.

This enables start_extras and end_extras in template maps.
Sean Farley - Nov. 15, 2013, 11:07 p.m.
matthewturk@gmail.com writes:

> # HG changeset patch
> # User Matthew Turk <matthewturk@gmail.com>
> # Date 1384555377 18000
> #      Fri Nov 15 17:42:57 2013 -0500
> # Node ID 47549382f99bd0b753f8ce7d787050d32f4890f5
> # Parent  b78c4813b053fd84eaf19b0df289d96d67e25b48
> template: Change extras to use showlist rather than manual templ call.

Another bad capitalized 'Change' but this patch looks good otherwise.

> This enables start_extras and end_extras in template maps.
>
> diff -r b78c4813b053 -r 47549382f99b mercurial/templatekw.py
> --- a/mercurial/templatekw.py	Fri Nov 15 17:14:02 2013 -0500
> +++ b/mercurial/templatekw.py	Fri Nov 15 17:42:57 2013 -0500
> @@ -221,11 +221,8 @@
>  def showextras(**args):
>      """:extras: List of dicts with key, value entries of the 'extras'
>      field of this changeset."""
> -    templ = args['templ']
> -    for key, value in sorted(args['ctx'].extra().items()):
> -        args = args.copy()
> -        args.update(dict(key=key, value=value))
> -        yield templ('extra', **args)
> +    yield showlist('extra', sorted(dict(key=a, value=b)
> +                   for (a, b) in args['ctx'].extra().items()), **args)
>  
>  def showfileadds(**args):
>      """:file_adds: List of strings. Files added by this changeset."""
> _______________________________________________
> Mercurial-devel mailing list
> Mercurial-devel@selenic.com
> http://selenic.com/mailman/listinfo/mercurial-devel

Patch

diff -r b78c4813b053 -r 47549382f99b mercurial/templatekw.py
--- a/mercurial/templatekw.py	Fri Nov 15 17:14:02 2013 -0500
+++ b/mercurial/templatekw.py	Fri Nov 15 17:42:57 2013 -0500
@@ -221,11 +221,8 @@ 
 def showextras(**args):
     """:extras: List of dicts with key, value entries of the 'extras'
     field of this changeset."""
-    templ = args['templ']
-    for key, value in sorted(args['ctx'].extra().items()):
-        args = args.copy()
-        args.update(dict(key=key, value=value))
-        yield templ('extra', **args)
+    yield showlist('extra', sorted(dict(key=a, value=b)
+                   for (a, b) in args['ctx'].extra().items()), **args)
 
 def showfileadds(**args):
     """:file_adds: List of strings. Files added by this changeset."""