# HG changeset patch # User Anton Shestakov # Date 1644165099 -10800 # Node ID 8b393f40a5e665a579c6a8ac655785eeb41357a4 # Parent ae27a0684e75679c34a59bb0f92ecd580be1bd38 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 diff -r ae27a0684e75 -r 8b393f40a5e6 mercurial/branchmap.py --- a/mercurial/branchmap.py Sun Feb 06 19:14:51 2022 +0300 +++ b/mercurial/branchmap.py Sun Feb 06 19:31:39 2022 +0300 @@ -519,7 +519,7 @@ # checks can be skipped. Otherwise, the ancestors of the # "uncertain" set are removed from branchheads. # This computation is heavy and avoided if at all possible. - bheads = self._entries.setdefault(branch, []) + bheads = self._entries.get(branch, []) bheadset = {cl.rev(node) for node in bheads} uncertain = set() for newrev in sorted(newheadrevs): @@ -562,8 +562,8 @@ if floorrev <= max(uncertain): ancestors = set(cl.ancestors(uncertain, floorrev)) bheadset -= ancestors - bheadrevs = sorted(bheadset) - self[branch] = [cl.node(rev) for rev in bheadrevs] + if bheadset: + self[branch] = [cl.node(rev) for rev in sorted(bheadset)] tiprev = max(newheadrevs) if tiprev > ntiprev: ntiprev = tiprev