diff --git a/mercurial/exchange.py b/mercurial/exchange.py --- a/mercurial/exchange.py +++ b/mercurial/exchange.py @@ -522,8 +522,21 @@ 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. + try: + if not len(repo.file(b'.hgsub')) or not len(repo.file(b'.hgsubstate')): + return + except RuntimeError: + # Alternative filelog implementations might not implement this, + # so just fallback to the generic implementation. + pass + 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):