diff mercurial/streamclone.py @ 52719:6feb3b3029b5

stream: consistently close progress before reporting time Seems more logical. We also take this as an opportunity to explicitly track bytes count in "v2" as relying on progress internal start is error prone.
author Pierre-Yves David <pierre-yves.david@octobus.net>
date Thu, 28 Nov 2024 11:05:07 +0100
parents 061bfd699a56
children ca17d31624ac
line wrap: on
line diff
--- a/mercurial/streamclone.py	Thu Nov 28 11:05:02 2024 +0100
+++ b/mercurial/streamclone.py	Thu Nov 28 11:05:07 2024 +0100
@@ -1069,6 +1069,7 @@
             _(b'clone'), total=filesize, unit=_(b'bytes')
         )
         progress.update(0)
+        byte_count = 0
 
         vfsmap = _makemap(repo)
         # we keep repo.vfs out of the on purpose, ther are too many danger
@@ -1100,6 +1101,7 @@
 
                     with vfs(name, b'w') as ofp:
                         for chunk in util.filechunkiter(fp, limit=datalen):
+                            byte_count += len(chunk)
                             progress.increment(step=len(chunk))
                             ofp.write(chunk)
 
@@ -1107,8 +1109,8 @@
             # streamclone-ed file at next access
             repo.invalidate(clearfilecache=True)
 
-        _report_transferred(repo, start, progress.pos)
         progress.complete()
+        _report_transferred(repo, start, byte_count)
 
 
 def consumev3(repo, fp) -> None:
@@ -1173,8 +1175,8 @@
             # streamclone-ed file at next access
             repo.invalidate(clearfilecache=True)
 
+        progress.complete()
         _report_transferred(repo, start, bytes_transferred)
-        progress.complete()
 
 
 def applybundlev2(