Patchwork D10856: clone: also report the bookmark file as copied

login
register
mail settings
Submitter phabricator
Date June 9, 2021, 2:39 p.m.
Message ID <differential-rev-PHID-DREV-bemru5vqbijihevk3a4z-req@mercurial-scm.org>
Download mbox | patch
Permalink /patch/49174/
State Superseded
Headers show

Comments

phabricator - June 9, 2021, 2:39 p.m.
marmoute created this revision.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.

REVISION SUMMARY
  This is a small UI adjustement, but this is easy enough to do.

REPOSITORY
  rHG Mercurial

BRANCH
  default

REVISION DETAIL
  https://phab.mercurial-scm.org/D10856

AFFECTED FILES
  mercurial/streamclone.py

CHANGE DETAILS




To: marmoute, #hg-reviewers
Cc: mercurial-patches, mercurial-devel

Patch

diff --git a/mercurial/streamclone.py b/mercurial/streamclone.py
--- a/mercurial/streamclone.py
+++ b/mercurial/streamclone.py
@@ -824,6 +824,16 @@ 
 
     with dest_repo.lock():
         with src_repo.lock():
+
+            # bookmark is not integrated to the streaming as it might 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)