changeset 32909:89610c586fa2

templatekw: reference predecessor node id as {node} in map operation More predecessor-depending values will be populated by the next patch.
author Yuya Nishihara <yuya@tcha.org>
date Sat, 17 Jun 2017 13:18:03 +0900
parents 661025fd3e1c
children 498e9dcc5fa9
files mercurial/templatekw.py tests/test-obsmarker-template.t
diffstat 2 files changed, 36 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/templatekw.py	Sun Jun 18 23:05:54 2017 -0400
+++ b/mercurial/templatekw.py	Sat Jun 17 13:18:03 2017 +0900
@@ -568,8 +568,8 @@
     predecessors = sorted(obsutil.closestpredecessors(repo, ctx.node()))
     predecessors = map(hex, predecessors)
 
-    return _hybrid(None, predecessors, lambda x: {'predecessor': x},
-                   lambda d: d['predecessor'][:12])
+    return _hybrid(None, predecessors, lambda x: {'node': x},
+                   lambda d: d['node'][:12])
 
 @templatekeyword('p1rev')
 def showp1rev(repo, ctx, templ, **args):
--- a/tests/test-obsmarker-template.t	Sun Jun 18 23:05:54 2017 -0400
+++ b/tests/test-obsmarker-template.t	Sat Jun 17 13:18:03 2017 +0900
@@ -15,7 +15,8 @@
   > tlog = log -G -T '{node|short}\
   >     {if(predecessors, "\n  Predecessors: {predecessors}")}\
   >     {if(predecessors, "\n  semi-colon: {join(predecessors, "; ")}")}\
-  >     {if(predecessors, "\n  json: {predecessors|json}")}\n'
+  >     {if(predecessors, "\n  json: {predecessors|json}")}\
+  >     {if(predecessors, "\n  map: {join(predecessors % "{node}", " ")}")}\n'
   > EOF
 
 Test templates on amended commit
@@ -72,6 +73,7 @@
   |    Predecessors: 471f378eab4c
   |    semi-colon: 471f378eab4c
   |    json: ["471f378eab4c5e25f6c77f785b27c936efb22874"]
+  |    map: 471f378eab4c5e25f6c77f785b27c936efb22874
   | @  471f378eab4c
   |/
   o  ea207398892e
@@ -85,6 +87,7 @@
   |    Predecessors: a468dc9b3633
   |    semi-colon: a468dc9b3633
   |    json: ["a468dc9b36338b14fdb7825f55ce3df4e71517ad"]
+  |    map: a468dc9b36338b14fdb7825f55ce3df4e71517ad
   | @  a468dc9b3633
   |/
   o  ea207398892e
@@ -96,10 +99,12 @@
   |    Predecessors: a468dc9b3633
   |    semi-colon: a468dc9b3633
   |    json: ["a468dc9b36338b14fdb7825f55ce3df4e71517ad"]
+  |    map: a468dc9b36338b14fdb7825f55ce3df4e71517ad
   | @  a468dc9b3633
   |/     Predecessors: 471f378eab4c
   |      semi-colon: 471f378eab4c
   |      json: ["471f378eab4c5e25f6c77f785b27c936efb22874"]
+  |      map: 471f378eab4c5e25f6c77f785b27c936efb22874
   | x  f137d23bb3e1
   | |
   | x  471f378eab4c
@@ -121,10 +126,12 @@
   |    Predecessors: a468dc9b3633
   |    semi-colon: a468dc9b3633
   |    json: ["a468dc9b36338b14fdb7825f55ce3df4e71517ad"]
+  |    map: a468dc9b36338b14fdb7825f55ce3df4e71517ad
   | x  a468dc9b3633
   |/     Predecessors: 471f378eab4c
   |      semi-colon: 471f378eab4c
   |      json: ["471f378eab4c5e25f6c77f785b27c936efb22874"]
+  |      map: 471f378eab4c5e25f6c77f785b27c936efb22874
   | x  f137d23bb3e1
   | |
   | x  471f378eab4c
@@ -202,10 +209,12 @@
   |    Predecessors: 471597cad322
   |    semi-colon: 471597cad322
   |    json: ["471597cad322d1f659bb169751be9133dad92ef3"]
+  |    map: 471597cad322d1f659bb169751be9133dad92ef3
   o  337fec4d2edc
   |    Predecessors: 471597cad322
   |    semi-colon: 471597cad322
   |    json: ["471597cad322d1f659bb169751be9133dad92ef3"]
+  |    map: 471597cad322d1f659bb169751be9133dad92ef3
   | @  471597cad322
   |/
   o  ea207398892e
@@ -229,10 +238,12 @@
   |    Predecessors: 471597cad322
   |    semi-colon: 471597cad322
   |    json: ["471597cad322d1f659bb169751be9133dad92ef3"]
+  |    map: 471597cad322d1f659bb169751be9133dad92ef3
   o  337fec4d2edc
   |    Predecessors: 471597cad322
   |    semi-colon: 471597cad322
   |    json: ["471597cad322d1f659bb169751be9133dad92ef3"]
+  |    map: 471597cad322d1f659bb169751be9133dad92ef3
   | x  471597cad322
   |/
   o  ea207398892e
@@ -312,6 +323,7 @@
   |    Predecessors: 471f378eab4c
   |    semi-colon: 471f378eab4c
   |    json: ["471f378eab4c5e25f6c77f785b27c936efb22874"]
+  |    map: 471f378eab4c5e25f6c77f785b27c936efb22874
   | @  471f378eab4c
   |/
   o  ea207398892e
@@ -326,6 +338,7 @@
   |    Predecessors: 0dec01379d3b 471f378eab4c
   |    semi-colon: 0dec01379d3b; 471f378eab4c
   |    json: ["0dec01379d3be6318c470ead31b1fe7ae7cb53d5", "471f378eab4c5e25f6c77f785b27c936efb22874"]
+  |    map: 0dec01379d3be6318c470ead31b1fe7ae7cb53d5 471f378eab4c5e25f6c77f785b27c936efb22874
   | @  0dec01379d3b
   | |
   | x  471f378eab4c
@@ -349,6 +362,7 @@
   |    Predecessors: 0dec01379d3b 471f378eab4c
   |    semi-colon: 0dec01379d3b; 471f378eab4c
   |    json: ["0dec01379d3be6318c470ead31b1fe7ae7cb53d5", "471f378eab4c5e25f6c77f785b27c936efb22874"]
+  |    map: 0dec01379d3be6318c470ead31b1fe7ae7cb53d5 471f378eab4c5e25f6c77f785b27c936efb22874
   | x  0dec01379d3b
   | |
   | x  471f378eab4c
@@ -460,10 +474,12 @@
   |    Predecessors: 471f378eab4c
   |    semi-colon: 471f378eab4c
   |    json: ["471f378eab4c5e25f6c77f785b27c936efb22874"]
+  |    map: 471f378eab4c5e25f6c77f785b27c936efb22874
   | o  fdf9bde5129a
   |/     Predecessors: 471f378eab4c
   |      semi-colon: 471f378eab4c
   |      json: ["471f378eab4c5e25f6c77f785b27c936efb22874"]
+  |      map: 471f378eab4c5e25f6c77f785b27c936efb22874
   | @  471f378eab4c
   |/
   o  ea207398892e
@@ -487,14 +503,17 @@
   |    Predecessors: 65b757b745b9
   |    semi-colon: 65b757b745b9
   |    json: ["65b757b745b935093c87a2bccd877521cccffcbd"]
+  |    map: 65b757b745b935093c87a2bccd877521cccffcbd
   | x  65b757b745b9
   |/     Predecessors: 471f378eab4c
   |      semi-colon: 471f378eab4c
   |      json: ["471f378eab4c5e25f6c77f785b27c936efb22874"]
+  |      map: 471f378eab4c5e25f6c77f785b27c936efb22874
   | @  fdf9bde5129a
   |/     Predecessors: 471f378eab4c
   |      semi-colon: 471f378eab4c
   |      json: ["471f378eab4c5e25f6c77f785b27c936efb22874"]
+  |      map: 471f378eab4c5e25f6c77f785b27c936efb22874
   | x  471f378eab4c
   |/
   o  ea207398892e
@@ -588,6 +607,7 @@
   |    Predecessors: 471f378eab4c
   |    semi-colon: 471f378eab4c
   |    json: ["471f378eab4c5e25f6c77f785b27c936efb22874"]
+  |    map: 471f378eab4c5e25f6c77f785b27c936efb22874
   | @  471f378eab4c
   |/
   o  ea207398892e
@@ -601,6 +621,7 @@
   |    Predecessors: 0dec01379d3b 471f378eab4c
   |    semi-colon: 0dec01379d3b; 471f378eab4c
   |    json: ["0dec01379d3be6318c470ead31b1fe7ae7cb53d5", "471f378eab4c5e25f6c77f785b27c936efb22874"]
+  |    map: 0dec01379d3be6318c470ead31b1fe7ae7cb53d5 471f378eab4c5e25f6c77f785b27c936efb22874
   | @  0dec01379d3b
   | |
   | x  471f378eab4c
@@ -616,6 +637,7 @@
   |    Predecessors: 471f378eab4c b7ea6d14e664
   |    semi-colon: 471f378eab4c; b7ea6d14e664
   |    json: ["471f378eab4c5e25f6c77f785b27c936efb22874", "b7ea6d14e664bdc8922221f7992631b50da3fb07"]
+  |    map: 471f378eab4c5e25f6c77f785b27c936efb22874 b7ea6d14e664bdc8922221f7992631b50da3fb07
   | @  b7ea6d14e664
   | |
   | x  471f378eab4c
@@ -638,10 +660,12 @@
   |    Predecessors: 471f378eab4c b7ea6d14e664
   |    semi-colon: 471f378eab4c; b7ea6d14e664
   |    json: ["471f378eab4c5e25f6c77f785b27c936efb22874", "b7ea6d14e664bdc8922221f7992631b50da3fb07"]
+  |    map: 471f378eab4c5e25f6c77f785b27c936efb22874 b7ea6d14e664bdc8922221f7992631b50da3fb07
   | x  b7ea6d14e664
   | |    Predecessors: 0dec01379d3b
   | |    semi-colon: 0dec01379d3b
   | |    json: ["0dec01379d3be6318c470ead31b1fe7ae7cb53d5"]
+  | |    map: 0dec01379d3be6318c470ead31b1fe7ae7cb53d5
   | | x  0dec01379d3b
   | |/
   | x  471f378eab4c
@@ -744,6 +768,7 @@
   |    Predecessors: 471f378eab4c
   |    semi-colon: 471f378eab4c
   |    json: ["471f378eab4c5e25f6c77f785b27c936efb22874"]
+  |    map: 471f378eab4c5e25f6c77f785b27c936efb22874
   | @  471f378eab4c
   |/
   o  ea207398892e
@@ -764,6 +789,7 @@
   |    Predecessors: 471f378eab4c
   |    semi-colon: 471f378eab4c
   |    json: ["471f378eab4c5e25f6c77f785b27c936efb22874"]
+  |    map: 471f378eab4c5e25f6c77f785b27c936efb22874
   | x  471f378eab4c
   |/
   o  ea207398892e
@@ -807,14 +833,17 @@
   |    Predecessors: 0dec01379d3b
   |    semi-colon: 0dec01379d3b
   |    json: ["0dec01379d3be6318c470ead31b1fe7ae7cb53d5"]
+  |    map: 0dec01379d3be6318c470ead31b1fe7ae7cb53d5
   | @  0dec01379d3b
   | |    Predecessors: 471f378eab4c
   | |    semi-colon: 471f378eab4c
   | |    json: ["471f378eab4c5e25f6c77f785b27c936efb22874"]
+  | |    map: 471f378eab4c5e25f6c77f785b27c936efb22874
   | x  471f378eab4c
   |/     Predecessors: 0dec01379d3b
   |      semi-colon: 0dec01379d3b
   |      json: ["0dec01379d3be6318c470ead31b1fe7ae7cb53d5"]
+  |      map: 0dec01379d3be6318c470ead31b1fe7ae7cb53d5
   o  ea207398892e
   
 
@@ -825,6 +854,7 @@
   |    Predecessors: 471f378eab4c
   |    semi-colon: 471f378eab4c
   |    json: ["471f378eab4c5e25f6c77f785b27c936efb22874"]
+  |    map: 471f378eab4c5e25f6c77f785b27c936efb22874
   | @  471f378eab4c
   |/
   o  ea207398892e
@@ -843,13 +873,16 @@
   |    Predecessors: 0dec01379d3b
   |    semi-colon: 0dec01379d3b
   |    json: ["0dec01379d3be6318c470ead31b1fe7ae7cb53d5"]
+  |    map: 0dec01379d3be6318c470ead31b1fe7ae7cb53d5
   | x  0dec01379d3b
   | |    Predecessors: 471f378eab4c
   | |    semi-colon: 471f378eab4c
   | |    json: ["471f378eab4c5e25f6c77f785b27c936efb22874"]
+  | |    map: 471f378eab4c5e25f6c77f785b27c936efb22874
   | x  471f378eab4c
   |/     Predecessors: 0dec01379d3b
   |      semi-colon: 0dec01379d3b
   |      json: ["0dec01379d3be6318c470ead31b1fe7ae7cb53d5"]
+  |      map: 0dec01379d3be6318c470ead31b1fe7ae7cb53d5
   @  ea207398892e