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(), nullrev | |
19 |
|
19 | |||
20 | try: |
|
20 | try: | |
21 | last, lrev = lines.pop(0).split(" ", 1) |
|
21 | last, lrev = lines.pop(0).split(" ", 1) | |
@@ -32,13 +32,14 b' def read(repo):' | |||||
32 | raise ValueError('invalidating branch cache because node '+ |
|
32 | raise ValueError('invalidating branch cache because node '+ | |
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 | except KeyboardInterrupt: |
|
36 | except KeyboardInterrupt: | |
36 | raise |
|
37 | raise | |
37 | except Exception, inst: |
|
38 | except Exception, inst: | |
38 | if repo.ui.debugflag: |
|
39 | if repo.ui.debugflag: | |
39 | repo.ui.warn(str(inst), '\n') |
|
40 | repo.ui.warn(str(inst), '\n') | |
40 |
partial, |
|
41 | partial, lrev = branchcache(), nullrev | |
41 |
return partial, |
|
42 | return partial, lrev | |
42 |
|
43 | |||
43 | def write(repo, branches, tip, tiprev): |
|
44 | def write(repo, branches, tip, tiprev): | |
44 | try: |
|
45 | try: | |
@@ -115,15 +116,14 b' def updatecache(repo):' | |||||
115 | repo = repo.unfiltered() # Until we get a smarter cache management |
|
116 | repo = repo.unfiltered() # Until we get a smarter cache management | |
116 | cl = repo.changelog |
|
117 | cl = repo.changelog | |
117 | tip = cl.tip() |
|
118 | tip = cl.tip() | |
118 | if repo._branchcache is not None and repo._branchcachetip == tip: |
|
119 | partial = repo._branchcache | |
|
120 | if partial is not None and partial.tipnode == tip: | |||
119 | return |
|
121 | return | |
120 |
|
122 | |||
121 | oldtip = repo._branchcachetip |
|
123 | if partial is None or partial.tipnode not in cl.nodemap: | |
122 | if oldtip is None or oldtip not in cl.nodemap: |
|
124 | partial, lrev = read(repo) | |
123 | partial, last, lrev = read(repo) |
|
|||
124 | else: |
|
125 | else: | |
125 |
lrev = cl.rev( |
|
126 | lrev = cl.rev(partial.tipnode) | |
126 | partial = repo._branchcache |
|
|||
127 |
|
127 | |||
128 | catip = repo._cacheabletip() |
|
128 | catip = repo._cacheabletip() | |
129 | # if lrev == catip: cache is already up to date |
|
129 | # if lrev == catip: cache is already up to date | |
@@ -132,7 +132,8 b' def updatecache(repo):' | |||||
132 | if lrev < catip: |
|
132 | if lrev < catip: | |
133 | ctxgen = (repo[r] for r in cl.revs(lrev + 1, catip)) |
|
133 | ctxgen = (repo[r] for r in cl.revs(lrev + 1, catip)) | |
134 | update(repo, partial, ctxgen) |
|
134 | update(repo, partial, ctxgen) | |
135 |
|
|
135 | partial.tipnode = cl.node(catip) | |
|
136 | write(repo, partial, partial.tipnode, catip) | |||
136 | lrev = catip |
|
137 | lrev = catip | |
137 | # If cacheable tip were lower than actual tip, we need to update the |
|
138 | # If cacheable tip were lower than actual tip, we need to update the | |
138 | # cache up to tip. This update (from cacheable to actual tip) is not |
|
139 | # cache up to tip. This update (from cacheable to actual tip) is not | |
@@ -141,9 +142,12 b' def updatecache(repo):' | |||||
141 | if lrev < tiprev: |
|
142 | if lrev < tiprev: | |
142 | ctxgen = (repo[r] for r in cl.revs(lrev + 1, tiprev)) |
|
143 | ctxgen = (repo[r] for r in cl.revs(lrev + 1, tiprev)) | |
143 | update(repo, partial, ctxgen) |
|
144 | update(repo, partial, ctxgen) | |
|
145 | partial.tipnode = cl.node(tiprev) | |||
144 | repo._branchcache = partial |
|
146 | repo._branchcache = partial | |
145 | repo._branchcachetip = tip |
|
|||
146 |
|
147 | |||
147 | class branchcache(dict): |
|
148 | class branchcache(dict): | |
148 | """A dict like object that hold branches heads cache""" |
|
149 | """A dict like object that hold branches heads cache""" | |
149 |
|
150 | |||
|
151 | def __init__(self, entries=(), tipnode=nullid): | |||
|
152 | super(branchcache, self).__init__(entries) | |||
|
153 | self.tipnode = tipnode |
@@ -229,7 +229,6 b' class localrepository(object):' | |||||
229 |
|
229 | |||
230 |
|
230 | |||
231 | self._branchcache = None |
|
231 | self._branchcache = None | |
232 | self._branchcachetip = None |
|
|||
233 | self.filterpats = {} |
|
232 | self.filterpats = {} | |
234 | self._datafilters = {} |
|
233 | self._datafilters = {} | |
235 | self._transref = self._lockref = self._wlockref = None |
|
234 | self._transref = self._lockref = self._wlockref = None | |
@@ -979,7 +978,6 b' class localrepository(object):' | |||||
979 | del self.__dict__['_tagscache'] |
|
978 | del self.__dict__['_tagscache'] | |
980 |
|
979 | |||
981 | self.unfiltered()._branchcache = None # in UTF-8 |
|
980 | self.unfiltered()._branchcache = None # in UTF-8 | |
982 | self.unfiltered()._branchcachetip = None |
|
|||
983 | self.invalidatevolatilesets() |
|
981 | self.invalidatevolatilesets() | |
984 |
|
982 | |||
985 | def invalidatevolatilesets(self): |
|
983 | def invalidatevolatilesets(self): | |
@@ -1440,7 +1438,8 b' class localrepository(object):' | |||||
1440 | ctxgen = (self[node] for node in newheadnodes |
|
1438 | ctxgen = (self[node] for node in newheadnodes | |
1441 | if self.changelog.hasnode(node)) |
|
1439 | if self.changelog.hasnode(node)) | |
1442 | branchmap.update(self, self._branchcache, ctxgen) |
|
1440 | branchmap.update(self, self._branchcache, ctxgen) | |
1443 |
|
|
1441 | self._branchcache.tipnode = self.changelog.tip() | |
|
1442 | branchmap.write(self, self._branchcache, self._branchcache.tipnode, | |||
1444 | tiprev) |
|
1443 | tiprev) | |
1445 |
|
1444 | |||
1446 | # Ensure the persistent tag cache is updated. Doing it now |
|
1445 | # Ensure the persistent tag cache is updated. Doing it now | |
@@ -2495,9 +2494,10 b' class localrepository(object):' | |||||
2495 | if rbheads: |
|
2494 | if rbheads: | |
2496 | rtiprev = max((int(self.changelog.rev(node)) |
|
2495 | rtiprev = max((int(self.changelog.rev(node)) | |
2497 | for node in rbheads)) |
|
2496 | for node in rbheads)) | |
2498 |
|
|
2497 | cache = branchmap.branchcache(rbranchmap, | |
2499 |
|
|
2498 | self[rtiprev].node()) | |
2500 |
|
|
2499 | self._branchcache = cache | |
|
2500 | branchmap.write(self, cache, cache.tipnode, rtiprev) | |||
2501 | self.invalidate() |
|
2501 | self.invalidate() | |
2502 | return len(self.heads()) + 1 |
|
2502 | return len(self.heads()) + 1 | |
2503 | finally: |
|
2503 | finally: |
@@ -135,7 +135,6 b' class statichttprepository(localrepo.loc' | |||||
135 | self._tags = None |
|
135 | self._tags = None | |
136 | self.nodetagscache = None |
|
136 | self.nodetagscache = None | |
137 | self._branchcache = None |
|
137 | self._branchcache = None | |
138 | self._branchcachetip = None |
|
|||
139 | self.encodepats = None |
|
138 | self.encodepats = None | |
140 | self.decodepats = None |
|
139 | self.decodepats = None | |
141 |
|
140 |
General Comments 0
You need to be logged in to leave comments.
Login now