comparison hgext/clonebundles.py @ 27736:7644d3aeedec

clonebundles: remove advertisement of feature I screwed up. When clone bundles is enabled on the server and a compatible client without the feature enabled clones, the server sends down an advertisement saying to enable the feature. The server creates the message which is printed verbatim on the client as an "output" part. There are 2 problems: 1) The message doesn't respect the client's localization 2) The message contains a reference to the "experimental.clonebundles" option. Since clone bundles is about to be marked as non-experimental and the goal of the advertisement was to encourage clients to test the experimental feature, let's just remove the broken advertisement since it no longer serves a purpose.
author Gregory Szorc <gregory.szorc@gmail.com>
date Fri, 08 Jan 2016 10:53:07 -0800
parents f675ab4d0781
children 482eb357fe98
comparison
equal deleted inserted replaced
27735:bd37212c20ed 27736:7644d3aeedec
162 Mercurial server when the bundle hosting service fails. 162 Mercurial server when the bundle hosting service fails.
163 163
164 The following config options influence the behavior of the clone bundles 164 The following config options influence the behavior of the clone bundles
165 feature: 165 feature:
166 166
167 ui.clonebundleadvertise
168 Whether the server advertises the existence of the clone bundles feature
169 to compatible clients that aren't using it.
170
171 When this is enabled (the default), a server will send a message to
172 compatible clients performing a traditional clone informing them of the
173 available clone bundles feature. Compatible clients are those that support
174 bundle2 and are advertising support for the clone bundles feature.
175
176 ui.clonebundlefallback 167 ui.clonebundlefallback
177 Whether to automatically fall back to a traditional clone in case of 168 Whether to automatically fall back to a traditional clone in case of
178 clone bundles failure. Defaults to false for reasons described above. 169 clone bundles failure. Defaults to false for reasons described above.
179 170
180 experimental.clonebundles 171 experimental.clonebundles
188 179
189 If not defined, the order in the manifest will be used and the first 180 If not defined, the order in the manifest will be used and the first
190 available bundle will be downloaded. 181 available bundle will be downloaded.
191 """ 182 """
192 183
193 from mercurial.i18n import _
194 from mercurial.node import nullid
195 from mercurial import ( 184 from mercurial import (
196 exchange,
197 extensions, 185 extensions,
198 wireproto, 186 wireproto,
199 ) 187 )
200 188
201 testedwith = 'internal' 189 testedwith = 'internal'
209 if repo.opener.exists('clonebundles.manifest'): 197 if repo.opener.exists('clonebundles.manifest'):
210 caps.append('clonebundles') 198 caps.append('clonebundles')
211 199
212 return caps 200 return caps
213 201
214 @exchange.getbundle2partsgenerator('clonebundlesadvertise', 0)
215 def advertiseclonebundlespart(bundler, repo, source, bundlecaps=None,
216 b2caps=None, heads=None, common=None,
217 cbattempted=None, **kwargs):
218 """Inserts an output part to advertise clone bundles availability."""
219 # Allow server operators to disable this behavior.
220 # # experimental config: ui.clonebundleadvertise
221 if not repo.ui.configbool('ui', 'clonebundleadvertise', True):
222 return
223
224 # Only advertise if a manifest is present.
225 if not repo.opener.exists('clonebundles.manifest'):
226 return
227
228 # And when changegroup data is requested.
229 if not kwargs.get('cg', True):
230 return
231
232 # And when the client supports clone bundles.
233 if cbattempted is None:
234 return
235
236 # And when the client didn't attempt a clone bundle as part of this pull.
237 if cbattempted:
238 return
239
240 # And when a full clone is requested.
241 # Note: client should not send "cbattempted" for regular pulls. This check
242 # is defense in depth.
243 if common and common != [nullid]:
244 return
245
246 msg = _('this server supports the experimental "clone bundles" feature '
247 'that should enable faster and more reliable cloning\n'
248 'help test it by setting the "experimental.clonebundles" config '
249 'flag to "true"')
250
251 bundler.newpart('output', data=msg)
252
253 def extsetup(ui): 202 def extsetup(ui):
254 extensions.wrapfunction(wireproto, '_capabilities', capabilities) 203 extensions.wrapfunction(wireproto, '_capabilities', capabilities)