446 if args: |
446 if args: |
447 bm = getstring(args[0], |
447 bm = getstring(args[0], |
448 # i18n: "bookmark" is a keyword |
448 # i18n: "bookmark" is a keyword |
449 _('the argument to bookmark must be a string')) |
449 _('the argument to bookmark must be a string')) |
450 kind, pattern, matcher = _stringmatcher(bm) |
450 kind, pattern, matcher = _stringmatcher(bm) |
|
451 bms = set() |
451 if kind == 'literal': |
452 if kind == 'literal': |
452 bmrev = repo._bookmarks.get(pattern, None) |
453 bmrev = repo._bookmarks.get(pattern, None) |
453 if not bmrev: |
454 if not bmrev: |
454 raise util.Abort(_("bookmark '%s' does not exist") % bm) |
455 raise util.Abort(_("bookmark '%s' does not exist") % bm) |
455 bmrev = repo[bmrev].rev() |
456 bms.add(repo[bmrev].rev()) |
456 return subset.filter(lambda r: r == bmrev) |
|
457 else: |
457 else: |
458 matchrevs = set() |
458 matchrevs = set() |
459 for name, bmrev in repo._bookmarks.iteritems(): |
459 for name, bmrev in repo._bookmarks.iteritems(): |
460 if matcher(name): |
460 if matcher(name): |
461 matchrevs.add(bmrev) |
461 matchrevs.add(bmrev) |
462 if not matchrevs: |
462 if not matchrevs: |
463 raise util.Abort(_("no bookmarks exist that match '%s'") |
463 raise util.Abort(_("no bookmarks exist that match '%s'") |
464 % pattern) |
464 % pattern) |
465 bmrevs = set() |
|
466 for bmrev in matchrevs: |
465 for bmrev in matchrevs: |
467 bmrevs.add(repo[bmrev].rev()) |
466 bms.add(repo[bmrev].rev()) |
468 return subset & bmrevs |
467 else: |
469 |
468 bms = set([repo[r].rev() |
470 bms = set([repo[r].rev() |
469 for r in repo._bookmarks.values()]) |
471 for r in repo._bookmarks.values()]) |
|
472 return subset.filter(bms.__contains__) |
470 return subset.filter(bms.__contains__) |
473 |
471 |
474 def branch(repo, subset, x): |
472 def branch(repo, subset, x): |
475 """``branch(string or set)`` |
473 """``branch(string or set)`` |
476 All changesets belonging to the given branch or the branches of the given |
474 All changesets belonging to the given branch or the branches of the given |