@recaptime-dev's working patches + fork for Phorge, a community fork of Phabricator. (Upstream dev and stable branches are at upstream/main and upstream/stable respectively.) hq.recaptime.dev/wiki/Phorge
phorge phabricator
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Updates for Mercurial's HTTP protocol

Summary:
While testing https://secure.phabricator.com/D21864 I ran into some issues getting mercurial HTTP access working. Using wireshark I confirmed that my local mercurial 6.4 was not including command arguments as HTTP headers but in the querystring.

I didn't dig too deep into understanding when/why this started happening. The protocol documents this in [[ https://repo.mercurial-scm.org/hg/file/tip/mercurial/helptext/internals/wireprotocol.txt | wireprotocol.txt ]].

>Command arguments can be sent multiple ways. The simplest is part of the URL query string using ``x-www-form-urlencoded`` encoding (see Python's ``urllib.urlencode()``. However, many servers impose length limitations on the URL. So this mechanism is typically only used if the server doesn't support other mechanisms.

Based on that either the mercurial on the server is really old (it's 6.1.1 tho) or maybe some other parsing/info passing in Phab's handling of the wire protocol is causing the client to downgrade the wire protocol support.

Cherry-picked from:

https://secure.phabricator.com/D21867

https://secure.phabricator.com/rP0b6e758978a9691bd5ad25db4aa4c4301640a9a9

Test Plan: Host mercurial repo using HTTP, test push/pull.

Reviewers: O1 Blessed Committers, valerio.bozzolan

Reviewed By: O1 Blessed Committers, valerio.bozzolan

Subscribers: tobiaswiese, Matthew, Cigaryno

Differential Revision: https://we.phorge.it/D25471

+22 -3
+22 -3
src/applications/diffusion/controller/DiffusionServeController.php
··· 878 878 } 879 879 $args_raw[] = $_SERVER[$header]; 880 880 } 881 - $args_raw = implode('', $args_raw); 881 + 882 + if ($args_raw) { 883 + $args_raw = implode('', $args_raw); 884 + return id(new PhutilQueryStringParser()) 885 + ->parseQueryString($args_raw); 886 + } 887 + 888 + // Sometimes arguments come in via the query string. Note that this will 889 + // not handle multi-value entries e.g. "a[]=1,a[]=2" however it's unclear 890 + // whether or how the mercurial protocol should handle this. 891 + $query = idx($_SERVER, 'QUERY_STRING', ''); 892 + $query_pairs = id(new PhutilQueryStringParser()) 893 + ->parseQueryString($query); 894 + foreach ($query_pairs as $key => $value) { 895 + // Filter out private/internal keys as well as the command itself. 896 + if (strncmp($key, '__', 2) && $key != 'cmd') { 897 + $args_raw[$key] = $value; 898 + } 899 + } 882 900 883 - return id(new PhutilQueryStringParser()) 884 - ->parseQueryString($args_raw); 901 + // TODO: Arguments can also come in via request body for POST requests. The 902 + // body would be all arguments, url-encoded. 903 + return $args_raw; 885 904 } 886 905 887 906 private function formatMercurialArguments($command, array $arguments) {