Show More
@@ -76,6 +76,7 b' The dot operator can be used as a shorth' | |||
|
76 | 76 | |
|
77 | 77 | - ``expr.member`` is roughly equivalent to ``expr % "{member}"`` if ``expr`` |
|
78 | 78 | returns a non-list/dict. The returned value is not stringified. |
|
79 | - ``dict.key`` is identical to ``get(dict, "key")``. | |
|
79 | 80 | |
|
80 | 81 | Aliases |
|
81 | 82 | ======= |
@@ -463,7 +463,8 b' def runmember(context, mapping, data):' | |||
|
463 | 463 | lm = mapping.copy() |
|
464 | 464 | lm.update(d.tomap()) |
|
465 | 465 | return runsymbol(context, lm, memb) |
|
466 | # TODO: d.get(memb) if dict-like? | |
|
466 | if util.safehasattr(d, 'get'): | |
|
467 | return _getdictitem(d, memb) | |
|
467 | 468 | |
|
468 | 469 | sym = findsymbolicname(darg) |
|
469 | 470 | if sym: |
@@ -751,6 +752,9 b' def get(context, mapping, args):' | |||
|
751 | 752 | raise error.ParseError(_("get() expects a dict as first argument")) |
|
752 | 753 | |
|
753 | 754 | key = evalfuncarg(context, mapping, args[1]) |
|
755 | return _getdictitem(dictarg, key) | |
|
756 | ||
|
757 | def _getdictitem(dictarg, key): | |
|
754 | 758 | val = dictarg.get(key) |
|
755 | 759 | if val is None: |
|
756 | 760 | return |
@@ -3184,6 +3184,8 b' Test evaluation of dot operator:' | |||
|
3184 | 3184 | |
|
3185 | 3185 | $ hg log -R latesttag -l1 -T '{min(revset("0:9")).node}\n' |
|
3186 | 3186 | ce3cec86e6c26bd9bdfc590a6b92abc9680f1796 |
|
3187 | $ hg log -R latesttag -r0 -T '{extras.branch}\n' | |
|
3188 | default | |
|
3187 | 3189 | |
|
3188 | 3190 | $ hg log -R latesttag -l1 -T '{author.invalid}\n' |
|
3189 | 3191 | hg: parse error: keyword 'author' has no member |
General Comments 0
You need to be logged in to leave comments.
Login now