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 |