##// END OF EJS Templates
branchmap: make update responsible to update the cache key...
Pierre-Yves David -
r18130:1b05ffce default
parent child Browse files
Show More
@@ -91,17 +91,39 b' def update(repo, partial, ctxgen):'
91 91 if ancestors:
92 92 bheadrevs = [b for b in bheadrevs if b not in ancestors]
93 93 partial[branch] = [cl.node(rev) for rev in bheadrevs]
94 tiprev = max(bheadrevs)
95 if tiprev > partial.tiprev:
96 partial.tipnode = cl.node(tiprev)
97 partial.tiprev = tiprev
98
94 99
95 100 # There may be branches that cease to exist when the last commit in the
96 101 # branch was stripped. This code filters them out. Note that the
97 102 # branch that ceased to exist may not be in newbranches because
98 103 # newbranches is the set of candidate heads, which when you strip the
99 104 # last commit in a branch will be the parent branch.
105 droppednodes = []
100 106 for branch in partial.keys():
101 107 nodes = [head for head in partial[branch]
102 108 if cl.hasnode(head)]
103 109 if not nodes:
110 droppednodes.extend(nodes)
104 111 del partial[branch]
112 try:
113 node = cl.node(partial.tiprev)
114 except IndexError:
115 node = None
116 if ((partial.tipnode != node)
117 or (partial.tipnode in droppednodes)):
118 # cache key are not valid anymore
119 partial.tipnode = nullid
120 partial.tiprev = nullrev
121 for heads in partial.values():
122 tiprev = max(cl.rev(node) for node in heads)
123 if tiprev > partial.tiprev:
124 partial.tipnode = cl.node(tiprev)
125 partial.tiprev = tiprev
126
105 127
106 128 def updatecache(repo):
107 129 repo = repo.unfiltered() # Until we get a smarter cache management
@@ -121,8 +143,6 b' def updatecache(repo):'
121 143 if partial.tiprev < catip:
122 144 ctxgen = (repo[r] for r in cl.revs(partial.tiprev + 1, catip))
123 145 update(repo, partial, ctxgen)
124 partial.tipnode = cl.node(catip)
125 partial.tiprev = catip
126 146 partial.write(repo)
127 147 # If cacheable tip were lower than actual tip, we need to update the
128 148 # cache up to tip. This update (from cacheable to actual tip) is not
@@ -131,8 +151,6 b' def updatecache(repo):'
131 151 if partial.tiprev < tiprev:
132 152 ctxgen = (repo[r] for r in cl.revs(partial.tiprev + 1, tiprev))
133 153 update(repo, partial, ctxgen)
134 partial.tipnode = cl.node(tiprev)
135 partial.tiprev = tiprev
136 154 repo._branchcache = partial
137 155
138 156 class branchcache(dict):
@@ -1438,8 +1438,6 b' class localrepository(object):'
1438 1438 if self.changelog.hasnode(node))
1439 1439 cache = self._branchcache
1440 1440 branchmap.update(self, cache, ctxgen)
1441 cache.tipnode = self.changelog.tip()
1442 cache.tiprev = self.changelog.rev(cache.tipnode)
1443 1441 cache.write(self)
1444 1442
1445 1443 # Ensure the persistent tag cache is updated. Doing it now
General Comments 0
You need to be logged in to leave comments. Login now