Mercurial > public > mercurial-scm > hg-stable
comparison mercurial/revset.py @ 24374:77fd1fb538cd
revbranchcache: store repo on the object
Previously we would instantiate the revbranchcache with a repo object, use it
briefly, then require it be passed in every time we wanted to fetch any
information. This seems unnecessary since it's obviously specific to that repo
(since it was constructed with it).
This patch stores the repo on the revbranchcache object, and removes the repo
parameter from the various functions on that class. This has the other nice
benefit of removing the double-revbranchcache-read that existed before (it was
read once for the branch revset, and once for the repo.revbranchcache).
author | Durham Goode <durham@fb.com> |
---|---|
date | Tue, 10 Feb 2015 19:57:51 -0800 |
parents | e8ea31131705 |
children | 0e41f110e69e |
comparison
equal
deleted
inserted
replaced
24373:59cc09240afb | 24374:77fd1fb538cd |
---|---|
526 | 526 |
527 If `string` starts with `re:`, the remainder of the name is treated as | 527 If `string` starts with `re:`, the remainder of the name is treated as |
528 a regular expression. To match a branch that actually starts with `re:`, | 528 a regular expression. To match a branch that actually starts with `re:`, |
529 use the prefix `literal:`. | 529 use the prefix `literal:`. |
530 """ | 530 """ |
531 import branchmap | 531 getbi = repo.revbranchcache().branchinfo |
532 urepo = repo.unfiltered() | |
533 ucl = urepo.changelog | |
534 getbi = branchmap.revbranchcache(urepo, readonly=True).branchinfo | |
535 | 532 |
536 try: | 533 try: |
537 b = getstring(x, '') | 534 b = getstring(x, '') |
538 except error.ParseError: | 535 except error.ParseError: |
539 # not a string, but another revspec, e.g. tip() | 536 # not a string, but another revspec, e.g. tip() |
542 kind, pattern, matcher = _stringmatcher(b) | 539 kind, pattern, matcher = _stringmatcher(b) |
543 if kind == 'literal': | 540 if kind == 'literal': |
544 # note: falls through to the revspec case if no branch with | 541 # note: falls through to the revspec case if no branch with |
545 # this name exists | 542 # this name exists |
546 if pattern in repo.branchmap(): | 543 if pattern in repo.branchmap(): |
547 return subset.filter(lambda r: matcher(getbi(ucl, r)[0])) | 544 return subset.filter(lambda r: matcher(getbi(r)[0])) |
548 else: | 545 else: |
549 return subset.filter(lambda r: matcher(getbi(ucl, r)[0])) | 546 return subset.filter(lambda r: matcher(getbi(r)[0])) |
550 | 547 |
551 s = getset(repo, fullreposet(repo), x) | 548 s = getset(repo, fullreposet(repo), x) |
552 b = set() | 549 b = set() |
553 for r in s: | 550 for r in s: |
554 b.add(getbi(ucl, r)[0]) | 551 b.add(getbi(r)[0]) |
555 c = s.__contains__ | 552 c = s.__contains__ |
556 return subset.filter(lambda r: c(r) or getbi(ucl, r)[0] in b) | 553 return subset.filter(lambda r: c(r) or getbi(r)[0] in b) |
557 | 554 |
558 def bumped(repo, subset, x): | 555 def bumped(repo, subset, x): |
559 """``bumped()`` | 556 """``bumped()`` |
560 Mutable changesets marked as successors of public changesets. | 557 Mutable changesets marked as successors of public changesets. |
561 | 558 |