Patchwork D11956: exchange: add fast path for subrepo check on push

login
register
mail settings
Submitter phabricator
Date Jan. 3, 2022, 12:30 a.m.
Message ID <differential-rev-PHID-DREV-t2egpb5ppoyg6zwfjlp3-req@mercurial-scm.org>
Download mbox | patch
Permalink /patch/50282/
State New
Headers show

Comments

phabricator - Jan. 3, 2022, 12:30 a.m.
joerg.sonnenberger created this revision.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.

REVISION SUMMARY
  Try to check if .hgsub and .hgsubstate exist at all before looking
  for them in every changeset to be pushed. The latter can be quite
  expensive for large repositories and the existance check is almost free.

REPOSITORY
  rHG Mercurial

BRANCH
  default

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

AFFECTED FILES
  mercurial/exchange.py

CHANGE DETAILS




To: joerg.sonnenberger, #hg-reviewers
Cc: mercurial-patches, mercurial-devel

Patch

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):