changeset 47454: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 da3fb8c10caa
files mercurial/streamclone.py
diffstat 1 files changed, 15 insertions(+), 7 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/streamclone.py	Tue Jun 08 02:06:45 2021 +0200
+++ b/mercurial/streamclone.py	Tue Jun 08 03:56:33 2021 +0200
@@ -824,6 +824,16 @@
 
     with dest_repo.lock():
         with src_repo.lock():
+
+            # bookmark is not integrated to the streaming as it might use the
+            # `repo.vfs` and they are too many sentitive data accessible
+            # through `repo.vfs` to expose it to streaming clone.
+            src_book_vfs = bookmarks.bookmarksvfs(src_repo)
+            srcbookmarks = src_book_vfs.join(b'bookmarks')
+            bm_count = 0
+            if os.path.exists(srcbookmarks):
+                bm_count = 1
+
             entries, totalfilesize = _v2_walk(
                 src_repo,
                 includes=None,
@@ -834,7 +844,7 @@
             dest_vfs_map = _makemap(dest_repo)
             progress = src_repo.ui.makeprogress(
                 topic=_(b'linking'),
-                total=len(entries),
+                total=len(entries) + bm_count,
                 unit=_(b'files'),
             )
             # copy  files
@@ -848,18 +858,16 @@
             hardlink = _copy_files(src_vfs_map, dest_vfs_map, files, progress)
 
             # copy bookmarks over
-            src_book_vfs = bookmarks.bookmarksvfs(src_repo)
-            srcbookmarks = src_book_vfs.join(b'bookmarks')
-            dst_book_vfs = bookmarks.bookmarksvfs(dest_repo)
-            dstbookmarks = dst_book_vfs.join(b'bookmarks')
-            if os.path.exists(srcbookmarks):
+            if bm_count:
+                dst_book_vfs = bookmarks.bookmarksvfs(dest_repo)
+                dstbookmarks = dst_book_vfs.join(b'bookmarks')
                 util.copyfile(srcbookmarks, dstbookmarks)
         progress.complete()
         if hardlink:
             msg = b'linked %d files\n'
         else:
             msg = b'copied %d files\n'
-        src_repo.ui.debug(msg % len(entries))
+        src_repo.ui.debug(msg % (len(entries) + bm_count))
 
         with dest_repo.transaction(b"localclone") as tr:
             dest_repo.store.write(tr)