upgrade: use rawsize() instead of revlog index
authorGregory Szorc <gregory.szorc@gmail.com>
Mon, 24 Sep 2018 09:38:27 -0700
changeset 39859 32d3ed3023bb
parent 39858 9534fe1e5d28
child 39860 d9b3cc3d5d07
upgrade: use rawsize() instead of revlog index The revlog index is a very low-level data structure and it shouldn't be exposed to the storage interface - at least not in its current form. upgrade.py is the only consumer of the index attribute on file storage in the repository. This commit rewrites that final consumer to use rawsize() instead of going through the index. This is actually the more proper API to use, as rawsize() will accurately report the size of revisions which have a negative size in the index. Differential Revision: https://phab.mercurial-scm.org/D4719
mercurial/filelog.py
mercurial/upgrade.py
--- a/mercurial/filelog.py	Thu Sep 20 19:20:01 2018 -0700
+++ b/mercurial/filelog.py	Mon Sep 24 09:38:27 2018 -0700
@@ -81,7 +81,7 @@
     def iscensored(self, rev):
         return self._revlog.iscensored(rev)
 
-    # Used by verify.
+    # Used by repo upgrade, verify.
     def rawsize(self, rev):
         return self._revlog.rawsize(rev)
 
--- a/mercurial/upgrade.py	Thu Sep 20 19:20:01 2018 -0700
+++ b/mercurial/upgrade.py	Mon Sep 24 09:38:27 2018 -0700
@@ -491,10 +491,7 @@
         for path in rl.files():
             datasize += rl.opener.stat(path).st_size
 
-        idx = rl.index
-        for rev in rl:
-            e = idx[rev]
-            rawsize += e[2]
+        rawsize += sum(map(rl.rawsize, iter(rl)))
 
         srcsize += datasize
         srcrawsize += rawsize