Show More
@@ -17,31 +17,58 b' from . import (' | |||||
17 | util, |
|
17 | util, | |
18 | ) |
|
18 | ) | |
19 |
|
19 | |||
20 |
def |
|
20 | def canperformstreamclone(repo, remote, heads, streamrequested=None): | |
21 | # now, all clients that can request uncompressed clones can |
|
21 | """Whether it is possible to perform a streaming clone as part of pull. | |
22 | # read repo formats supported by all servers that can serve |
|
|||
23 | # them. |
|
|||
24 |
|
|
22 | ||
25 | # if revlog format changes, client will have to check version |
|
23 | Returns a tuple of (supported, requirements). ``supported`` is True if | |
26 | # and format flags on "stream" capability, and use |
|
24 | streaming clone is supported and False otherwise. ``requirements`` is | |
27 | # uncompressed only if compatible. |
|
25 | a set of repo requirements from the remote, or ``None`` if stream clone | |
|
26 | isn't supported. | |||
|
27 | """ | |||
|
28 | # Streaming clone only works if all data is being requested. | |||
|
29 | if heads: | |||
|
30 | return False, None | |||
28 |
|
31 | |||
29 | if stream is None: |
|
32 | # If we don't have a preference, let the server decide for us. This | |
30 | # if the server explicitly prefers to stream (for fast LANs) |
|
33 | # likely only comes into play in LANs. | |
31 | stream = remote.capable('stream-preferred') |
|
34 | if streamrequested is None: | |
|
35 | # The server can advertise whether to prefer streaming clone. | |||
|
36 | streamrequested = remote.capable('stream-preferred') | |||
|
37 | ||||
|
38 | if not streamrequested: | |||
|
39 | return False, None | |||
32 |
|
40 | |||
33 | if stream and not heads: |
|
41 | # In order for stream clone to work, the client has to support all the | |
34 | # 'stream' means remote revlog format is revlogv1 only |
|
42 | # requirements advertised by the server. | |
35 | if remote.capable('stream'): |
|
43 | # | |
36 | streamin(repo, remote, set(('revlogv1',))) |
|
44 | # The server advertises its requirements via the "stream" and "streamreqs" | |
37 | else: |
|
45 | # capability. "stream" (a value-less capability) is advertised if and only | |
38 | # otherwise, 'streamreqs' contains the remote revlog format |
|
46 | # if the only requirement is "revlogv1." Else, the "streamreqs" capability | |
39 | streamreqs = remote.capable('streamreqs') |
|
47 | # is advertised and contains a comma-delimited list of requirements. | |
40 | if streamreqs: |
|
48 | requirements = set() | |
41 | streamreqs = set(streamreqs.split(',')) |
|
49 | if remote.capable('stream'): | |
42 | # if we support it, stream in and adjust our requirements |
|
50 | requirements.add('revlogv1') | |
43 | if not streamreqs - repo.supportedformats: |
|
51 | else: | |
44 |
|
|
52 | streamreqs = remote.capable('streamreqs') | |
|
53 | # This is weird and shouldn't happen with modern servers. | |||
|
54 | if not streamreqs: | |||
|
55 | return False, None | |||
|
56 | ||||
|
57 | streamreqs = set(streamreqs.split(',')) | |||
|
58 | # Server requires something we don't support. Bail. | |||
|
59 | if streamreqs - repo.supportedformats: | |||
|
60 | return False, None | |||
|
61 | requirements = streamreqs | |||
|
62 | ||||
|
63 | return True, requirements | |||
|
64 | ||||
|
65 | def maybeperformstreamclone(repo, remote, heads, stream): | |||
|
66 | supported, requirements = canperformstreamclone(repo, remote, heads, | |||
|
67 | streamrequested=stream) | |||
|
68 | if not supported: | |||
|
69 | return | |||
|
70 | ||||
|
71 | streamin(repo, remote, requirements) | |||
45 |
|
72 | |||
46 | def allowservergeneration(ui): |
|
73 | def allowservergeneration(ui): | |
47 | """Whether streaming clones are allowed from the server.""" |
|
74 | """Whether streaming clones are allowed from the server.""" |
General Comments 0
You need to be logged in to leave comments.
Login now