Mercurial > public > mercurial-scm > hg-stable
comparison mercurial/branchmap.py @ 18234:a55b06885cda
branchmap: allow to use cache of subset
Filtered repository are *subset* of unfiltered repository. This means that a
filtered branchmap could be use to compute the unfiltered version.
And filtered version happen to be subset of each other:
- "all() - unserved()" is a subset of "all() - hidden()"
- "all() - hidden()" is a subset of "all()"
This means that branchmap with "unfiltered" filter can be used as a base for
"hidden" branchmap that itself could be used as a base for unfiltered
branchmap.
unserved < hidden < None
This changeset implements this mechanism. If the on disk branchcache is not valid
we use the branchcache of the nearest subset as base instead of computing it from
scratch. Such fallback can be cascaded multiple time is necessary.
Note that both "hidden" and "unserved" set are a bit volatile. We will add more
stable filtering in next changesets.
This changeset enables collaboration between no filtering and "unserved"
filtering. Fixing performance regression introduced by 47f00b0de337
author | Pierre-Yves David <pierre-yves.david@ens-lyon.org> |
---|---|
date | Mon, 07 Jan 2013 17:23:25 +0100 |
parents | dd0b636b0b65 |
children | 2502a15e033d |
comparison
equal
deleted
inserted
replaced
18233:59a9f18d4587 | 18234:a55b06885cda |
---|---|
5 # This software may be used and distributed according to the terms of the | 5 # This software may be used and distributed according to the terms of the |
6 # GNU General Public License version 2 or any later version. | 6 # GNU General Public License version 2 or any later version. |
7 | 7 |
8 from node import bin, hex, nullid, nullrev | 8 from node import bin, hex, nullid, nullrev |
9 import encoding | 9 import encoding |
10 import util | 10 import util, repoview |
11 | 11 |
12 def _filename(repo): | 12 def _filename(repo): |
13 """name of a branchcache file for a given repo or repoview""" | 13 """name of a branchcache file for a given repo or repoview""" |
14 filename = "cache/branchheads" | 14 filename = "cache/branchheads" |
15 if repo.filtername: | 15 if repo.filtername: |
61 def updatecache(repo): | 61 def updatecache(repo): |
62 cl = repo.changelog | 62 cl = repo.changelog |
63 filtername = repo.filtername | 63 filtername = repo.filtername |
64 partial = repo._branchcaches.get(filtername) | 64 partial = repo._branchcaches.get(filtername) |
65 | 65 |
66 revs = [] | |
66 if partial is None or not partial.validfor(repo): | 67 if partial is None or not partial.validfor(repo): |
67 partial = read(repo) | 68 partial = read(repo) |
68 if partial is None: | 69 if partial is None: |
69 partial = branchcache() | 70 subsetname = repoview.subsettable.get(filtername) |
70 | 71 if subsetname is None: |
71 revs = list(cl.revs(start=partial.tiprev +1)) | 72 partial = branchcache() |
73 else: | |
74 subset = repo.filtered(subsetname) | |
75 partial = subset.branchmap().copy() | |
76 extrarevs = subset.changelog.filteredrevs - cl.filteredrevs | |
77 revs.extend(r for r in extrarevs if r <= partial.tiprev) | |
78 revs.extend(cl.revs(start=partial.tiprev + 1)) | |
72 if revs: | 79 if revs: |
73 ctxgen = (repo[r] for r in revs) | 80 ctxgen = (repo[r] for r in revs) |
74 partial.update(repo, ctxgen) | 81 partial.update(repo, ctxgen) |
75 partial.write(repo) | 82 partial.write(repo) |
83 assert partial.validfor(repo) | |
76 repo._branchcaches[repo.filtername] = partial | 84 repo._branchcaches[repo.filtername] = partial |
77 | 85 |
78 class branchcache(dict): | 86 class branchcache(dict): |
79 """A dict like object that hold branches heads cache""" | 87 """A dict like object that hold branches heads cache""" |
80 | 88 |