changeset 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 ae27a0684e75
children 02e9ad08999b
files mercurial/branchmap.py
diffstat 1 files changed, 3 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- 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