##// END OF EJS Templates
templater: handle exception when applying map operator to non-iterable object...
Yuya Nishihara -
r28349:7cb2f243 default
parent child Browse files
Show More
@@ -305,9 +305,17 b' def runmap(context, mapping, data):'
305 func, data, ctmpl = data
305 func, data, ctmpl = data
306 d = func(context, mapping, data)
306 d = func(context, mapping, data)
307 if util.safehasattr(d, 'itermaps'):
307 if util.safehasattr(d, 'itermaps'):
308 d = d.itermaps()
308 diter = d.itermaps()
309 else:
310 try:
311 diter = iter(d)
312 except TypeError:
313 if func is runsymbol:
314 raise error.ParseError(_("keyword '%s' is not iterable") % data)
315 else:
316 raise error.ParseError(_("%r is not iterable") % d)
309
317
310 for i in d:
318 for i in diter:
311 lm = mapping.copy()
319 lm = mapping.copy()
312 if isinstance(i, dict):
320 if isinstance(i, dict):
313 lm.update(i)
321 lm.update(i)
@@ -2790,6 +2790,14 b' Test new-style inline templating:'
2790 $ hg log -R latesttag -r tip --template 'modified files: {file_mods % " {file}\n"}\n'
2790 $ hg log -R latesttag -r tip --template 'modified files: {file_mods % " {file}\n"}\n'
2791 modified files: .hgtags
2791 modified files: .hgtags
2792
2792
2793
2794 $ hg log -R latesttag -r tip -T '{rev % "a"}\n'
2795 hg: parse error: keyword 'rev' is not iterable
2796 [255]
2797 $ hg log -R latesttag -r tip -T '{get(extras, "unknown") % "a"}\n'
2798 hg: parse error: None is not iterable
2799 [255]
2800
2793 Test the sub function of templating for expansion:
2801 Test the sub function of templating for expansion:
2794
2802
2795 $ hg log -R latesttag -r 10 --template '{sub("[0-9]", "x", "{rev}")}\n'
2803 $ hg log -R latesttag -r 10 --template '{sub("[0-9]", "x", "{rev}")}\n'
General Comments 0
You need to be logged in to leave comments. Login now