Patchwork D12135: branchmap: don't add branch entries if there are no heads

login
register
mail settings
Submitter phabricator
Date Feb. 7, 2022, 6:41 a.m.
Message ID <differential-rev-PHID-DREV-jmpazilboiutyeti2enh-req@mercurial-scm.org>
Download mbox | patch
Permalink /patch/50469/
State New
Headers show

Comments

phabricator - Feb. 7, 2022, 6:41 a.m.
av6 created this revision.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.

REVISION SUMMARY
  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.

REPOSITORY
  rHG Mercurial

BRANCH
  default

REVISION DETAIL
  https://phab.mercurial-scm.org/D12135

AFFECTED FILES
  mercurial/branchmap.py

CHANGE DETAILS




To: av6, #hg-reviewers
Cc: mercurial-patches, mercurial-devel

Patch

diff --git a/mercurial/branchmap.py b/mercurial/branchmap.py
--- a/mercurial/branchmap.py
+++ b/mercurial/branchmap.py
@@ -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