stream-clone: bail-out earlier if stream clone is not requested
authorPierre-Yves David <pierre-yves.david@octobus.net>
Sat, 20 May 2023 01:22:49 +0200
changeset 50522 58e4842fbfc1
parent 50521 f697af015683
child 50523 a6543983b8f4
stream-clone: bail-out earlier if stream clone is not requested The `canperformstreamclone` function is bit messy. However it seems clearer to me to check if a stream-clone have been requested by the client or the server at all, before checking if a compatible protocol can be negotiated with the server. So I am doing some gratuitous movement so reorder conditional.
mercurial/streamclone.py
--- a/mercurial/streamclone.py	Sat May 20 01:19:26 2023 +0200
+++ b/mercurial/streamclone.py	Sat May 20 01:22:49 2023 +0200
@@ -69,6 +69,16 @@
     repo = pullop.repo
     remote = pullop.remote
 
+    # should we consider streaming clone at all ?
+    streamrequested = pullop.streamclonerequested
+    # If we don't have a preference, let the server decide for us. This
+    # likely only comes into play in LANs.
+    if streamrequested is None:
+        # The server can advertise whether to prefer streaming clone.
+        streamrequested = remote.capable(b'stream-preferred')
+    if not streamrequested:
+        return False, None
+
     # Streaming clone only works on an empty destination repository
     if len(repo):
         return False, None
@@ -92,17 +102,6 @@
     elif bundle2 and not bundle2supported:
         return False, None
 
-    streamrequested = pullop.streamclonerequested
-
-    # If we don't have a preference, let the server decide for us. This
-    # likely only comes into play in LANs.
-    if streamrequested is None:
-        # The server can advertise whether to prefer streaming clone.
-        streamrequested = remote.capable(b'stream-preferred')
-
-    if not streamrequested:
-        return False, None
-
     # In order for stream clone to work, the client has to support all the
     # requirements advertised by the server.
     #