114 partial.write(repo) |
114 partial.write(repo) |
115 |
115 |
116 assert partial.validfor(repo), filtername |
116 assert partial.validfor(repo), filtername |
117 repo._branchcaches[repo.filtername] = partial |
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 class branchcache(dict): |
151 class branchcache(dict): |
120 """A dict like object that hold branches heads cache. |
152 """A dict like object that hold branches heads cache. |
121 |
153 |
122 This cache is used to avoid costly computations to determine all the |
154 This cache is used to avoid costly computations to determine all the |
123 branch heads of a repo. |
155 branch heads of a repo. |