Patchwork [2,of,8] upgrade: walk the source store file only once

login
register
mail settings
Submitter Pierre-Yves David
Date Aug. 5, 2019, 4:36 p.m.
Message ID <085f8c53d0067f4cbb5e.1565022990@nodosa.octopoid.net>
Download mbox | patch
Permalink /patch/41154/
State Accepted
Headers show

Comments

Pierre-Yves David - Aug. 5, 2019, 4:36 p.m.
# HG changeset patch
# User Pierre-Yves David <pierre-yves.david@octobus.net>
# Date 1564250297 -7200
#      Sat Jul 27 19:58:17 2019 +0200
# Node ID 085f8c53d0067f4cbb5ed3b9738ef33dbafa0782
# Parent  8d019de36e616e8d71ba19c713a6f85cdc8beb60
# EXP-Topic upgrade-select
# Available At https://bitbucket.org/octobus/mercurial-devel/
#              hg pull https://bitbucket.org/octobus/mercurial-devel/ -r 085f8c53d006
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.

Patch

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