D11956: exchange: add fast path for subrepo check on push
joerg.sonnenberger (Joerg Sonnenberger)
phabricator at mercurial-scm.org
Mon Jan 3 00:30:06 UTC 2022
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
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):
To: joerg.sonnenberger, #hg-reviewers
Cc: mercurial-patches, mercurial-devel
More information about the Mercurial-devel
mailing list