Show More
@@ -116,6 +116,38 b' def updatecache(repo):' | |||
|
116 | 116 | assert partial.validfor(repo), filtername |
|
117 | 117 | repo._branchcaches[repo.filtername] = partial |
|
118 | 118 | |
|
119 | def replacecache(repo, bm): | |
|
120 | """Replace the branchmap cache for a repo with a branch mapping. | |
|
121 | ||
|
122 | This is likely only called during clone with a branch map from a remote. | |
|
123 | """ | |
|
124 | rbheads = [] | |
|
125 | closed = [] | |
|
126 | for bheads in bm.itervalues(): | |
|
127 | rbheads.extend(bheads) | |
|
128 | for h in bheads: | |
|
129 | r = repo.changelog.rev(h) | |
|
130 | b, c = repo.changelog.branchinfo(r) | |
|
131 | if c: | |
|
132 | closed.append(h) | |
|
133 | ||
|
134 | if rbheads: | |
|
135 | rtiprev = max((int(repo.changelog.rev(node)) | |
|
136 | for node in rbheads)) | |
|
137 | cache = branchcache(bm, | |
|
138 | repo[rtiprev].node(), | |
|
139 | rtiprev, | |
|
140 | closednodes=closed) | |
|
141 | ||
|
142 | # Try to stick it as low as possible | |
|
143 | # filter above served are unlikely to be fetch from a clone | |
|
144 | for candidate in ('base', 'immutable', 'served'): | |
|
145 | rview = repo.filtered(candidate) | |
|
146 | if cache.validfor(rview): | |
|
147 | repo._branchcaches[candidate] = cache | |
|
148 | cache.write(rview) | |
|
149 | break | |
|
150 | ||
|
119 | 151 | class branchcache(dict): |
|
120 | 152 | """A dict like object that hold branches heads cache. |
|
121 | 153 |
@@ -253,31 +253,8 b' def applyremotedata(repo, remotereqs, re' | |||
|
253 | 253 | repo._writerequirements() |
|
254 | 254 | |
|
255 | 255 | if remotebranchmap: |
|
256 | rbheads = [] | |
|
257 | closed = [] | |
|
258 | for bheads in remotebranchmap.itervalues(): | |
|
259 | rbheads.extend(bheads) | |
|
260 | for h in bheads: | |
|
261 | r = repo.changelog.rev(h) | |
|
262 | b, c = repo.changelog.branchinfo(r) | |
|
263 | if c: | |
|
264 | closed.append(h) | |
|
256 | branchmap.replacecache(repo, remotebranchmap) | |
|
265 | 257 | |
|
266 | if rbheads: | |
|
267 | rtiprev = max((int(repo.changelog.rev(node)) | |
|
268 | for node in rbheads)) | |
|
269 | cache = branchmap.branchcache(remotebranchmap, | |
|
270 | repo[rtiprev].node(), | |
|
271 | rtiprev, | |
|
272 | closednodes=closed) | |
|
273 | # Try to stick it as low as possible | |
|
274 | # filter above served are unlikely to be fetch from a clone | |
|
275 | for candidate in ('base', 'immutable', 'served'): | |
|
276 | rview = repo.filtered(candidate) | |
|
277 | if cache.validfor(rview): | |
|
278 | repo._branchcaches[candidate] = cache | |
|
279 | cache.write(rview) | |
|
280 | break | |
|
281 | 258 | repo.invalidate() |
|
282 | 259 | finally: |
|
283 | 260 | lock.release() |
General Comments 0
You need to be logged in to leave comments.
Login now