Show More
@@ -409,12 +409,6 def whyunstable(context, mapping): | |||||
409 |
|
409 | |||
410 | whyunstable._requires = {'repo', 'ctx'} |
|
410 | whyunstable._requires = {'repo', 'ctx'} | |
411 |
|
411 | |||
412 | # helper to mark a function as a new-style template keyword; can be removed |
|
|||
413 | # once old-style function gets unsupported and new-style becomes the default |
|
|||
414 | def _kwfunc(f): |
|
|||
415 | f._requires = () |
|
|||
416 | return f |
|
|||
417 |
|
||||
418 | def commonentry(repo, ctx): |
|
412 | def commonentry(repo, ctx): | |
419 | node = scmutil.binnode(ctx) |
|
413 | node = scmutil.binnode(ctx) | |
420 | return { |
|
414 | return { | |
@@ -439,8 +433,8 def commonentry(repo, ctx): | |||||
439 | 'branches': nodebranchdict(repo, ctx), |
|
433 | 'branches': nodebranchdict(repo, ctx), | |
440 | 'tags': nodetagsdict(repo, node), |
|
434 | 'tags': nodetagsdict(repo, node), | |
441 | 'bookmarks': nodebookmarksdict(repo, node), |
|
435 | 'bookmarks': nodebookmarksdict(repo, node), | |
442 |
'parent': |
|
436 | 'parent': lambda context, mapping: parents(ctx), | |
443 |
'child': |
|
437 | 'child': lambda context, mapping: children(ctx), | |
444 | } |
|
438 | } | |
445 |
|
439 | |||
446 | def changelistentry(web, ctx): |
|
440 | def changelistentry(web, ctx): | |
@@ -457,9 +451,9 def changelistentry(web, ctx): | |||||
457 |
|
451 | |||
458 | entry = commonentry(repo, ctx) |
|
452 | entry = commonentry(repo, ctx) | |
459 | entry.update({ |
|
453 | entry.update({ | |
460 |
'allparents': |
|
454 | 'allparents': lambda context, mapping: parents(ctx), | |
461 |
'parent': |
|
455 | 'parent': lambda context, mapping: parents(ctx, rev - 1), | |
462 |
'child': |
|
456 | 'child': lambda context, mapping: children(ctx, rev + 1), | |
463 | 'changelogtag': showtags, |
|
457 | 'changelogtag': showtags, | |
464 | 'files': files, |
|
458 | 'files': files, | |
465 | }) |
|
459 | }) | |
@@ -529,7 +523,7 def changesetentry(web, ctx): | |||||
529 | changesetbranch=showbranch, |
|
523 | changesetbranch=showbranch, | |
530 | files=templateutil.mappedgenerator(_listfilesgen, |
|
524 | files=templateutil.mappedgenerator(_listfilesgen, | |
531 | args=(ctx, web.stripecount)), |
|
525 | args=(ctx, web.stripecount)), | |
532 |
diffsummary= |
|
526 | diffsummary=lambda context, mapping: diffsummary(diffstatsgen), | |
533 | diffstat=diffstats, |
|
527 | diffstat=diffstats, | |
534 | archives=web.archivelist(ctx.hex()), |
|
528 | archives=web.archivelist(ctx.hex()), | |
535 | **pycompat.strkwargs(commonentry(web.repo, ctx))) |
|
529 | **pycompat.strkwargs(commonentry(web.repo, ctx))) |
@@ -338,13 +338,6 class templatekeyword(_templateregistrar | |||||
338 | ''' |
|
338 | ''' | |
339 | pass |
|
339 | pass | |
340 |
|
340 | |||
341 | # old API (DEPRECATED) |
|
|||
342 | @templatekeyword('mykeyword') |
|
|||
343 | def mykeywordfunc(repo, ctx, templ, cache, revcache, **args): |
|
|||
344 | '''Explanation of this template keyword .... |
|
|||
345 | ''' |
|
|||
346 | pass |
|
|||
347 |
|
||||
348 | The first string argument is used also in online help. |
|
341 | The first string argument is used also in online help. | |
349 |
|
342 | |||
350 | Optional argument 'requires' should be a collection of resource names |
|
343 | Optional argument 'requires' should be a collection of resource names |
@@ -874,7 +874,6 def runstring(context, mapping, data): | |||||
874 | def _recursivesymbolblocker(key): |
|
874 | def _recursivesymbolblocker(key): | |
875 | def showrecursion(context, mapping): |
|
875 | def showrecursion(context, mapping): | |
876 | raise error.Abort(_("recursive reference '%s' in template") % key) |
|
876 | raise error.Abort(_("recursive reference '%s' in template") % key) | |
877 | showrecursion._requires = () # mark as new-style templatekw |
|
|||
878 | return showrecursion |
|
877 | return showrecursion | |
879 |
|
878 | |||
880 | def runsymbol(context, mapping, key, default=''): |
|
879 | def runsymbol(context, mapping, key, default=''): | |
@@ -888,19 +887,6 def runsymbol(context, mapping, key, def | |||||
888 | v = context.process(key, safemapping) |
|
887 | v = context.process(key, safemapping) | |
889 | except TemplateNotFound: |
|
888 | except TemplateNotFound: | |
890 | v = default |
|
889 | v = default | |
891 | if callable(v) and getattr(v, '_requires', None) is None: |
|
|||
892 | # old templatekw: expand all keywords and resources |
|
|||
893 | # (TODO: drop support for old-style functions. 'f._requires = ()' |
|
|||
894 | # can be removed.) |
|
|||
895 | props = {k: context._resources.lookup(mapping, k) |
|
|||
896 | for k in context._resources.knownkeys()} |
|
|||
897 | # pass context to _showcompatlist() through templatekw._showlist() |
|
|||
898 | props['templ'] = context |
|
|||
899 | props.update(mapping) |
|
|||
900 | ui = props.get('ui') |
|
|||
901 | if ui: |
|
|||
902 | ui.deprecwarn("old-style template keyword '%s'" % key, '4.8') |
|
|||
903 | return v(**pycompat.strkwargs(props)) |
|
|||
904 | if callable(v): |
|
890 | if callable(v): | |
905 | # new templatekw |
|
891 | # new templatekw | |
906 | try: |
|
892 | try: |
General Comments 0
You need to be logged in to leave comments.
Login now