comparison mercurial/branchmap.py @ 48718:8b393f40a5e6

branchmap: don't add branch entries if there are no heads We definitely don't want any empty entries to be present in repo.branchmap() just for the sake of not breaking test-notify.t. No test changes required because the previous patch made notify extension to not raise any tracebacks in case of RepoLookupErrors. Differential Revision: https://phab.mercurial-scm.org/D12135
author Anton Shestakov <av6@dwimlabs.net>
date Sun, 06 Feb 2022 19:31:39 +0300
parents f8f2ecdde4b5
children 02e9ad08999b
comparison
equal deleted inserted replaced
48717:ae27a0684e75 48718:8b393f40a5e6
517 # kept in the "uncertain" set. If all branchheads are also 517 # kept in the "uncertain" set. If all branchheads are also
518 # topological heads, they can't have descendants and further 518 # topological heads, they can't have descendants and further
519 # checks can be skipped. Otherwise, the ancestors of the 519 # checks can be skipped. Otherwise, the ancestors of the
520 # "uncertain" set are removed from branchheads. 520 # "uncertain" set are removed from branchheads.
521 # This computation is heavy and avoided if at all possible. 521 # This computation is heavy and avoided if at all possible.
522 bheads = self._entries.setdefault(branch, []) 522 bheads = self._entries.get(branch, [])
523 bheadset = {cl.rev(node) for node in bheads} 523 bheadset = {cl.rev(node) for node in bheads}
524 uncertain = set() 524 uncertain = set()
525 for newrev in sorted(newheadrevs): 525 for newrev in sorted(newheadrevs):
526 if newrev in obsrevs: 526 if newrev in obsrevs:
527 # We ignore obsolete changesets as they shouldn't be 527 # We ignore obsolete changesets as they shouldn't be
560 if bheadset - topoheads: 560 if bheadset - topoheads:
561 floorrev = min(bheadset) 561 floorrev = min(bheadset)
562 if floorrev <= max(uncertain): 562 if floorrev <= max(uncertain):
563 ancestors = set(cl.ancestors(uncertain, floorrev)) 563 ancestors = set(cl.ancestors(uncertain, floorrev))
564 bheadset -= ancestors 564 bheadset -= ancestors
565 bheadrevs = sorted(bheadset) 565 if bheadset:
566 self[branch] = [cl.node(rev) for rev in bheadrevs] 566 self[branch] = [cl.node(rev) for rev in sorted(bheadset)]
567 tiprev = max(newheadrevs) 567 tiprev = max(newheadrevs)
568 if tiprev > ntiprev: 568 if tiprev > ntiprev:
569 ntiprev = tiprev 569 ntiprev = tiprev
570 570
571 if ntiprev > self.tiprev: 571 if ntiprev > self.tiprev: