Show More
@@ -347,28 +347,18 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, ar |
|
350 | def _revsetutil(repo, subset, x, rtypes, matcher): | |
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 |
|
352 | |||
353 | revs = set() |
|
353 | revs = set() | |
354 | cl = repo.changelog |
|
354 | cl = repo.changelog | |
355 | literals, matchers = args |
|
|||
356 | # whether arguments were passed or not |
|
|||
357 | argspassed = bool(literals or matchers) |
|
|||
358 | for rtype in rtypes: |
|
355 | for rtype in rtypes: | |
359 | if rtype in repo.names: |
|
356 | if rtype in repo.names: | |
360 | ns = repo.names[rtype] |
|
357 | ns = repo.names[rtype] | |
361 | for name in ns.listnames(repo): |
|
358 | for name in ns.listnames(repo): | |
362 |
if |
|
359 | if not matcher(name): | |
363 |
|
|
360 | continue | |
364 |
|
|
361 | revs.update(ns.nodes(repo, name)) | |
365 | continue |
|
|||
366 | for matcher in matchers: |
|
|||
367 | if matcher(name): |
|
|||
368 | revs.update(ns.nodes(repo, name)) |
|
|||
369 | break |
|
|||
370 | else: |
|
|||
371 | revs.update(ns.nodes(repo, name)) |
|
|||
372 |
|
362 | |||
373 | results = (cl.rev(n) for n in revs if cl.hasnode(n)) |
|
363 | results = (cl.rev(n) for n in revs if cl.hasnode(n)) | |
374 | return subset & smartset.baseset(sorted(results)) |
|
364 | return subset & smartset.baseset(sorted(results)) | |
@@ -376,48 +366,29 b' def _revsetutil(repo, subset, x, rtypes,' | |||||
376 | def _parseargs(x): |
|
366 | def _parseargs(x): | |
377 | """parses the argument passed in revsets |
|
367 | """parses the argument passed in revsets | |
378 |
|
368 | |||
379 | returns (literals, matchers) where, |
|
369 | Returns a matcher for the passed pattern. | |
380 | literals is a set of literals passed by user |
|
|||
381 | matchers is a list of matcher objects for patterns passed by user |
|
|||
382 | """ |
|
370 | """ | |
383 |
|
371 | args = revsetlang.getargs(x, 0, 1, _('only one argument accepted')) | ||
384 | # set of paths passed as literals |
|
372 | for arg in args: | |
385 | literals = set() |
|
373 | kind, pattern, matcher = stringutil.stringmatcher( | |
386 | # list of matcher to match the patterns passed as names |
|
374 | revsetlang.getstring(arg, _('argument must be a string'))) | |
387 | matchers = [] |
|
375 | return matcher | |
388 |
|
376 | return lambda a: True | ||
389 | if not x: |
|
|||
390 | return literals, matchers |
|
|||
391 |
|
377 | |||
392 | args = set() |
|
378 | @revsetpredicate('remotenames([name])') | |
393 | lx = revsetlang.getlist(x) |
|
|||
394 | err = _('the argument must be a string') |
|
|||
395 | for entry in lx: |
|
|||
396 | args.add(revsetlang.getstring(entry, err)) |
|
|||
397 | for p in args: |
|
|||
398 | kind, pattern, matcher = stringutil.stringmatcher(p) |
|
|||
399 | if kind == 'literal': |
|
|||
400 | literals.add(pattern) |
|
|||
401 | else: |
|
|||
402 | matchers.append(matcher) |
|
|||
403 | return literals, matchers |
|
|||
404 |
|
||||
405 | @revsetpredicate('remotenames([name, ...])') |
|
|||
406 | def remotenamesrevset(repo, subset, x): |
|
379 | def remotenamesrevset(repo, subset, x): | |
407 |
"""All changesets which have a remotename on them. If |
|
380 | """All changesets which have a remotename on them. If `name` is | |
408 |
remotenames of |
|
381 | specified, only remotenames of matching remote paths are considered. | |
409 |
|
382 | |||
410 | Pattern matching is supported for `name`. See :hg:`help revisions.patterns`. |
|
383 | Pattern matching is supported for `name`. See :hg:`help revisions.patterns`. | |
411 | """ |
|
384 | """ | |
412 |
|
||||
413 | args = _parseargs(x) |
|
|||
414 | return _revsetutil(repo, subset, x, ('remotebookmarks', 'remotebranches'), |
|
385 | return _revsetutil(repo, subset, x, ('remotebookmarks', 'remotebranches'), | |
415 | args) |
|
386 | _parseargs(x)) | |
416 |
|
387 | |||
417 |
@revsetpredicate('remotebranches([name |
|
388 | @revsetpredicate('remotebranches([name])') | |
418 | def remotebranchesrevset(repo, subset, x): |
|
389 | def remotebranchesrevset(repo, subset, x): | |
419 |
"""All changesets which are branch heads on remotes. If |
|
390 | """All changesets which are branch heads on remotes. If `name` is | |
420 |
|
|
391 | specified, only remotenames of matching remote paths are considered. | |
421 |
|
392 | |||
422 | Pattern matching is supported for `name`. See :hg:`help revisions.patterns`. |
|
393 | Pattern matching is supported for `name`. See :hg:`help revisions.patterns`. | |
423 | """ |
|
394 | """ | |
@@ -425,10 +396,10 b' def remotebranchesrevset(repo, subset, x' | |||||
425 | args = _parseargs(x) |
|
396 | args = _parseargs(x) | |
426 | return _revsetutil(repo, subset, x, ('remotebranches',), args) |
|
397 | return _revsetutil(repo, subset, x, ('remotebranches',), args) | |
427 |
|
398 | |||
428 |
@revsetpredicate('remotebookmarks([name |
|
399 | @revsetpredicate('remotebookmarks([name])') | |
429 | def remotebmarksrevset(repo, subset, x): |
|
400 | def remotebmarksrevset(repo, subset, x): | |
430 |
"""All changesets which have bookmarks on remotes. If |
|
401 | """All changesets which have bookmarks on remotes. If `name` is | |
431 |
|
|
402 | specified, only remotenames of matching remote paths are considered. | |
432 |
|
403 | |||
433 | Pattern matching is supported for `name`. See :hg:`help revisions.patterns`. |
|
404 | Pattern matching is supported for `name`. See :hg:`help revisions.patterns`. | |
434 | """ |
|
405 | """ |
@@ -486,67 +486,19 b' Testing for a single name which does not' | |||||
486 |
|
486 | |||
487 | $ hg log -r 'remotenames("server3")' -GT "{rev}:{node|short} {remotenames}\n" |
|
487 | $ hg log -r 'remotenames("server3")' -GT "{rev}:{node|short} {remotenames}\n" | |
488 |
|
488 | |||
489 |
Testing for multiple names wh |
|
489 | Testing for multiple names, which is not supported. | |
490 |
|
490 | |||
491 | $ hg log -r 'remotenames("re:default", "re:server2")' -GT "{rev}:{node|short} {remotenames}\n" |
|
491 | $ hg log -r 'remotenames("re:default", "re:server2")' -GT "{rev}:{node|short} {remotenames}\n" | |
492 | o 10:bf433e48adea server2/default |
|
492 | hg: parse error: only one argument accepted | |
493 | | |
|
493 | [255] | |
494 | | o 9:f34adec73c21 server2/wat |
|
|||
495 | | | |
|
|||
496 | | o 8:3e1487808078 default/foo default/wat |
|
|||
497 | | : |
|
|||
498 | @ : 7:ec2426147f0e default/default |
|
|||
499 | | : |
|
|||
500 | o : 6:87d6d6676308 default/bar server2/bar |
|
|||
501 | :/ |
|
|||
502 | o 3:62615734edd5 server2/foo |
|
|||
503 | | |
|
|||
504 | ~ |
|
|||
505 |
|
494 | |||
506 | $ hg log -r 'remotebranches("default/wat", "server2/wat")' -GT "{rev}:{node|short} {remotebranches}\n" |
|
495 | $ hg log -r 'remotebranches("default/wat", "server2/wat")' -GT "{rev}:{node|short} {remotebranches}\n" | |
507 | o 9:f34adec73c21 server2/wat |
|
496 | hg: parse error: only one argument accepted | |
508 | | |
|
497 | [255] | |
509 | o 8:3e1487808078 default/wat |
|
|||
510 | | |
|
|||
511 | ~ |
|
|||
512 |
|
498 | |||
513 | $ hg log -r 'remotebookmarks("default/foo", "server2/foo")' -GT "{rev}:{node|short} {remotebookmarks}\n" |
|
499 | $ hg log -r 'remotebookmarks("default/foo", "server2/foo")' -GT "{rev}:{node|short} {remotebookmarks}\n" | |
514 | o 8:3e1487808078 default/foo |
|
500 | hg: parse error: only one argument accepted | |
515 | : |
|
501 | [255] | |
516 | o 3:62615734edd5 server2/foo |
|
|||
517 | | |
|
|||
518 | ~ |
|
|||
519 |
|
||||
520 | Testing for multipe names where some exists and some not |
|
|||
521 |
|
||||
522 | $ hg log -r 'remotenames(def, "re:server2")' -GT "{rev}:{node|short} {remotenames}\n" |
|
|||
523 | o 10:bf433e48adea server2/default |
|
|||
524 | : |
|
|||
525 | : o 9:f34adec73c21 server2/wat |
|
|||
526 | : : |
|
|||
527 | o : 6:87d6d6676308 default/bar server2/bar |
|
|||
528 | :/ |
|
|||
529 | o 3:62615734edd5 server2/foo |
|
|||
530 | | |
|
|||
531 | ~ |
|
|||
532 |
|
||||
533 | $ hg log -r 'remotebranches("default/default", server)' -GT "{rev}:{node|short} {remotebranches}\n" |
|
|||
534 | @ 7:ec2426147f0e default/default |
|
|||
535 | | |
|
|||
536 | ~ |
|
|||
537 |
|
||||
538 | $ hg log -r 'remotebookmarks("default/foo", serv)' -GT "{rev}:{node|short} {remotebookmarks}\n" |
|
|||
539 | o 8:3e1487808078 default/foo |
|
|||
540 | | |
|
|||
541 | ~ |
|
|||
542 |
|
||||
543 | Where multiple names specified and None of them exists |
|
|||
544 |
|
||||
545 | $ hg log -r 'remotenames(def, serv2)' -GT "{rev}:{node|short} {remotenames}\n" |
|
|||
546 |
|
||||
547 | $ hg log -r 'remotebranches(defu, server)' -GT "{rev}:{node|short} {remotebranches}\n" |
|
|||
548 |
|
||||
549 | $ hg log -r 'remotebookmarks(delt, serv)' -GT "{rev}:{node|short} {remotebookmarks}\n" |
|
|||
550 |
|
502 | |||
551 | Testing pattern matching |
|
503 | Testing pattern matching | |
552 |
|
504 | |||
@@ -569,12 +521,3 b' Testing pattern matching' | |||||
569 | o 9:f34adec73c21 server2/wat |
|
521 | o 9:f34adec73c21 server2/wat | |
570 | | |
|
522 | | | |
571 | ~ |
|
523 | ~ | |
572 |
|
||||
573 | $ hg log -r 'remotebookmarks("re:def", "re:.*2")' -GT "{rev}:{node|short} {remotebookmarks}\n" |
|
|||
574 | o 8:3e1487808078 default/foo |
|
|||
575 | : |
|
|||
576 | : o 6:87d6d6676308 default/bar server2/bar |
|
|||
577 | :/ |
|
|||
578 | o 3:62615734edd5 server2/foo |
|
|||
579 | | |
|
|||
580 | ~ |
|
General Comments 0
You need to be logged in to leave comments.
Login now