Show More
@@ -64,7 +64,10 b' REQUIRESNI' | |||
|
64 | 64 | Value should be "true". |
|
65 | 65 | """ |
|
66 | 66 | |
|
67 | from mercurial.i18n import _ | |
|
68 | from mercurial.node import nullid | |
|
67 | 69 | from mercurial import ( |
|
70 | exchange, | |
|
68 | 71 | extensions, |
|
69 | 72 | wireproto, |
|
70 | 73 | ) |
@@ -94,5 +97,44 b' def bundles(repo, proto):' | |||
|
94 | 97 | """ |
|
95 | 98 | return repo.opener.tryread('clonebundles.manifest') |
|
96 | 99 | |
|
100 | @exchange.getbundle2partsgenerator('clonebundlesadvertise', 0) | |
|
101 | def advertiseclonebundlespart(bundler, repo, source, bundlecaps=None, | |
|
102 | b2caps=None, heads=None, common=None, | |
|
103 | cbattempted=None, **kwargs): | |
|
104 | """Inserts an output part to advertise clone bundles availability.""" | |
|
105 | # Allow server operators to disable this behavior. | |
|
106 | # # experimental config: ui.clonebundleadvertise | |
|
107 | if not repo.ui.configbool('ui', 'clonebundleadvertise', True): | |
|
108 | return | |
|
109 | ||
|
110 | # Only advertise if a manifest is present. | |
|
111 | if not repo.opener.exists('clonebundles.manifest'): | |
|
112 | return | |
|
113 | ||
|
114 | # And when changegroup data is requested. | |
|
115 | if not kwargs.get('cg', True): | |
|
116 | return | |
|
117 | ||
|
118 | # And when the client supports clone bundles. | |
|
119 | if cbattempted is None: | |
|
120 | return | |
|
121 | ||
|
122 | # And when the client didn't attempt a clone bundle as part of this pull. | |
|
123 | if cbattempted: | |
|
124 | return | |
|
125 | ||
|
126 | # And when a full clone is requested. | |
|
127 | # Note: client should not send "cbattempted" for regular pulls. This check | |
|
128 | # is defense in depth. | |
|
129 | if common and common != [nullid]: | |
|
130 | return | |
|
131 | ||
|
132 | msg = _('this server supports the experimental "clone bundles" feature ' | |
|
133 | 'that should enable faster and more reliable cloning\n' | |
|
134 | 'help test it by setting the "experimental.clonebundles" config ' | |
|
135 | 'flag to "true"') | |
|
136 | ||
|
137 | bundler.newpart('output', data=msg) | |
|
138 | ||
|
97 | 139 | def extsetup(ui): |
|
98 | 140 | extensions.wrapfunction(wireproto, '_capabilities', capabilities) |
@@ -64,6 +64,17 b' Empty manifest file results in retrieval' | |||
|
64 | 64 | adding file changes |
|
65 | 65 | added 2 changesets with 2 changes to 2 files |
|
66 | 66 | |
|
67 | Server advertises presence of feature to client requesting full clone | |
|
68 | ||
|
69 | $ hg --config experimental.clonebundles=false clone -U http://localhost:$HGPORT advertise-on-clone | |
|
70 | requesting all changes | |
|
71 | remote: this server supports the experimental "clone bundles" feature that should enable faster and more reliable cloning | |
|
72 | remote: help test it by setting the "experimental.clonebundles" config flag to "true" | |
|
73 | adding changesets | |
|
74 | adding manifests | |
|
75 | adding file changes | |
|
76 | added 2 changesets with 2 changes to 2 files | |
|
77 | ||
|
67 | 78 | Manifest file with invalid URL aborts |
|
68 | 79 | |
|
69 | 80 | $ echo 'http://does.not.exist/bundle.hg' > server/.hg/clonebundles.manifest |
General Comments 0
You need to be logged in to leave comments.
Login now