[Updated] D11236: streamclone: ensure the server sends the right amount of data
valentin.gatienbaron (Valentin Gatien-Baron)
phabricator at mercurial-scm.org
Mon Aug 2 10:44:29 UTC 2021
Closed by commit rHG48f07adbda98: streamclone: ensure the server sends the right amount of data (authored by valentin.gatienbaron).
This revision was automatically updated to reflect the committed changes.
REPOSITORY
rHG Mercurial
CHANGES SINCE LAST UPDATE
https://phab.mercurial-scm.org/D11236?vs=29766&id=29769
CHANGES SINCE LAST ACTION
https://phab.mercurial-scm.org/D11236/new/
REVISION DETAIL
https://phab.mercurial-scm.org/D11236
AFFECTED FILES
mercurial/streamclone.py
CHANGE DETAILS
diff --git a/mercurial/streamclone.py b/mercurial/streamclone.py
--- a/mercurial/streamclone.py
+++ b/mercurial/streamclone.py
@@ -583,7 +583,7 @@
# copy is delayed until we are in the try
entries = [_filterfull(e, copy, vfsmap) for e in entries]
yield None # this release the lock on the repository
- seen = 0
+ totalbytecount = 0
for src, name, ftype, data in entries:
vfs = vfsmap[src]
@@ -595,6 +595,7 @@
elif ftype == _filefull:
fp = open(data, b'rb')
size = util.fstat(fp).st_size
+ bytecount = 0
try:
yield util.uvarintencode(size)
yield name
@@ -603,9 +604,20 @@
else:
chunks = util.filechunkiter(fp, limit=size)
for chunk in chunks:
- seen += len(chunk)
- progress.update(seen)
+ bytecount += len(chunk)
+ totalbytecount += len(chunk)
+ progress.update(totalbytecount)
yield chunk
+ if bytecount != size:
+ # Would most likely be caused by a race due to `hg strip` or
+ # a revlog split
+ raise error.Abort(
+ _(
+ b'clone could only read %d bytes from %s, but '
+ b'expected %d bytes'
+ )
+ % (bytecount, name, size)
+ )
finally:
fp.close()
To: valentin.gatienbaron, #hg-reviewers, pulkit
Cc: Alphare, mercurial-patches
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mercurial-scm.org/pipermail/mercurial-patches/attachments/20210802/dd0ab497/attachment-0002.html>
More information about the Mercurial-patches
mailing list