diff mercurial/upgrade.py @ 39857:8dab7c8a93eb

upgrade: report size of backing files, not internal storage size upgrade.py is the only consumer of filelog.index, which I'd like to eliminate from the file storage interface. This commit changes the upgrade code to report the storage size of files by looking at the size of the files backing its storage instead of looking at the index. I'm not convinced the approach in this patch will live very long because it is relying on low-level attributes like "opener" and "files," which may behave very differently on non-revlog storage. But the data is only used for reporting purposes and it does get us one step closer to eliminating "index." A side-effect of this change is we now report the size of the revlog index data - not just the revision data. I think this is more accurate. Differential Revision: https://phab.mercurial-scm.org/D4717
author Gregory Szorc <gregory.szorc@gmail.com>
date Mon, 24 Sep 2018 09:37:19 -0700
parents 41aa5dced975
children 32d3ed3023bb
line wrap: on
line diff
--- a/mercurial/upgrade.py	Thu Sep 20 18:07:42 2018 -0700
+++ b/mercurial/upgrade.py	Mon Sep 24 09:37:19 2018 -0700
@@ -487,10 +487,13 @@
 
         datasize = 0
         rawsize = 0
+
+        for path in rl.files():
+            datasize += rl.opener.stat(path).st_size
+
         idx = rl.index
         for rev in rl:
             e = idx[rev]
-            datasize += e[1]
             rawsize += e[2]
 
         srcsize += datasize
@@ -582,9 +585,8 @@
                     deltabothparents=deltabothparents)
 
         datasize = 0
-        idx = newrl.index
-        for rev in newrl:
-            datasize += idx[rev][1]
+        for path in newrl.files():
+            datasize += newrl.opener.stat(path).st_size
 
         dstsize += datasize