comparison hgsubversion/__init__.py @ 1591:39e2f8f8f205

templatekw: make portable to hg48
author Augie Fackler <raf@durin42.com>
date Fri, 02 Nov 2018 23:24:19 -0400
parents 40d8557d6aee
children 74c5fd9c3e76
comparison
equal deleted inserted replaced
1590:40d8557d6aee 1591:39e2f8f8f205
15 For more information and instructions, see :hg:`help subversion`. 15 For more information and instructions, see :hg:`help subversion`.
16 ''' 16 '''
17 17
18 testedwith = '3.7 3.8 3.9 4.0 4.1 4.2 4.3 4.4 4.5 4.6 4.7 4.8' 18 testedwith = '3.7 3.8 3.9 4.0 4.1 4.2 4.3 4.4 4.5 4.6 4.7 4.8'
19 19
20 import inspect
20 import os 21 import os
21 22
22 from mercurial import commands 23 from mercurial import commands
23 try: 24 try:
24 from mercurial import exchange 25 from mercurial import exchange
358 elif kw == 'svnrev': 359 elif kw == 'svnrev':
359 return convertinfo[40:].rsplit('@', 1)[-1] 360 return convertinfo[40:].rsplit('@', 1)[-1]
360 else: 361 else:
361 raise hgerror.Abort('unrecognized hgsubversion keyword %s' % kw) 362 raise hgerror.Abort('unrecognized hgsubversion keyword %s' % kw)
362 363
363 @templatekeyword('svnrev') 364 _ishg48 = 'requires' in inspect.getargspec(
364 def svnrevkw(**args): 365 getattr(templatekeyword, '_extrasetup', lambda: None)).args
365 """:svnrev: String. Converted subversion revision number.""" 366
366 return _templatehelper(args['ctx'], 'svnrev') 367 if _ishg48:
367 368 @templatekeyword('svnrev', requires={'ctx'})
368 @templatekeyword('svnpath') 369 def svnrevkw(context, mapping):
369 def svnpathkw(**args): 370 """:svnrev: String. Converted subversion revision number."""
370 """:svnpath: String. Converted subversion revision project path.""" 371 ctx = context.resource(mapping, 'ctx')
371 return _templatehelper(args['ctx'], 'svnpath') 372 return _templatehelper(ctx, 'svnrev')
372 373
373 @templatekeyword('svnuuid') 374 @templatekeyword('svnpath', requires={'ctx'})
374 def svnuuidkw(**args): 375 def svnpathkw(context, mapping):
375 """:svnuuid: String. Converted subversion revision repository identifier.""" 376 """:svnpath: String. Converted subversion revision project path."""
376 return _templatehelper(args['ctx'], 'svnuuid') 377 ctx = context.resource(mapping, 'ctx')
378 return _templatehelper(ctx, 'svnpath')
379
380 @templatekeyword('svnuuid', requires={'ctx'})
381 def svnuuidkw(context, mapping):
382 """:svnuuid: String. Converted subversion revision repository identifier."""
383 ctx = context.resource(mapping, 'ctx')
384 return _templatehelper(ctx, 'svnuuid')
385 else:
386 @templatekeyword('svnrev')
387 def svnrevkw(**args):
388 """:svnrev: String. Converted subversion revision number."""
389 return _templatehelper(args['ctx'], 'svnrev')
390
391 @templatekeyword('svnpath')
392 def svnpathkw(**args):
393 """:svnpath: String. Converted subversion revision project path."""
394 return _templatehelper(args['ctx'], 'svnpath')
395
396 @templatekeyword('svnuuid')
397 def svnuuidkw(**args):
398 """:svnuuid: String. Converted subversion revision repository identifier."""
399 return _templatehelper(args['ctx'], 'svnuuid')
377 400
378 loadkeyword(templatekeyword) 401 loadkeyword(templatekeyword)