# HG changeset patch # User Pierre-Yves David # Date 2019-07-27 17:58:17 # Node ID 896fb9deeaf8c21a728dbe64e808c07b27e5b168 # Parent 716d575df275306e916a07a3382c4539af6be161 upgrade: walk the source store file only once I don't expect this to have a significant performance impact, but it seems simpler and saner to do the operation only once and to keep the result around. diff --git a/mercurial/upgrade.py b/mercurial/upgrade.py --- a/mercurial/upgrade.py +++ b/mercurial/upgrade.py @@ -554,9 +554,11 @@ def _copyrevlogs(ui, srcrepo, dstrepo, t crawsize = 0 cdstsize = 0 + alldatafiles = list(srcrepo.store.walk()) + # Perform a pass to collect metadata. This validates we can open all # source files and allows a unified progress bar to be displayed. - for unencoded, encoded, size in srcrepo.store.walk(): + for unencoded, encoded, size in alldatafiles: if unencoded.endswith('.d'): continue @@ -607,7 +609,7 @@ def _copyrevlogs(ui, srcrepo, dstrepo, t # Do the actual copying. # FUTURE this operation can be farmed off to worker processes. seen = set() - for unencoded, encoded, size in srcrepo.store.walk(): + for unencoded, encoded, size in alldatafiles: if unencoded.endswith('.d'): continue