comparison hgext/convert/__init__.py @ 36514:7b74afec6772

templatekw: switch non-showlist template keywords to new API
author Yuya Nishihara <yuya@tcha.org>
date Sun, 25 Feb 2018 13:40:46 +0900
parents 281214150561
children 34758397ad1b
comparison
equal deleted inserted replaced
36513:6ad140dc4269 36514:7b74afec6772
475 named directory) in the CVS repository, and converts the log to a 475 named directory) in the CVS repository, and converts the log to a
476 series of changesets based on matching commit log entries and 476 series of changesets based on matching commit log entries and
477 dates.''' 477 dates.'''
478 return cvsps.debugcvsps(ui, *args, **opts) 478 return cvsps.debugcvsps(ui, *args, **opts)
479 479
480 def kwconverted(ctx, name): 480 def kwconverted(context, mapping, name):
481 ctx = context.resource(mapping, 'ctx')
481 rev = ctx.extra().get('convert_revision', '') 482 rev = ctx.extra().get('convert_revision', '')
482 if rev.startswith('svn:'): 483 if rev.startswith('svn:'):
483 if name == 'svnrev': 484 if name == 'svnrev':
484 return str(subversion.revsplit(rev)[2]) 485 return str(subversion.revsplit(rev)[2])
485 elif name == 'svnpath': 486 elif name == 'svnpath':
488 return subversion.revsplit(rev)[0] 489 return subversion.revsplit(rev)[0]
489 return rev 490 return rev
490 491
491 templatekeyword = registrar.templatekeyword() 492 templatekeyword = registrar.templatekeyword()
492 493
493 @templatekeyword('svnrev') 494 @templatekeyword('svnrev', requires={'ctx'})
494 def kwsvnrev(repo, ctx, **args): 495 def kwsvnrev(context, mapping):
495 """String. Converted subversion revision number.""" 496 """String. Converted subversion revision number."""
496 return kwconverted(ctx, 'svnrev') 497 return kwconverted(context, mapping, 'svnrev')
497 498
498 @templatekeyword('svnpath') 499 @templatekeyword('svnpath', requires={'ctx'})
499 def kwsvnpath(repo, ctx, **args): 500 def kwsvnpath(context, mapping):
500 """String. Converted subversion revision project path.""" 501 """String. Converted subversion revision project path."""
501 return kwconverted(ctx, 'svnpath') 502 return kwconverted(context, mapping, 'svnpath')
502 503
503 @templatekeyword('svnuuid') 504 @templatekeyword('svnuuid', requires={'ctx'})
504 def kwsvnuuid(repo, ctx, **args): 505 def kwsvnuuid(context, mapping):
505 """String. Converted subversion revision repository identifier.""" 506 """String. Converted subversion revision repository identifier."""
506 return kwconverted(ctx, 'svnuuid') 507 return kwconverted(context, mapping, 'svnuuid')
507 508
508 # tell hggettext to extract docstrings from these functions: 509 # tell hggettext to extract docstrings from these functions:
509 i18nfunctions = [kwsvnrev, kwsvnpath, kwsvnuuid] 510 i18nfunctions = [kwsvnrev, kwsvnpath, kwsvnuuid]