changeset 42473:307f67d4aee3

export: don't prefetch *all* files in manifest `hg export` only shows changed files, not all files, but we still prefetched all files in cmdutil.export(). The same is true for the other commands calling cmdutil.exportfile(). That meant that `hg export` with remotefilelog (or lfs, I assume) could take much longer than expected because it would download all the files in the repo. Differential Revision: https://phab.mercurial-scm.org/D6532
author Martin von Zweigbergk <martinvonz@google.com>
date Fri, 14 Jun 2019 10:21:47 -0700
parents d768ca427249
children adb636392b3f
files mercurial/cmdutil.py
diffstat 1 files changed, 10 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/cmdutil.py	Fri Jun 14 13:50:06 2019 -0700
+++ b/mercurial/cmdutil.py	Fri Jun 14 10:21:47 2019 -0700
@@ -1668,6 +1668,14 @@
                 _exportsingle(repo, ctx, fm, match, switch_parent, seqno,
                               diffopts)
 
+def _prefetchchangedfiles(repo, revs, match):
+    allfiles = set()
+    for rev in revs:
+        for file in repo[rev].files():
+            if not match or match(file):
+                allfiles.add(file)
+    scmutil.prefetchfiles(repo, revs, scmutil.matchfiles(repo, allfiles))
+
 def export(repo, revs, basefm, fntemplate='hg-%h.patch', switch_parent=False,
            opts=None, match=None):
     '''export changesets as hg patches
@@ -1692,7 +1700,7 @@
                             the given template.
         Otherwise: All revs will be written to basefm.
     '''
-    scmutil.prefetchfiles(repo, revs, match)
+    _prefetchchangedfiles(repo, revs, match)
 
     if not fntemplate:
         _exportfile(repo, revs, basefm, '<unnamed>', switch_parent, opts, match)
@@ -1702,7 +1710,7 @@
 
 def exportfile(repo, revs, fp, switch_parent=False, opts=None, match=None):
     """Export changesets to the given file stream"""
-    scmutil.prefetchfiles(repo, revs, match)
+    _prefetchchangedfiles(repo, revs, match)
 
     dest = getattr(fp, 'name', '<unnamed>')
     with formatter.formatter(repo.ui, fp, 'export', {}) as fm: