# HG changeset patch # User Boris Feld # Date 1496059411 -7200 # Node ID d5db7464676d3a82e8b632704edbdcb1e2a84ea2 # Parent 67be110640779ba7bad6ab0152d7e8be56ffe2ec template: update successors 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 67be11064077 -r d5db7464676d hgext3rd/evolve/templatekw.py --- a/hgext3rd/evolve/templatekw.py Mon May 29 17:54:14 2017 +0200 +++ b/hgext3rd/evolve/templatekw.py Mon May 29 14:03:31 2017 +0200 @@ -87,11 +87,18 @@ ssets = closestsuccessors(repo, ctx.node()) - final = [] + data = [] + gen = [] for ss in ssets: - final.append('[%s]' % ', '.join(map(node.short, ss))) + subgen = '[%s]' % ', '.join(map(node.short, ss)) + gen.append(subgen) + h = templatekw._hybrid(subgen, ss, lambda x: {'successor': x}, + lambda d: "%s" % d["successor"]) + data.append(h) - return ', '.join(final) + gen = ', '.join(gen) + return templatekw._hybrid(gen, data, lambda x: {'successorset': x}, + lambda d: d["successorset"]) @eh.templatekw("obsfate_quiet") def showobsfate_quiet(repo, ctx, templ, **args): diff -r 67be11064077 -r d5db7464676d tests/test-evolve-templates.t --- a/tests/test-evolve-templates.t Mon May 29 17:54:14 2017 +0200 +++ b/tests/test-evolve-templates.t Mon May 29 14:03:31 2017 +0200 @@ -16,6 +16,7 @@ > {if(precursors, "\n Precursors: {precursors}")}\ > {if(precursors, "\n semi-colon: {join(precursors, "; ")}")}\ > {if(successors, "\n Successors: {successors}")}\ + > {if(successors, "\n semi-colon: {join(successors, "; ")}")}\ > {if(successors, "\n Fate: {obsfate_quiet}")}\n' > EOF @@ -75,6 +76,7 @@ | semi-colon: 471f378eab4c | @ 471f378eab4c |/ Successors: [d004c8f274b9] + | semi-colon: [d004c8f274b9] | Fate: superseed as d004c8f274b9 o ea207398892e @@ -90,6 +92,7 @@ | semi-colon: a468dc9b3633 | @ a468dc9b3633 |/ Successors: [d004c8f274b9] + | semi-colon: [d004c8f274b9] | Fate: superseed as d004c8f274b9 o ea207398892e @@ -103,11 +106,13 @@ |/ Precursors: 471f378eab4c | semi-colon: 471f378eab4c | Successors: [d004c8f274b9] + | semi-colon: [d004c8f274b9] | Fate: superseed as d004c8f274b9 | x f137d23bb3e1 | | | x 471f378eab4c |/ Successors: [a468dc9b3633] + | semi-colon: [a468dc9b3633] | Fate: superseed as a468dc9b3633 o ea207398892e @@ -127,11 +132,13 @@ |/ Precursors: 471f378eab4c | semi-colon: 471f378eab4c | Successors: [d004c8f274b9] + | semi-colon: [d004c8f274b9] | Fate: superseed as d004c8f274b9 | x f137d23bb3e1 | | | x 471f378eab4c |/ Successors: [a468dc9b3633] + | semi-colon: [a468dc9b3633] | Fate: superseed as a468dc9b3633 o ea207398892e @@ -236,6 +243,7 @@ | semi-colon: 471597cad322 | @ 471597cad322 |/ Successors: [337fec4d2edc, f257fde29c7a] + | semi-colon: [337fec4d2edc, f257fde29c7a] | Fate: superseed as 337fec4d2edc,f257fde29c7a o ea207398892e @@ -262,6 +270,7 @@ | semi-colon: 471597cad322 | x 471597cad322 |/ Successors: [337fec4d2edc, f257fde29c7a] + | semi-colon: [337fec4d2edc, f257fde29c7a] | Fate: superseed as 337fec4d2edc,f257fde29c7a o ea207398892e @@ -334,6 +343,7 @@ | semi-colon: 471f378eab4c | @ 471f378eab4c |/ Successors: [eb5a0daa2192] + | semi-colon: [eb5a0daa2192] | Fate: superseed as eb5a0daa2192 o ea207398892e @@ -350,9 +360,11 @@ | semi-colon: 0dec01379d3b; 471f378eab4c | @ 0dec01379d3b | | Successors: [eb5a0daa2192] + | | semi-colon: [eb5a0daa2192] | | Fate: superseed as eb5a0daa2192 | x 471f378eab4c |/ Successors: [eb5a0daa2192] + | semi-colon: [eb5a0daa2192] | Fate: superseed as eb5a0daa2192 o ea207398892e @@ -374,9 +386,11 @@ | semi-colon: 0dec01379d3b; 471f378eab4c | x 0dec01379d3b | | Successors: [eb5a0daa2192] + | | semi-colon: [eb5a0daa2192] | | Fate: superseed as eb5a0daa2192 | x 471f378eab4c |/ Successors: [eb5a0daa2192] + | semi-colon: [eb5a0daa2192] | Fate: superseed as eb5a0daa2192 o ea207398892e @@ -462,6 +476,7 @@ | semi-colon: 471f378eab4c | @ 471f378eab4c |/ Successors: [fdf9bde5129a], [019fadeab383] + | semi-colon: [fdf9bde5129a]; [019fadeab383] | Fate: superseed as fdf9bde5129a + superseed as 019fadeab383 o ea207398892e @@ -485,12 +500,14 @@ |/ Precursors: 471f378eab4c | semi-colon: 471f378eab4c | Successors: [019fadeab383] + | semi-colon: [019fadeab383] | Fate: superseed as 019fadeab383 | @ fdf9bde5129a |/ Precursors: 471f378eab4c | semi-colon: 471f378eab4c | x 471f378eab4c |/ Successors: [fdf9bde5129a], [65b757b745b9] + | semi-colon: [fdf9bde5129a]; [65b757b745b9] | Fate: superseed as fdf9bde5129a + superseed as 65b757b745b9 o ea207398892e @@ -574,6 +591,7 @@ | semi-colon: 471f378eab4c | @ 471f378eab4c |/ Successors: [eb5a0daa2192] + | semi-colon: [eb5a0daa2192] | Fate: superseed as eb5a0daa2192 o ea207398892e @@ -587,9 +605,11 @@ | semi-colon: 0dec01379d3b; 471f378eab4c | @ 0dec01379d3b | | Successors: [eb5a0daa2192] + | | semi-colon: [eb5a0daa2192] | | Fate: superseed as eb5a0daa2192 | x 471f378eab4c |/ Successors: [eb5a0daa2192] + | semi-colon: [eb5a0daa2192] | Fate: superseed as eb5a0daa2192 o ea207398892e @@ -603,9 +623,11 @@ | semi-colon: 471f378eab4c; b7ea6d14e664 | @ b7ea6d14e664 | | Successors: [eb5a0daa2192] + | | semi-colon: [eb5a0daa2192] | | Fate: superseed as eb5a0daa2192 | x 471f378eab4c |/ Successors: [eb5a0daa2192] + | semi-colon: [eb5a0daa2192] | Fate: superseed as eb5a0daa2192 o ea207398892e @@ -624,12 +646,15 @@ | | Precursors: 0dec01379d3b | | semi-colon: 0dec01379d3b | | Successors: [eb5a0daa2192] + | | semi-colon: [eb5a0daa2192] | | Fate: superseed as eb5a0daa2192 | | x 0dec01379d3b | |/ Successors: [b7ea6d14e664] + | | semi-colon: [b7ea6d14e664] | | Fate: superseed as b7ea6d14e664 | x 471f378eab4c |/ Successors: [eb5a0daa2192] + | semi-colon: [eb5a0daa2192] | Fate: superseed as eb5a0daa2192 o ea207398892e @@ -727,6 +752,7 @@ | semi-colon: 471f378eab4c | @ 471f378eab4c |/ Successors: [7a230b46bf61] + | semi-colon: [7a230b46bf61] | Fate: superseed as 7a230b46bf61 o ea207398892e @@ -743,6 +769,7 @@ | semi-colon: 471f378eab4c | x 471f378eab4c |/ Successors: [7a230b46bf61] + | semi-colon: [7a230b46bf61] | Fate: superseed as 7a230b46bf61 o ea207398892e