changeset 48549:28f0092ec89f

exchange: add fast path for subrepo check on push 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. Differential Revision: https://phab.mercurial-scm.org/D11956
author Joerg Sonnenberger <joerg@bec.de>
date Mon, 03 Jan 2022 01:09:56 +0100
parents 88a45330b290
children 21c0ae0693bc
files hgext/remotefilelog/README.md hgext/remotefilelog/remotefilelog.py mercurial/exchange.py relnotes/next
diffstat 4 files changed, 19 insertions(+), 7 deletions(-) [+]
line wrap: on
line diff
--- a/hgext/remotefilelog/README.md	Wed Jan 05 11:34:54 2022 -0800
+++ b/hgext/remotefilelog/README.md	Mon Jan 03 01:09:56 2022 +0100
@@ -88,7 +88,9 @@
 
 4. Tags are not supported in completely shallow repos. If you use tags in your repo you will have to specify `excludepattern=.hgtags` in your client configuration to ensure that file is downloaded. The include/excludepattern settings are experimental at the moment and have yet to be deployed in a production environment.
 
-5. A few commands will be slower. `hg log <filename>` will be much slower since it has to walk the entire commit history instead of just the filelog. Use `hg log -f <filename>` instead, which remains very fast.
+5. Similarly, subrepositories should not be used with completely shallow repos. Use `excludepattern=.hgsub*` in your client configuration to ensure that the files are downloaded.
+
+6. A few commands will be slower. `hg log <filename>` will be much slower since it has to walk the entire commit history instead of just the filelog. Use `hg log -f <filename>` instead, which remains very fast.
 
 Contributing
 ============
--- a/hgext/remotefilelog/remotefilelog.py	Wed Jan 05 11:34:54 2022 -0800
+++ b/hgext/remotefilelog/remotefilelog.py	Mon Jan 03 01:09:56 2022 +0100
@@ -244,11 +244,11 @@
     __bool__ = __nonzero__
 
     def __len__(self):
-        if self.filename == b'.hgtags':
-            # The length of .hgtags is used to fast path tag checking.
-            # remotefilelog doesn't support .hgtags since the entire .hgtags
-            # history is needed.  Use the excludepattern setting to make
-            # .hgtags a normal filelog.
+        if self.filename in (b'.hgtags', b'.hgsub', b'.hgsubstate'):
+            # Global tag and subrepository support require access to the
+            # file history for various performance sensitive operations.
+            # excludepattern should be used for repositories depending on
+            # those features to fallback to regular filelog.
             return 0
 
         raise RuntimeError(b"len not supported")
--- 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):
--- a/relnotes/next	Wed Jan 05 11:34:54 2022 -0800
+++ b/relnotes/next	Mon Jan 03 01:09:56 2022 +0100
@@ -15,6 +15,8 @@
 
 == Backwards Compatibility Changes ==
 
+The remotefilelog extension now requires an appropiate excludepattern
+for subrepositories.
 
 == Internal API Changes ==