mercurial/exchange.py
changeset 48549 28f0092ec89f
parent 48526 04688c51f81f
child 48875 6000f5b25c9b
--- 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):