Mercurial > public > mercurial-scm > hg
comparison mercurial/streamclone.py @ 50631:1415e17ea20f
stream-clone: pre-indent some code
This make the next changeset clearer.
author | Pierre-Yves David <pierre-yves.david@octobus.net> |
---|---|
date | Mon, 29 May 2023 04:12:30 +0200 |
parents | f2ae815ae34c |
children | 3416b46320dc |
comparison
equal
deleted
inserted
replaced
50630:f2ae815ae34c | 50631:1415e17ea20f |
---|---|
642 entries = [_filterfull(e, copy, vfsmap) for e in entries] | 642 entries = [_filterfull(e, copy, vfsmap) for e in entries] |
643 yield None # this release the lock on the repository | 643 yield None # this release the lock on the repository |
644 totalbytecount = 0 | 644 totalbytecount = 0 |
645 | 645 |
646 for src, name, ftype, data in entries: | 646 for src, name, ftype, data in entries: |
647 vfs = vfsmap[src] | 647 if True: |
648 yield src | 648 vfs = vfsmap[src] |
649 yield util.uvarintencode(len(name)) | 649 yield src |
650 if ftype == _fileappend: | 650 yield util.uvarintencode(len(name)) |
651 fp = vfs(name) | 651 if ftype == _fileappend: |
652 size = data | 652 fp = vfs(name) |
653 elif ftype == _filefull: | 653 size = data |
654 fp = open(data, b'rb') | 654 elif ftype == _filefull: |
655 size = util.fstat(fp).st_size | 655 fp = open(data, b'rb') |
656 bytecount = 0 | 656 size = util.fstat(fp).st_size |
657 try: | 657 bytecount = 0 |
658 yield util.uvarintencode(size) | 658 try: |
659 yield name | 659 yield util.uvarintencode(size) |
660 if size <= 65536: | 660 yield name |
661 chunks = (fp.read(size),) | 661 if size <= 65536: |
662 else: | 662 chunks = (fp.read(size),) |
663 chunks = util.filechunkiter(fp, limit=size) | 663 else: |
664 for chunk in chunks: | 664 chunks = util.filechunkiter(fp, limit=size) |
665 bytecount += len(chunk) | 665 for chunk in chunks: |
666 totalbytecount += len(chunk) | 666 bytecount += len(chunk) |
667 progress.update(totalbytecount) | 667 totalbytecount += len(chunk) |
668 yield chunk | 668 progress.update(totalbytecount) |
669 if bytecount != size: | 669 yield chunk |
670 # Would most likely be caused by a race due to `hg strip` or | 670 if bytecount != size: |
671 # a revlog split | 671 # Would most likely be caused by a race due to `hg |
672 raise error.Abort( | 672 # strip` or a revlog split |
673 _( | 673 msg = _( |
674 b'clone could only read %d bytes from %s, but ' | 674 b'clone could only read %d bytes from %s, but ' |
675 b'expected %d bytes' | 675 b'expected %d bytes' |
676 ) | 676 ) |
677 % (bytecount, name, size) | 677 raise error.Abort(msg % (bytecount, name, size)) |
678 ) | 678 finally: |
679 finally: | 679 fp.close() |
680 fp.close() | |
681 | 680 |
682 | 681 |
683 def _test_sync_point_walk_1(repo): | 682 def _test_sync_point_walk_1(repo): |
684 """a function for synchronisation during tests""" | 683 """a function for synchronisation during tests""" |
685 | 684 |