Show More
@@ -15,7 +15,7 b' def read(repo):' | |||||
15 | lines = f.read().split('\n') |
|
15 | lines = f.read().split('\n') | |
16 | f.close() |
|
16 | f.close() | |
17 | except (IOError, OSError): |
|
17 | except (IOError, OSError): | |
18 |
return branchcache() |
|
18 | return branchcache() | |
19 |
|
19 | |||
20 | try: |
|
20 | try: | |
21 | last, lrev = lines.pop(0).split(" ", 1) |
|
21 | last, lrev = lines.pop(0).split(" ", 1) | |
@@ -33,13 +33,14 b' def read(repo):' | |||||
33 | '%s does not exist' % node) |
|
33 | '%s does not exist' % node) | |
34 | partial.setdefault(label, []).append(bin(node)) |
|
34 | partial.setdefault(label, []).append(bin(node)) | |
35 | partial.tipnode = last |
|
35 | partial.tipnode = last | |
|
36 | partial.tiprev = lrev | |||
36 | except KeyboardInterrupt: |
|
37 | except KeyboardInterrupt: | |
37 | raise |
|
38 | raise | |
38 | except Exception, inst: |
|
39 | except Exception, inst: | |
39 | if repo.ui.debugflag: |
|
40 | if repo.ui.debugflag: | |
40 | repo.ui.warn(str(inst), '\n') |
|
41 | repo.ui.warn(str(inst), '\n') | |
41 |
partial |
|
42 | partial = branchcache() | |
42 |
return partial |
|
43 | return partial | |
43 |
|
44 | |||
44 | def write(repo, branches, tip, tiprev): |
|
45 | def write(repo, branches, tip, tiprev): | |
45 | try: |
|
46 | try: | |
@@ -121,33 +122,33 b' def updatecache(repo):' | |||||
121 | return |
|
122 | return | |
122 |
|
123 | |||
123 | if partial is None or partial.tipnode not in cl.nodemap: |
|
124 | if partial is None or partial.tipnode not in cl.nodemap: | |
124 |
partial |
|
125 | partial = read(repo) | |
125 | else: |
|
|||
126 | lrev = cl.rev(partial.tipnode) |
|
|||
127 |
|
126 | |||
128 | catip = repo._cacheabletip() |
|
127 | catip = repo._cacheabletip() | |
129 | # if lrev == catip: cache is already up to date |
|
128 | # if partial.tiprev == catip: cache is already up to date | |
130 |
# if lrev > catip: we have uncachable element in `partial` can't |
|
129 | # if partial.tiprev > catip: we have uncachable element in `partial` can't | |
131 | # on disk |
|
130 | # write on disk | |
132 | if lrev < catip: |
|
131 | if partial.tiprev < catip: | |
133 | ctxgen = (repo[r] for r in cl.revs(lrev + 1, catip)) |
|
132 | ctxgen = (repo[r] for r in cl.revs(partial.tiprev + 1, catip)) | |
134 | update(repo, partial, ctxgen) |
|
133 | update(repo, partial, ctxgen) | |
135 | partial.tipnode = cl.node(catip) |
|
134 | partial.tipnode = cl.node(catip) | |
136 |
|
|
135 | partial.tiprev = catip | |
137 | lrev = catip |
|
136 | write(repo, partial, partial.tipnode, partial.tiprev) | |
138 | # If cacheable tip were lower than actual tip, we need to update the |
|
137 | # If cacheable tip were lower than actual tip, we need to update the | |
139 | # cache up to tip. This update (from cacheable to actual tip) is not |
|
138 | # cache up to tip. This update (from cacheable to actual tip) is not | |
140 | # written to disk since it's not cacheable. |
|
139 | # written to disk since it's not cacheable. | |
141 | tiprev = len(repo) - 1 |
|
140 | tiprev = len(repo) - 1 | |
142 | if lrev < tiprev: |
|
141 | if partial.tiprev < tiprev: | |
143 | ctxgen = (repo[r] for r in cl.revs(lrev + 1, tiprev)) |
|
142 | ctxgen = (repo[r] for r in cl.revs(partial.tiprev + 1, tiprev)) | |
144 | update(repo, partial, ctxgen) |
|
143 | update(repo, partial, ctxgen) | |
145 | partial.tipnode = cl.node(tiprev) |
|
144 | partial.tipnode = cl.node(tiprev) | |
|
145 | partial.tiprev = tiprev | |||
146 | repo._branchcache = partial |
|
146 | repo._branchcache = partial | |
147 |
|
147 | |||
148 | class branchcache(dict): |
|
148 | class branchcache(dict): | |
149 | """A dict like object that hold branches heads cache""" |
|
149 | """A dict like object that hold branches heads cache""" | |
150 |
|
150 | |||
151 | def __init__(self, entries=(), tipnode=nullid): |
|
151 | def __init__(self, entries=(), tipnode=nullid, tiprev=nullrev): | |
152 | super(branchcache, self).__init__(entries) |
|
152 | super(branchcache, self).__init__(entries) | |
153 | self.tipnode = tipnode |
|
153 | self.tipnode = tipnode | |
|
154 | self.tiprev = tiprev |
@@ -1434,13 +1434,13 b' class localrepository(object):' | |||||
1434 | # it, Otherwise, since nodes were destroyed, the cache is stale and this |
|
1434 | # it, Otherwise, since nodes were destroyed, the cache is stale and this | |
1435 | # will be caught the next time it is read. |
|
1435 | # will be caught the next time it is read. | |
1436 | if newheadnodes: |
|
1436 | if newheadnodes: | |
1437 | tiprev = len(self) - 1 |
|
|||
1438 | ctxgen = (self[node] for node in newheadnodes |
|
1437 | ctxgen = (self[node] for node in newheadnodes | |
1439 | if self.changelog.hasnode(node)) |
|
1438 | if self.changelog.hasnode(node)) | |
1440 |
|
|
1439 | cache = self._branchcache | |
1441 | self._branchcache.tipnode = self.changelog.tip() |
|
1440 | branchmap.update(self, cache, ctxgen) | |
1442 | branchmap.write(self, self._branchcache, self._branchcache.tipnode, |
|
1441 | cache.tipnode = self.changelog.tip() | |
1443 | tiprev) |
|
1442 | cache.tiprev = self.changelog.rev(cache.tipnode) | |
|
1443 | branchmap.write(self, cache, cache.tipnode, cache.tiprev) | |||
1444 |
|
1444 | |||
1445 | # Ensure the persistent tag cache is updated. Doing it now |
|
1445 | # Ensure the persistent tag cache is updated. Doing it now | |
1446 | # means that the tag cache only has to worry about destroyed |
|
1446 | # means that the tag cache only has to worry about destroyed | |
@@ -2495,9 +2495,10 b' class localrepository(object):' | |||||
2495 | rtiprev = max((int(self.changelog.rev(node)) |
|
2495 | rtiprev = max((int(self.changelog.rev(node)) | |
2496 | for node in rbheads)) |
|
2496 | for node in rbheads)) | |
2497 | cache = branchmap.branchcache(rbranchmap, |
|
2497 | cache = branchmap.branchcache(rbranchmap, | |
2498 |
self[rtiprev].node() |
|
2498 | self[rtiprev].node(), | |
|
2499 | rtiprev) | |||
2499 | self._branchcache = cache |
|
2500 | self._branchcache = cache | |
2500 |
branchmap.write(self, cache, cache.tipnode, |
|
2501 | branchmap.write(self, cache, cache.tipnode, cache.tiprev) | |
2501 | self.invalidate() |
|
2502 | self.invalidate() | |
2502 | return len(self.heads()) + 1 |
|
2503 | return len(self.heads()) + 1 | |
2503 | finally: |
|
2504 | finally: |
General Comments 0
You need to be logged in to leave comments.
Login now