##// END OF EJS Templates
branchmap: simplify update code...
Pierre-Yves David -
r20263:ea499675 default
parent child Browse files
Show More
@@ -221,7 +221,7 b' class branchcache(dict):'
221 221
222 222 def update(self, repo, revgen):
223 223 """Given a branchhead cache, self, that may have extra nodes or be
224 missing heads, and a generator of nodes that are at least a superset of
224 missing heads, and a generator of nodes that are strictly a superset of
225 225 heads missing, this function updates self to be correct.
226 226 """
227 227 cl = repo.changelog
@@ -239,32 +239,26 b' class branchcache(dict):'
239 239 for branch, newheadrevs in newbranches.iteritems():
240 240 bheads = self.setdefault(branch, [])
241 241 bheadrevs = [cl.rev(node) for node in bheads]
242 ctxisnew = bheadrevs and min(newheadrevs) > max(bheadrevs)
243 # Remove duplicates - nodes that are in newheadrevs and are already
244 # in bheadrevs. This can happen if you strip a node whose parent
245 # was already a head (because they're on different branches).
246 bheadrevs = sorted(set(bheadrevs).union(newheadrevs))
247 242
248 # Starting from tip means fewer passes over reachable. If we know
249 # the new candidates are not ancestors of existing heads, we don't
250 # have to examine ancestors of existing heads
251 if ctxisnew:
252 iterrevs = sorted(newheadrevs)
253 else:
254 iterrevs = list(bheadrevs)
243 # This have been tested True on all internal usage of this function.
244 # run it again in case of doubt
245 # assert not (set(bheadrevs) & set(newheadrevs))
246 newheadrevs.sort()
247 bheadrevs.extend(newheadrevs)
248 bheadrevs.sort()
255 249
256 250 # This loop prunes out two kinds of heads - heads that are
257 251 # superseded by a head in newheadrevs, and newheadrevs that are not
258 252 # heads because an existing head is their descendant.
259 while iterrevs:
260 latest = iterrevs.pop()
253 while newheadrevs:
254 latest = newheadrevs.pop()
261 255 if latest not in bheadrevs:
262 256 continue
263 257 ancestors = set(cl.ancestors([latest], bheadrevs[0]))
264 258 if ancestors:
265 259 bheadrevs = [b for b in bheadrevs if b not in ancestors]
266 260 self[branch] = [cl.node(rev) for rev in bheadrevs]
267 tiprev = max(bheadrevs)
261 tiprev = bheadrevs[-1]
268 262 if tiprev > self.tiprev:
269 263 self.tipnode = cl.node(tiprev)
270 264 self.tiprev = tiprev
1 NO CONTENT: modified file, binary diff hidden
General Comments 0
You need to be logged in to leave comments. Login now