Differential D14241 Diff 34404 src/applications/diffusion/protocol/DiffusionMercurialWireProtocol.php
Changeset View
Changeset View
Standalone View
Standalone View
src/applications/diffusion/protocol/DiffusionMercurialWireProtocol.php
Show First 20 Lines • Show All 93 Lines • ▼ Show 20 Lines | foreach ($cmds as $sub_cmd) { | ||||
if (!self::isReadOnlyCommand($name)) { | if (!self::isReadOnlyCommand($name)) { | ||||
return false; | return false; | ||||
} | } | ||||
} | } | ||||
return true; | return true; | ||||
} | } | ||||
/** If the server version is running 3.4+ it will respond | |||||
* with 'bundle2' capability in the format of "bundle2=(url-encoding)". | |||||
* Until we maange to properly package up bundles to send back we | |||||
* disallow the client from knowing we speak bundle2 by removing it | |||||
* from the capabilities listing. | |||||
* | |||||
* The format of the capabilties string is: "a space separated list | |||||
* of strings representing what commands the server supports" | |||||
* @link https://www.mercurial-scm.org/wiki/CommandServer#Protocol | |||||
* | |||||
* @param string $capabilities - The string of capabilities to | |||||
* strip the bundle2 capability from. This is expected to be | |||||
* the space-separated list of strings resulting from the | |||||
* querying the 'capabilties' command. | |||||
* | |||||
* @return string The resulting space-separated list of capabilities | |||||
* which no longer contains the 'bundle2' capability. This is meant | |||||
* to replace the original $body to send back to client. | |||||
*/ | |||||
public static function filterBundle2Capability($capabilities) { | |||||
$bundle2_arg = 'bundle2='; | |||||
$bundle2_arg_len = strlen($bundle2_arg); | |||||
$capabilities_arr = explode(' ', $capabilities); | |||||
$arrindex = -1; | |||||
$found_bundle2 = false; | |||||
foreach ($capabilities_arr as $capability) { | |||||
$arrindex++; | |||||
if (substr($capability, 0, $bundle2_arg_len) == $bundle2_arg) { | |||||
$found_bundle2 = true; | |||||
break; | |||||
} | |||||
} | |||||
if ($found_bundle2 && $arrindex > -1) { | |||||
unset($capabilities_arr[$arrindex]); | |||||
} | |||||
$capabilities_without_bundle2 = implode(' ', $capabilities_arr); | |||||
return $capabilities_without_bundle2; | |||||
epriestley: I think you can do this a little more easily as:
```lang=php
$parts = explode(' '… | |||||
cspeckmimAuthorUnsubmitted Not Done Inline ActionsOk I'll fix that. I was initially afraid to try and modify the array while iterating over it, as that typically causes runtime errors in Java. Also I forgot about preg_match. cspeckmim: Ok I'll fix that. I was initially afraid to try and modify the array while iterating over it… | |||||
} | |||||
} | } |
I think you can do this a little more easily as: