diff mercurial/streamclone.py @ 50505:521fec115dad

store: use a StoreEntry object instead of tuple for store files We want to make the store return more semantic information instead of a stream of file path. To achieve this, we start with adding a simple object that hold the same information as the tuple it replace, and do a simple update to the user code to fetch and use the same information. From there, we will be able to iteratively upgrade the codebase toward better objects.
author Pierre-Yves David <pierre-yves.david@octobus.net>
date Mon, 15 May 2023 08:56:23 +0200
parents d89eecf9605e
children 9fdc28e21b68
line wrap: on
line diff
--- a/mercurial/streamclone.py	Mon May 15 08:56:08 2023 +0200
+++ b/mercurial/streamclone.py	Mon May 15 08:56:23 2023 +0200
@@ -269,10 +269,10 @@
     # Get consistent snapshot of repo, lock during scan.
     with repo.lock():
         repo.ui.debug(b'scanning\n')
-        for file_type, name, size in _walkstreamfiles(repo):
-            if size:
-                entries.append((name, size))
-                total_bytes += size
+        for entry in _walkstreamfiles(repo):
+            if entry.file_size:
+                entries.append((entry.unencoded_path, entry.file_size))
+                total_bytes += entry.file_size
         _test_sync_point_walk_1(repo)
     _test_sync_point_walk_2(repo)
 
@@ -677,13 +677,15 @@
     if includes or excludes:
         matcher = narrowspec.match(repo.root, includes, excludes)
 
-    for rl_type, name, size in _walkstreamfiles(repo, matcher):
-        if size:
+    for entry in _walkstreamfiles(repo, matcher):
+        if entry.file_size:
             ft = _fileappend
-            if rl_type & store.FILEFLAGS_VOLATILE:
+            if entry.is_volatile:
                 ft = _filefull
-            entries.append((_srcstore, name, ft, size))
-            totalfilesize += size
+            entries.append(
+                (_srcstore, entry.unencoded_path, ft, entry.file_size)
+            )
+            totalfilesize += entry.file_size
     for name in _walkstreamfullstorefiles(repo):
         if repo.svfs.exists(name):
             totalfilesize += repo.svfs.lstat(name).st_size