changeset 50633:f2ae815ae34c

local-clone: perform the hardlink/copy based from _entries_walk returns We previously used `_v2_walk`. However it is not bringing us much. So lets use the higher level function instead. This will offer us more flexibility with the `_v2_walk` function… like deleting it eventually.
author Pierre-Yves David <pierre-yves.david@octobus.net>
date Sun, 28 May 2023 04:12:10 +0200
parents 786443bd3bc1
children 1415e17ea20f
files mercurial/streamclone.py
diffstat 1 files changed, 11 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/streamclone.py	Mon May 29 04:24:29 2023 +0200
+++ b/mercurial/streamclone.py	Sun May 28 04:12:10 2023 +0200
@@ -900,7 +900,7 @@
         hardlink[0] = False
         progress.topic = _(b'copying')
 
-    for k, path, size in entries:
+    for k, path in entries:
         src_vfs = src_vfs_map[k]
         dst_vfs = dst_vfs_map[k]
         src_path = src_vfs.join(path)
@@ -951,17 +951,19 @@
             if os.path.exists(srcbookmarks):
                 bm_count = 1
 
-            entries, totalfilesize = _v2_walk(
+            entries = _entries_walk(
                 src_repo,
                 includes=None,
                 excludes=None,
                 includeobsmarkers=True,
             )
+            entries = list(entries)
             src_vfs_map = _makemap(src_repo)
             dest_vfs_map = _makemap(dest_repo)
+            total_files = sum(len(e[1].files()) for e in entries) + bm_count
             progress = src_repo.ui.makeprogress(
                 topic=_(b'linking'),
-                total=len(entries) + bm_count,
+                total=total_files,
                 unit=_(b'files'),
             )
             # copy  files
@@ -971,7 +973,11 @@
             # this would also requires checks that nobody is appending any data
             # to the files while we do the clone, so this is not done yet. We
             # could do this blindly when copying files.
-            files = ((k, path, size) for k, path, ftype, size in entries)
+            files = [
+                (vfs_key, f.unencoded_path)
+                for vfs_key, e in entries
+                for f in e.files()
+            ]
             hardlink = _copy_files(src_vfs_map, dest_vfs_map, files, progress)
 
             # copy bookmarks over
@@ -984,7 +990,7 @@
             msg = b'linked %d files\n'
         else:
             msg = b'copied %d files\n'
-        src_repo.ui.debug(msg % (len(entries) + bm_count))
+        src_repo.ui.debug(msg % total_files)
 
         with dest_repo.transaction(b"localclone") as tr:
             dest_repo.store.write(tr)