Show More
@@ -17,31 +17,58 b' from . import (' | |||
|
17 | 17 | util, |
|
18 | 18 | ) |
|
19 | 19 | |
|
20 |
def |
|
|
21 | # now, all clients that can request uncompressed clones can | |
|
22 | # read repo formats supported by all servers that can serve | |
|
23 | # them. | |
|
20 | def canperformstreamclone(repo, remote, heads, streamrequested=None): | |
|
21 | """Whether it is possible to perform a streaming clone as part of pull. | |
|
24 | 22 |
|
|
25 | # if revlog format changes, client will have to check version | |
|
26 | # and format flags on "stream" capability, and use | |
|
27 | # uncompressed only if compatible. | |
|
23 | Returns a tuple of (supported, requirements). ``supported`` is True if | |
|
24 | streaming clone is supported and False otherwise. ``requirements`` is | |
|
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: | |
|
30 | # if the server explicitly prefers to stream (for fast LANs) | |
|
31 | stream = remote.capable('stream-preferred') | |
|
32 | # If we don't have a preference, let the server decide for us. This | |
|
33 | # likely only comes into play in LANs. | |
|
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: | |
|
34 | # 'stream' means remote revlog format is revlogv1 only | |
|
35 | if remote.capable('stream'): | |
|
36 | streamin(repo, remote, set(('revlogv1',))) | |
|
37 | else: | |
|
38 | # otherwise, 'streamreqs' contains the remote revlog format | |
|
39 | streamreqs = remote.capable('streamreqs') | |
|
40 | if streamreqs: | |
|
41 | streamreqs = set(streamreqs.split(',')) | |
|
42 | # if we support it, stream in and adjust our requirements | |
|
43 | if not streamreqs - repo.supportedformats: | |
|
44 |
|
|
|
41 | # In order for stream clone to work, the client has to support all the | |
|
42 | # requirements advertised by the server. | |
|
43 | # | |
|
44 | # The server advertises its requirements via the "stream" and "streamreqs" | |
|
45 | # capability. "stream" (a value-less capability) is advertised if and only | |
|
46 | # if the only requirement is "revlogv1." Else, the "streamreqs" capability | |
|
47 | # is advertised and contains a comma-delimited list of requirements. | |
|
48 | requirements = set() | |
|
49 | if remote.capable('stream'): | |
|
50 | requirements.add('revlogv1') | |
|
51 | else: | |
|
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 | 73 | def allowservergeneration(ui): |
|
47 | 74 | """Whether streaming clones are allowed from the server.""" |
General Comments 0
You need to be logged in to leave comments.
Login now