Mercurial > hg
comparison mercurial/streamclone.py @ 50521:f697af015683
stream-clone: bail-out earlier if pull is partial
The `canperformstreamclone` function is bit messy. However it seems clearer to
me to process the very generic condition about "can we consider a stream-clone
at all", before checking if a stream-clone is requested and if a compatible
protocol can be negotiated with the server.
So I am doing some gratuitous movement so reorder conditional.
author | Pierre-Yves David <pierre-yves.david@octobus.net> |
---|---|
date | Sat, 20 May 2023 01:19:26 +0200 |
parents | 0558866957fa |
children | 58e4842fbfc1 |
comparison
equal
deleted
inserted
replaced
50520:0558866957fa | 50521:f697af015683 |
---|---|
71 | 71 |
72 # Streaming clone only works on an empty destination repository | 72 # Streaming clone only works on an empty destination repository |
73 if len(repo): | 73 if len(repo): |
74 return False, None | 74 return False, None |
75 | 75 |
76 # Streaming clone only works if all data is being requested. | |
77 if pullop.heads: | |
78 return False, None | |
79 | |
76 bundle2supported = False | 80 bundle2supported = False |
77 if pullop.canusebundle2: | 81 if pullop.canusebundle2: |
78 if b'v2' in pullop.remotebundle2caps.get(b'stream', []): | 82 if b'v2' in pullop.remotebundle2caps.get(b'stream', []): |
79 bundle2supported = True | 83 bundle2supported = True |
80 # else | 84 # else |
84 # Ensures legacy code path uses available bundle2. | 88 # Ensures legacy code path uses available bundle2. |
85 if bundle2supported and not bundle2: | 89 if bundle2supported and not bundle2: |
86 return False, None | 90 return False, None |
87 # Ensures bundle2 doesn't try to do a stream clone if it isn't supported. | 91 # Ensures bundle2 doesn't try to do a stream clone if it isn't supported. |
88 elif bundle2 and not bundle2supported: | 92 elif bundle2 and not bundle2supported: |
89 return False, None | |
90 | |
91 # Streaming clone only works if all data is being requested. | |
92 if pullop.heads: | |
93 return False, None | 93 return False, None |
94 | 94 |
95 streamrequested = pullop.streamclonerequested | 95 streamrequested = pullop.streamclonerequested |
96 | 96 |
97 # If we don't have a preference, let the server decide for us. This | 97 # If we don't have a preference, let the server decide for us. This |