Show More
@@ -9,13 +9,13 b' from node import bin, hex, nullid, nullr' | |||||
9 | import encoding |
|
9 | import encoding | |
10 |
|
10 | |||
11 | def read(repo): |
|
11 | def read(repo): | |
12 |
partial = |
|
12 | partial = branchcache() | |
13 | try: |
|
13 | try: | |
14 | f = repo.opener("cache/branchheads") |
|
14 | f = repo.opener("cache/branchheads") | |
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 |
|
18 | return branchcache(), nullid, nullrev | |
19 |
|
19 | |||
20 | try: |
|
20 | try: | |
21 | last, lrev = lines.pop(0).split(" ", 1) |
|
21 | last, lrev = lines.pop(0).split(" ", 1) | |
@@ -37,7 +37,7 b' def read(repo):' | |||||
37 | except Exception, inst: |
|
37 | except Exception, inst: | |
38 | if repo.ui.debugflag: |
|
38 | if repo.ui.debugflag: | |
39 | repo.ui.warn(str(inst), '\n') |
|
39 | repo.ui.warn(str(inst), '\n') | |
40 |
partial, last, lrev = |
|
40 | partial, last, lrev = branchcache(), nullid, nullrev | |
41 | return partial, last, lrev |
|
41 | return partial, last, lrev | |
42 |
|
42 | |||
43 | def write(repo, branches, tip, tiprev): |
|
43 | def write(repo, branches, tip, tiprev): | |
@@ -143,3 +143,7 b' def updatecache(repo):' | |||||
143 | update(repo, partial, ctxgen) |
|
143 | update(repo, partial, ctxgen) | |
144 | repo._branchcache = partial |
|
144 | repo._branchcache = partial | |
145 | repo._branchcachetip = tip |
|
145 | repo._branchcachetip = tip | |
|
146 | ||||
|
147 | class branchcache(dict): | |||
|
148 | """A dict like object that hold branches heads cache""" | |||
|
149 |
@@ -193,8 +193,9 b' def _headssummary(repo, remote, outgoing' | |||||
193 |
|
193 | |||
194 | # D. Update newmap with outgoing changes. |
|
194 | # D. Update newmap with outgoing changes. | |
195 | # This will possibly add new heads and remove existing ones. |
|
195 | # This will possibly add new heads and remove existing ones. | |
196 | newmap = dict((branch, heads[1]) for branch, heads in headssum.iteritems() |
|
196 | newmap = branchmap.branchcache((branch, heads[1]) | |
197 | if heads[0] is not None) |
|
197 | for branch, heads in headssum.iteritems() | |
|
198 | if heads[0] is not None) | |||
198 | branchmap.update(repo, newmap, missingctx) |
|
199 | branchmap.update(repo, newmap, missingctx) | |
199 | for branch, newheads in newmap.iteritems(): |
|
200 | for branch, newheads in newmap.iteritems(): | |
200 | headssum[branch][1][:] = newheads |
|
201 | headssum[branch][1][:] = newheads |
@@ -666,7 +666,7 b' class localrepository(object):' | |||||
666 | '''returns a dictionary {branch: [branchheads]}''' |
|
666 | '''returns a dictionary {branch: [branchheads]}''' | |
667 | if self.changelog.filteredrevs: |
|
667 | if self.changelog.filteredrevs: | |
668 | # some changeset are excluded we can't use the cache |
|
668 | # some changeset are excluded we can't use the cache | |
669 |
bmap = |
|
669 | bmap = branchmap.branchcache() | |
670 | branchmap.update(self, bmap, (self[r] for r in self)) |
|
670 | branchmap.update(self, bmap, (self[r] for r in self)) | |
671 | return bmap |
|
671 | return bmap | |
672 | else: |
|
672 | else: | |
@@ -2495,7 +2495,7 b' class localrepository(object):' | |||||
2495 | if rbheads: |
|
2495 | if rbheads: | |
2496 | rtiprev = max((int(self.changelog.rev(node)) |
|
2496 | rtiprev = max((int(self.changelog.rev(node)) | |
2497 | for node in rbheads)) |
|
2497 | for node in rbheads)) | |
2498 | self._branchcache = rbranchmap |
|
2498 | self._branchcache = branchmap.branchcache(rbranchmap) | |
2499 | rtipnode = self._branchcachetip = self[rtiprev].node() |
|
2499 | rtipnode = self._branchcachetip = self[rtiprev].node() | |
2500 | branchmap.write(self, self._branchcache, rtipnode, rtiprev) |
|
2500 | branchmap.write(self, self._branchcache, rtipnode, rtiprev) | |
2501 | self.invalidate() |
|
2501 | self.invalidate() |
General Comments 0
You need to be logged in to leave comments.
Login now