diff -r 88a45330b290 -r 28f0092ec89f mercurial/exchange.py --- a/mercurial/exchange.py Wed Jan 05 11:34:54 2022 -0800 +++ b/mercurial/exchange.py Mon Jan 03 01:09:56 2022 +0100 @@ -521,8 +521,16 @@ def _checksubrepostate(pushop): """Ensure all outgoing referenced subrepo revisions are present locally""" + + repo = pushop.repo + + # If the repository does not use subrepos, skip the expensive + # manifest checks. + if not len(repo.file(b'.hgsub')) or not len(repo.file(b'.hgsubstate')): + return + for n in pushop.outgoing.missing: - ctx = pushop.repo[n] + ctx = repo[n] if b'.hgsub' in ctx.manifest() and b'.hgsubstate' in ctx.files(): for subpath in sorted(ctx.substate):