Mercurial > public > mercurial-scm > hg
comparison mercurial/revset.py @ 20461:abd8e56a1038
revset: added lazyset implementation to contains revset
author | Lucas Moscovicz <lmoscovicz@fb.com> |
---|---|
date | Tue, 04 Feb 2014 15:07:03 -0800 |
parents | 3a88d0d0c6b6 |
children | c38e5556d87b |
comparison
equal
deleted
inserted
replaced
20460:3a88d0d0c6b6 | 20461:abd8e56a1038 |
---|---|
533 relative to the current directory and match against a file exactly | 533 relative to the current directory and match against a file exactly |
534 for efficiency. | 534 for efficiency. |
535 """ | 535 """ |
536 # i18n: "contains" is a keyword | 536 # i18n: "contains" is a keyword |
537 pat = getstring(x, _("contains requires a pattern")) | 537 pat = getstring(x, _("contains requires a pattern")) |
538 s = [] | 538 |
539 if not matchmod.patkind(pat): | 539 def matches(x): |
540 pat = pathutil.canonpath(repo.root, repo.getcwd(), pat) | 540 if not matchmod.patkind(pat): |
541 for r in subset: | 541 pats = pathutil.canonpath(repo.root, repo.getcwd(), pat) |
542 if pat in repo[r]: | 542 if pats in repo[x]: |
543 s.append(r) | 543 return True |
544 else: | 544 else: |
545 m = None | 545 c = repo[x] |
546 for r in subset: | 546 m = matchmod.match(repo.root, repo.getcwd(), [pat], ctx=c) |
547 c = repo[r] | |
548 if not m or matchmod.patkind(pat) == 'set': | |
549 m = matchmod.match(repo.root, repo.getcwd(), [pat], ctx=c) | |
550 for f in c.manifest(): | 547 for f in c.manifest(): |
551 if m(f): | 548 if m(f): |
552 s.append(r) | 549 return True |
553 break | 550 return False |
554 return baseset(s) | 551 |
552 return lazyset(subset, matches) | |
555 | 553 |
556 def converted(repo, subset, x): | 554 def converted(repo, subset, x): |
557 """``converted([id])`` | 555 """``converted([id])`` |
558 Changesets converted from the given identifier in the old repository if | 556 Changesets converted from the given identifier in the old repository if |
559 present, or all converted changesets if no identifier is specified. | 557 present, or all converted changesets if no identifier is specified. |