Show More
@@ -347,27 +347,17 b' def remotebrancheskw(context, mapping):' | |||
|
347 | 347 | return templateutil.compatlist(context, mapping, 'remotebranch', |
|
348 | 348 | remotebranches, plural='remotebranches') |
|
349 | 349 | |
|
350 |
def _revsetutil(repo, subset, x, rtypes, ar |
|
|
350 | def _revsetutil(repo, subset, x, rtypes, matcher): | |
|
351 | 351 | """utility function to return a set of revs based on the rtypes""" |
|
352 | 352 | |
|
353 | 353 | revs = set() |
|
354 | 354 | cl = repo.changelog |
|
355 | literals, matchers = args | |
|
356 | # whether arguments were passed or not | |
|
357 | argspassed = bool(literals or matchers) | |
|
358 | 355 | for rtype in rtypes: |
|
359 | 356 | if rtype in repo.names: |
|
360 | 357 | ns = repo.names[rtype] |
|
361 | 358 | for name in ns.listnames(repo): |
|
362 |
if |
|
|
363 | if name in literals: | |
|
364 | revs.update(ns.nodes(repo, name)) | |
|
359 | if not matcher(name): | |
|
365 | 360 |
|
|
366 | for matcher in matchers: | |
|
367 | if matcher(name): | |
|
368 | revs.update(ns.nodes(repo, name)) | |
|
369 | break | |
|
370 | else: | |
|
371 | 361 |
|
|
372 | 362 | |
|
373 | 363 | results = (cl.rev(n) for n in revs if cl.hasnode(n)) |
@@ -376,48 +366,29 b' def _revsetutil(repo, subset, x, rtypes,' | |||
|
376 | 366 | def _parseargs(x): |
|
377 | 367 | """parses the argument passed in revsets |
|
378 | 368 | |
|
379 | returns (literals, matchers) where, | |
|
380 | literals is a set of literals passed by user | |
|
381 | matchers is a list of matcher objects for patterns passed by user | |
|
369 | Returns a matcher for the passed pattern. | |
|
382 | 370 | """ |
|
383 | ||
|
384 | # set of paths passed as literals | |
|
385 | literals = set() | |
|
386 | # list of matcher to match the patterns passed as names | |
|
387 | matchers = [] | |
|
388 | ||
|
389 | if not x: | |
|
390 | return literals, matchers | |
|
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 | |
|
391 | 377 | |
|
392 | args = set() | |
|
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, ...])') | |
|
378 | @revsetpredicate('remotenames([name])') | |
|
406 | 379 | def remotenamesrevset(repo, subset, x): |
|
407 |
"""All changesets which have a remotename on them. If |
|
|
408 |
remotenames of |
|
|
380 | """All changesets which have a remotename on them. If `name` is | |
|
381 | specified, only remotenames of matching remote paths are considered. | |
|
409 | 382 | |
|
410 | 383 | Pattern matching is supported for `name`. See :hg:`help revisions.patterns`. |
|
411 | 384 | """ |
|
412 | ||
|
413 | args = _parseargs(x) | |
|
414 | 385 | return _revsetutil(repo, subset, x, ('remotebookmarks', 'remotebranches'), |
|
415 | args) | |
|
386 | _parseargs(x)) | |
|
416 | 387 | |
|
417 |
@revsetpredicate('remotebranches([name |
|
|
388 | @revsetpredicate('remotebranches([name])') | |
|
418 | 389 | def remotebranchesrevset(repo, subset, x): |
|
419 |
"""All changesets which are branch heads on remotes. If |
|
|
420 |
|
|
|
390 | """All changesets which are branch heads on remotes. If `name` is | |
|
391 | specified, only remotenames of matching remote paths are considered. | |
|
421 | 392 | |
|
422 | 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 | 396 | args = _parseargs(x) |
|
426 | 397 | return _revsetutil(repo, subset, x, ('remotebranches',), args) |
|
427 | 398 | |
|
428 |
@revsetpredicate('remotebookmarks([name |
|
|
399 | @revsetpredicate('remotebookmarks([name])') | |
|
429 | 400 | def remotebmarksrevset(repo, subset, x): |
|
430 |
"""All changesets which have bookmarks on remotes. If |
|
|
431 |
|
|
|
401 | """All changesets which have bookmarks on remotes. If `name` is | |
|
402 | specified, only remotenames of matching remote paths are considered. | |
|
432 | 403 | |
|
433 | 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 | 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 | 491 | $ hg log -r 'remotenames("re:default", "re:server2")' -GT "{rev}:{node|short} {remotenames}\n" |
|
492 | o 10:bf433e48adea server2/default | |
|
493 | | | |
|
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 | ~ | |
|
492 | hg: parse error: only one argument accepted | |
|
493 | [255] | |
|
505 | 494 | |
|
506 | 495 | $ hg log -r 'remotebranches("default/wat", "server2/wat")' -GT "{rev}:{node|short} {remotebranches}\n" |
|
507 | o 9:f34adec73c21 server2/wat | |
|
508 | | | |
|
509 | o 8:3e1487808078 default/wat | |
|
510 | | | |
|
511 | ~ | |
|
496 | hg: parse error: only one argument accepted | |
|
497 | [255] | |
|
512 | 498 | |
|
513 | 499 | $ hg log -r 'remotebookmarks("default/foo", "server2/foo")' -GT "{rev}:{node|short} {remotebookmarks}\n" |
|
514 | o 8:3e1487808078 default/foo | |
|
515 | : | |
|
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" | |
|
500 | hg: parse error: only one argument accepted | |
|
501 | [255] | |
|
550 | 502 | |
|
551 | 503 | Testing pattern matching |
|
552 | 504 | |
@@ -569,12 +521,3 b' Testing pattern matching' | |||
|
569 | 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