comparison mercurial/hgweb/hgweb_mod.py @ 35982:5a56bf4180ad

wireproto: function for testing if wire protocol command is available Currently, we perform simple membership testing for whether a wire command is available. In the future, not all wire protocol commands will be available on all transports. For example, a legacy transport may not support newer commands. In preparation of this, teach the protocol handlers to call into a function to determine if a wire protocol command is available. That function currently does membership testing like before, so behavior should be identical. In the case of the HTTP server, behavior is a bit wonkier. "cmd" is used by both the wire protocol and hgweb. We do want the protocol handler to handle requests for all commands that look like wire protocol commands, even if they aren't available. Otherwise, the fallback to hgweb would only confuse automated clients and make it easier for hgweb to accidentally implement a "cmd" that is identical to wire protocol commands (since they aren't centrally registered). Differential Revision: https://phab.mercurial-scm.org/D1999
author Gregory Szorc <gregory.szorc@gmail.com>
date Tue, 30 Jan 2018 18:41:44 -0800
parents a42455b3dbf8
children cdc93fe1da77
comparison
equal deleted inserted replaced
35981:ef683a0fd21f 35982:5a56bf4180ad
354 parts = parts[len(repo_parts):] 354 parts = parts[len(repo_parts):]
355 query = '/'.join(parts) 355 query = '/'.join(parts)
356 else: 356 else:
357 query = req.env[r'QUERY_STRING'].partition(r'&')[0] 357 query = req.env[r'QUERY_STRING'].partition(r'&')[0]
358 query = query.partition(r';')[0] 358 query = query.partition(r';')[0]
359
360 # The ``cmd`` request parameter is used by both the wire protocol
361 # and hgweb. We route all known wire protocol commands to the
362 # wire protocol handler, even if the command isn't available for
363 # this transport. That's better for machine clients in the case
364 # of an errant request to an unavailable protocol command. And it
365 # prevents hgweb from accidentally using ``cmd`` values used by
366 # the wire protocol.
359 367
360 # process this if it's a protocol request 368 # process this if it's a protocol request
361 # protocol bits don't need to create any URLs 369 # protocol bits don't need to create any URLs
362 # and the clients always use the old URL structure 370 # and the clients always use the old URL structure
363 371