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