mercurial/branchmap.py
changeset 51532 a0ef462cf1a4
parent 51531 f85f23f1479b
child 51533 50850689d3c0
equal deleted inserted replaced
51531:f85f23f1479b 51532:a0ef462cf1a4
   282         missing heads, and a generator of nodes that are strictly a superset of
   282         missing heads, and a generator of nodes that are strictly a superset of
   283         heads missing, this function updates self to be correct.
   283         heads missing, this function updates self to be correct.
   284         """
   284         """
   285         starttime = util.timer()
   285         starttime = util.timer()
   286         cl = repo.changelog
   286         cl = repo.changelog
       
   287         # Faster than using ctx.obsolete()
       
   288         obsrevs = obsolete.getrevs(repo, b'obsolete')
   287         # collect new branch entries
   289         # collect new branch entries
   288         newbranches = {}
   290         newbranches = {}
   289         getbranchinfo = repo.revbranchcache().branchinfo
   291         getbranchinfo = repo.revbranchcache().branchinfo
   290         max_rev = -1
   292         max_rev = -1
   291         for r in revgen:
   293         for r in revgen:
       
   294             max_rev = max(max_rev, r)
       
   295             if r in obsrevs:
       
   296                 # We ignore obsolete changesets as they shouldn't be
       
   297                 # considered heads.
       
   298                 continue
   292             branch, closesbranch = getbranchinfo(r)
   299             branch, closesbranch = getbranchinfo(r)
   293             newbranches.setdefault(branch, []).append(r)
   300             newbranches.setdefault(branch, []).append(r)
   294             if closesbranch:
   301             if closesbranch:
   295                 self._closednodes.add(cl.node(r))
   302                 self._closednodes.add(cl.node(r))
   296             max_rev = max(max_rev, r)
       
   297         if max_rev < 0:
   303         if max_rev < 0:
   298             msg = "running branchcache.update without revision to update"
   304             msg = "running branchcache.update without revision to update"
   299             raise error.ProgrammingError(msg)
   305             raise error.ProgrammingError(msg)
   300 
   306 
   301         # Delay fetching the topological heads until they are needed.
   307         # Delay fetching the topological heads until they are needed.
   303         topoheads = None
   309         topoheads = None
   304 
   310 
   305         # If a changeset is visible, its parents must be visible too, so
   311         # If a changeset is visible, its parents must be visible too, so
   306         # use the faster unfiltered parent accessor.
   312         # use the faster unfiltered parent accessor.
   307         parentrevs = repo.unfiltered().changelog.parentrevs
   313         parentrevs = repo.unfiltered().changelog.parentrevs
   308 
       
   309         # Faster than using ctx.obsolete()
       
   310         obsrevs = obsolete.getrevs(repo, b'obsolete')
       
   311 
   314 
   312         for branch, newheadrevs in newbranches.items():
   315         for branch, newheadrevs in newbranches.items():
   313             # For every branch, compute the new branchheads.
   316             # For every branch, compute the new branchheads.
   314             # A branchhead is a revision such that no descendant is on
   317             # A branchhead is a revision such that no descendant is on
   315             # the same branch.
   318             # the same branch.
   347             #   This computation is heavy and avoided if at all possible.
   350             #   This computation is heavy and avoided if at all possible.
   348             bheads = self._entries.get(branch, [])
   351             bheads = self._entries.get(branch, [])
   349             bheadset = {cl.rev(node) for node in bheads}
   352             bheadset = {cl.rev(node) for node in bheads}
   350             uncertain = set()
   353             uncertain = set()
   351             for newrev in sorted(newheadrevs):
   354             for newrev in sorted(newheadrevs):
   352                 if newrev in obsrevs:
       
   353                     # We ignore obsolete changesets as they shouldn't be
       
   354                     # considered heads.
       
   355                     continue
       
   356 
       
   357                 if not bheadset:
   355                 if not bheadset:
   358                     bheadset.add(newrev)
   356                     bheadset.add(newrev)
   359                     continue
   357                     continue
   360 
   358 
   361                 parents = [p for p in parentrevs(newrev) if p != nullrev]
   359                 parents = [p for p in parentrevs(newrev) if p != nullrev]