# HG changeset patch # User Boris Feld # Date 1496052947 -7200 # Node ID 2092007af2058a7306d54205c16a578a0a1ec979 # Parent 8abc7066e38405f1740f5f0e048b0c929b8bda26 template: update precursors template output Use templatekw._hybrid as return value for precursor template, it's nicer and easier to play with than returning a formatted string. diff -r 8abc7066e384 -r 2092007af205 hgext3rd/evolve/templatekw.py --- a/hgext3rd/evolve/templatekw.py Mon May 29 17:16:15 2017 +0200 +++ b/hgext3rd/evolve/templatekw.py Mon May 29 12:15:47 2017 +0200 @@ -64,17 +64,13 @@ stack.append(precnodeid) @eh.templatekw("precursors") -def shownextvisibleprecursors(repo, ctx, templ, **args): +def shownextvisibleprecursors(repo, ctx, **args): """Returns a string containing the list if the closest successors displayed """ - # XXX-review: I've added a couple of 'XXX' for future work. - - # XXX: template logic supports lists, so we should more to using a list at some point - - # XXX: I think we could returns something close to a "changectx" that would allow template to alter the way we render this. - shortnodes = map(node.short, sorted(closestprecursors(repo, ctx.node()))) - return ', '.join(shortnodes) + precursors = sorted(closestprecursors(repo, ctx.node())) + return templatekw._hybrid(None, precursors, lambda x: {'precursor': x}, + lambda d: "%s" % node.short(d['precursor'])) def closestsuccessors(repo, nodeid): """ returns the closest visible successors sets instead. diff -r 8abc7066e384 -r 2092007af205 tests/test-evolve-templates.t --- a/tests/test-evolve-templates.t Mon May 29 17:16:15 2017 +0200 +++ b/tests/test-evolve-templates.t Mon May 29 12:15:47 2017 +0200 @@ -14,6 +14,7 @@ > [alias] > tlog = log -G -T '{node|short}\ > {if(precursors, "\n Precursors: {precursors}")}\ + > {if(precursors, "\n semi-colon: {join(precursors, "; ")}")}\ > {if(successors, "\n Successors: {successors}")}\ > {if(successors, "\n Fate: {obsfate_quiet}")}\n' > EOF @@ -71,6 +72,7 @@ $ hg tlog o d004c8f274b9 | Precursors: 471f378eab4c + | semi-colon: 471f378eab4c | @ 471f378eab4c |/ Successors: [d004c8f274b9] | Fate: superseed as d004c8f274b9 @@ -85,6 +87,7 @@ $ hg tlog o d004c8f274b9 | Precursors: a468dc9b3633 + | semi-colon: a468dc9b3633 | @ a468dc9b3633 |/ Successors: [d004c8f274b9] | Fate: superseed as d004c8f274b9 @@ -95,8 +98,10 @@ $ hg tlog --hidden o d004c8f274b9 | Precursors: a468dc9b3633 + | semi-colon: a468dc9b3633 | @ a468dc9b3633 |/ Precursors: 471f378eab4c + | semi-colon: 471f378eab4c | Successors: [d004c8f274b9] | Fate: superseed as d004c8f274b9 | x f137d23bb3e1 @@ -117,8 +122,10 @@ $ hg tlog --hidden @ d004c8f274b9 | Precursors: a468dc9b3633 + | semi-colon: a468dc9b3633 | x a468dc9b3633 |/ Precursors: 471f378eab4c + | semi-colon: 471f378eab4c | Successors: [d004c8f274b9] | Fate: superseed as d004c8f274b9 | x f137d23bb3e1 @@ -223,8 +230,10 @@ $ hg tlog o f257fde29c7a | Precursors: 471597cad322 + | semi-colon: 471597cad322 o 337fec4d2edc | Precursors: 471597cad322 + | semi-colon: 471597cad322 | @ 471597cad322 |/ Successors: [337fec4d2edc, f257fde29c7a] | Fate: superseed as 337fec4d2edc,f257fde29c7a @@ -247,8 +256,10 @@ $ hg tlog --hidden @ f257fde29c7a | Precursors: 471597cad322 + | semi-colon: 471597cad322 o 337fec4d2edc | Precursors: 471597cad322 + | semi-colon: 471597cad322 | x 471597cad322 |/ Successors: [337fec4d2edc, f257fde29c7a] | Fate: superseed as 337fec4d2edc,f257fde29c7a @@ -320,6 +331,7 @@ $ hg tlog o eb5a0daa2192 | Precursors: 471f378eab4c + | semi-colon: 471f378eab4c | @ 471f378eab4c |/ Successors: [eb5a0daa2192] | Fate: superseed as eb5a0daa2192 @@ -334,7 +346,8 @@ displayed $ hg tlog o eb5a0daa2192 - | Precursors: 0dec01379d3b, 471f378eab4c + | Precursors: 0dec01379d3b 471f378eab4c + | semi-colon: 0dec01379d3b; 471f378eab4c | @ 0dec01379d3b | | Successors: [eb5a0daa2192] | | Fate: superseed as eb5a0daa2192 @@ -357,7 +370,8 @@ --hidden $ hg tlog --hidden @ eb5a0daa2192 - | Precursors: 0dec01379d3b, 471f378eab4c + | Precursors: 0dec01379d3b 471f378eab4c + | semi-colon: 0dec01379d3b; 471f378eab4c | x 0dec01379d3b | | Successors: [eb5a0daa2192] | | Fate: superseed as eb5a0daa2192 @@ -442,8 +456,10 @@ $ hg tlog o 019fadeab383 | Precursors: 471f378eab4c + | semi-colon: 471f378eab4c | o fdf9bde5129a |/ Precursors: 471f378eab4c + | semi-colon: 471f378eab4c | @ 471f378eab4c |/ Successors: [fdf9bde5129a], [019fadeab383] | Fate: superseed as fdf9bde5129a + superseed as 019fadeab383 @@ -464,12 +480,15 @@ $ hg tlog --hidden o 019fadeab383 | Precursors: 65b757b745b9 + | semi-colon: 65b757b745b9 | x 65b757b745b9 |/ Precursors: 471f378eab4c + | semi-colon: 471f378eab4c | Successors: [019fadeab383] | Fate: superseed as 019fadeab383 | @ fdf9bde5129a |/ Precursors: 471f378eab4c + | semi-colon: 471f378eab4c | x 471f378eab4c |/ Successors: [fdf9bde5129a], [65b757b745b9] | Fate: superseed as fdf9bde5129a + superseed as 65b757b745b9 @@ -552,6 +571,7 @@ $ hg tlog o eb5a0daa2192 | Precursors: 471f378eab4c + | semi-colon: 471f378eab4c | @ 471f378eab4c |/ Successors: [eb5a0daa2192] | Fate: superseed as eb5a0daa2192 @@ -563,7 +583,8 @@ (use 'hg evolve' to update to its successor: eb5a0daa2192) $ hg tlog o eb5a0daa2192 - | Precursors: 0dec01379d3b, 471f378eab4c + | Precursors: 0dec01379d3b 471f378eab4c + | semi-colon: 0dec01379d3b; 471f378eab4c | @ 0dec01379d3b | | Successors: [eb5a0daa2192] | | Fate: superseed as eb5a0daa2192 @@ -578,7 +599,8 @@ (use 'hg evolve' to update to its successor: eb5a0daa2192) $ hg tlog o eb5a0daa2192 - | Precursors: 471f378eab4c, b7ea6d14e664 + | Precursors: 471f378eab4c b7ea6d14e664 + | semi-colon: 471f378eab4c; b7ea6d14e664 | @ b7ea6d14e664 | | Successors: [eb5a0daa2192] | | Fate: superseed as eb5a0daa2192 @@ -596,9 +618,11 @@ $ hg tlog --hidden @ eb5a0daa2192 - | Precursors: 471f378eab4c, b7ea6d14e664 + | Precursors: 471f378eab4c b7ea6d14e664 + | semi-colon: 471f378eab4c; b7ea6d14e664 | x b7ea6d14e664 | | Precursors: 0dec01379d3b + | | semi-colon: 0dec01379d3b | | Successors: [eb5a0daa2192] | | Fate: superseed as eb5a0daa2192 | | x 0dec01379d3b @@ -700,6 +724,7 @@ $ hg tlog o 7a230b46bf61 | Precursors: 471f378eab4c + | semi-colon: 471f378eab4c | @ 471f378eab4c |/ Successors: [7a230b46bf61] | Fate: superseed as 7a230b46bf61 @@ -715,6 +740,7 @@ $ hg tlog --hidden @ 7a230b46bf61 | Precursors: 471f378eab4c + | semi-colon: 471f378eab4c | x 471f378eab4c |/ Successors: [7a230b46bf61] | Fate: superseed as 7a230b46bf61