Mercurial > hg
comparison mercurial/streamclone.py @ 47448:d370256636fe
clone: also report the bookmark file as copied
This is a small UI adjustement, but this is easy enough to do.
Differential Revision: https://phab.mercurial-scm.org/D10856
author | Pierre-Yves David <pierre-yves.david@octobus.net> |
---|---|
date | Tue, 08 Jun 2021 03:56:33 +0200 |
parents | 377d8fc20e34 |
children | d7515d29761d |
comparison
equal
deleted
inserted
replaced
47447:377d8fc20e34 | 47448:d370256636fe |
---|---|
822 } | 822 } |
823 assert src_store_requirements == dest_store_requirements | 823 assert src_store_requirements == dest_store_requirements |
824 | 824 |
825 with dest_repo.lock(): | 825 with dest_repo.lock(): |
826 with src_repo.lock(): | 826 with src_repo.lock(): |
827 | |
828 # bookmark is not integrated to the streaming as it might use the | |
829 # `repo.vfs` and they are too many sentitive data accessible | |
830 # through `repo.vfs` to expose it to streaming clone. | |
831 src_book_vfs = bookmarks.bookmarksvfs(src_repo) | |
832 srcbookmarks = src_book_vfs.join(b'bookmarks') | |
833 bm_count = 0 | |
834 if os.path.exists(srcbookmarks): | |
835 bm_count = 1 | |
836 | |
827 entries, totalfilesize = _v2_walk( | 837 entries, totalfilesize = _v2_walk( |
828 src_repo, | 838 src_repo, |
829 includes=None, | 839 includes=None, |
830 excludes=None, | 840 excludes=None, |
831 includeobsmarkers=True, | 841 includeobsmarkers=True, |
832 ) | 842 ) |
833 src_vfs_map = _makemap(src_repo) | 843 src_vfs_map = _makemap(src_repo) |
834 dest_vfs_map = _makemap(dest_repo) | 844 dest_vfs_map = _makemap(dest_repo) |
835 progress = src_repo.ui.makeprogress( | 845 progress = src_repo.ui.makeprogress( |
836 topic=_(b'linking'), | 846 topic=_(b'linking'), |
837 total=len(entries), | 847 total=len(entries) + bm_count, |
838 unit=_(b'files'), | 848 unit=_(b'files'), |
839 ) | 849 ) |
840 # copy files | 850 # copy files |
841 # | 851 # |
842 # We could copy the full file while the source repository is locked | 852 # We could copy the full file while the source repository is locked |
846 # could do this blindly when copying files. | 856 # could do this blindly when copying files. |
847 files = ((k, path, size) for k, path, ftype, size in entries) | 857 files = ((k, path, size) for k, path, ftype, size in entries) |
848 hardlink = _copy_files(src_vfs_map, dest_vfs_map, files, progress) | 858 hardlink = _copy_files(src_vfs_map, dest_vfs_map, files, progress) |
849 | 859 |
850 # copy bookmarks over | 860 # copy bookmarks over |
851 src_book_vfs = bookmarks.bookmarksvfs(src_repo) | 861 if bm_count: |
852 srcbookmarks = src_book_vfs.join(b'bookmarks') | 862 dst_book_vfs = bookmarks.bookmarksvfs(dest_repo) |
853 dst_book_vfs = bookmarks.bookmarksvfs(dest_repo) | 863 dstbookmarks = dst_book_vfs.join(b'bookmarks') |
854 dstbookmarks = dst_book_vfs.join(b'bookmarks') | |
855 if os.path.exists(srcbookmarks): | |
856 util.copyfile(srcbookmarks, dstbookmarks) | 864 util.copyfile(srcbookmarks, dstbookmarks) |
857 progress.complete() | 865 progress.complete() |
858 if hardlink: | 866 if hardlink: |
859 msg = b'linked %d files\n' | 867 msg = b'linked %d files\n' |
860 else: | 868 else: |
861 msg = b'copied %d files\n' | 869 msg = b'copied %d files\n' |
862 src_repo.ui.debug(msg % len(entries)) | 870 src_repo.ui.debug(msg % (len(entries) + bm_count)) |
863 | 871 |
864 with dest_repo.transaction(b"localclone") as tr: | 872 with dest_repo.transaction(b"localclone") as tr: |
865 dest_repo.store.write(tr) | 873 dest_repo.store.write(tr) |
866 | 874 |
867 # clean up transaction file as they do not make sense | 875 # clean up transaction file as they do not make sense |