##// END OF EJS Templates
remotenames: inline _parseargs() into _revsetutil()...
Yuya Nishihara -
r40101:25533575 default
parent child Browse files
Show More
@@ -347,8 +347,14 b' def remotebrancheskw(context, mapping):'
347 return templateutil.compatlist(context, mapping, 'remotebranch',
347 return templateutil.compatlist(context, mapping, 'remotebranch',
348 remotebranches, plural='remotebranches')
348 remotebranches, plural='remotebranches')
349
349
350 def _revsetutil(repo, subset, x, rtypes, matcher):
350 def _revsetutil(repo, subset, x, rtypes):
351 """utility function to return a set of revs based on the rtypes"""
351 """utility function to return a set of revs based on the rtypes"""
352 args = revsetlang.getargs(x, 0, 1, _('only one argument accepted'))
353 if args:
354 kind, pattern, matcher = stringutil.stringmatcher(
355 revsetlang.getstring(args[0], _('argument must be a string')))
356 else:
357 matcher = lambda a: True
352
358
353 revs = set()
359 revs = set()
354 cl = repo.changelog
360 cl = repo.changelog
@@ -363,18 +369,6 b' def _revsetutil(repo, subset, x, rtypes,'
363 results = (cl.rev(n) for n in revs if cl.hasnode(n))
369 results = (cl.rev(n) for n in revs if cl.hasnode(n))
364 return subset & smartset.baseset(sorted(results))
370 return subset & smartset.baseset(sorted(results))
365
371
366 def _parseargs(x):
367 """parses the argument passed in revsets
368
369 Returns a matcher for the passed pattern.
370 """
371 args = revsetlang.getargs(x, 0, 1, _('only one argument accepted'))
372 for arg in args:
373 kind, pattern, matcher = stringutil.stringmatcher(
374 revsetlang.getstring(arg, _('argument must be a string')))
375 return matcher
376 return lambda a: True
377
378 @revsetpredicate('remotenames([name])')
372 @revsetpredicate('remotenames([name])')
379 def remotenamesrevset(repo, subset, x):
373 def remotenamesrevset(repo, subset, x):
380 """All changesets which have a remotename on them. If `name` is
374 """All changesets which have a remotename on them. If `name` is
@@ -382,8 +376,7 b' def remotenamesrevset(repo, subset, x):'
382
376
383 Pattern matching is supported for `name`. See :hg:`help revisions.patterns`.
377 Pattern matching is supported for `name`. See :hg:`help revisions.patterns`.
384 """
378 """
385 return _revsetutil(repo, subset, x, ('remotebookmarks', 'remotebranches'),
379 return _revsetutil(repo, subset, x, ('remotebookmarks', 'remotebranches'))
386 _parseargs(x))
387
380
388 @revsetpredicate('remotebranches([name])')
381 @revsetpredicate('remotebranches([name])')
389 def remotebranchesrevset(repo, subset, x):
382 def remotebranchesrevset(repo, subset, x):
@@ -392,9 +385,7 b' def remotebranchesrevset(repo, subset, x'
392
385
393 Pattern matching is supported for `name`. See :hg:`help revisions.patterns`.
386 Pattern matching is supported for `name`. See :hg:`help revisions.patterns`.
394 """
387 """
395
388 return _revsetutil(repo, subset, x, ('remotebranches',))
396 args = _parseargs(x)
397 return _revsetutil(repo, subset, x, ('remotebranches',), args)
398
389
399 @revsetpredicate('remotebookmarks([name])')
390 @revsetpredicate('remotebookmarks([name])')
400 def remotebmarksrevset(repo, subset, x):
391 def remotebmarksrevset(repo, subset, x):
@@ -403,6 +394,4 b' def remotebmarksrevset(repo, subset, x):'
403
394
404 Pattern matching is supported for `name`. See :hg:`help revisions.patterns`.
395 Pattern matching is supported for `name`. See :hg:`help revisions.patterns`.
405 """
396 """
406
397 return _revsetutil(repo, subset, x, ('remotebookmarks',))
407 args = _parseargs(x)
408 return _revsetutil(repo, subset, x, ('remotebookmarks',), args)
General Comments 0
You need to be logged in to leave comments. Login now