$original_argv = $argv;
$args = new PhutilArgumentParser($argv);
$args->parseStandardArguments();
+$args->parsePartial(
+ array(
+ array(
+ 'name' => 'load-phutil-library',
+ 'param' => 'path',
+ 'help' => 'Load a libphutil library.',
+ 'repeat' => true,
+ ),
+ array(
+ 'name' => 'conduit-uri',
+ 'param' => 'uri',
+ 'help' => 'Connect to Phabricator install specified by __uri__.',
+ ),
+ array(
+ 'name' => 'conduit-version',
+ 'param' => 'version',
+ 'help' => '(Developers) Mock client version in protocol handshake.',
+ ),
+ array(
+ 'name' => 'conduit-timeout',
+ 'param' => 'timeout',
+ 'help' => 'Set Conduit timeout (in seconds).',
+ ),
+ ));
-$argv = $args->getUnconsumedArgumentVector();
$config_trace_mode = $args->getArg('trace');
-$force_conduit = null;
-$force_conduit_version = null;
-$args = $argv;
-$load = array();
-$matches = null;
-foreach ($args as $key => $arg) {
- if ($arg == '--') {
- break;
- } else if (preg_match('/^--load-phutil-library=(.*)$/', $arg, $matches)) {
- unset($args[$key]);
- $load[] = $matches[1];
- } else if (preg_match('/^--conduit-uri=(.*)$/', $arg, $matches)) {
- unset($args[$key]);
- $force_conduit = $matches[1];
- } else if (preg_match('/^--conduit-version=(.*)$/', $arg, $matches)) {
- unset($args[$key]);
- $force_conduit_version = $matches[1];
- }
-}
+$force_conduit = $args->getArg('conduit-uri');
+$force_conduit_version = $args->getArg('conduit-version');
+$conduit_timeout = $args->getArg('conduit-timeout');
+$load = $args->getArg('load-phutil-library');
+
+$argv = $args->getUnconsumedArgumentVector();
+$args = array_values($argv);
-$args = array_values($args);
$working_directory = getcwd();
try {
if ($force_conduit_version) {
$workflow->forceConduitVersion($force_conduit_version);
}
+ if ($conduit_timeout) {
+ $workflow->setConduitTimeout($conduit_timeout);
+ }
$need_working_copy = $workflow->requiresWorkingCopy();
$need_conduit = $workflow->requiresConduit();
}
echo phutil_console_format(
- "\n**Exception:**\n%s\n%s\n",
+ "**Exception**\n%s\n%s\n",
$ex->getMessage(),
"(Run with --trace for a full exception trace.)");
private $conduitCredentials;
private $conduitAuthenticated;
private $forcedConduitVersion;
+ private $conduitTimeout;
private $userPHID;
private $userName;
$this->conduit = new ConduitClient($this->conduitURI);
+ if ($this->conduitTimeout) {
+ $this->conduit->setTimeout($this->conduitTimeout);
+ }
+
return $this;
}
return $this;
}
+
+ /**
+ * Force arc to identify with a specific Conduit version during the
+ * protocol handshake. This is primarily useful for development (especially
+ * for sending diffs which bump the client Conduit version), since the client
+ * still actually speaks the builtin version of the protocol.
+ *
+ * Controlled by the --conduit-version flag.
+ *
+ * @param int Version the client should pretend to be.
+ * @return this
+ * @task conduit
+ */
public function forceConduitVersion($version) {
$this->forcedConduitVersion = $version;
return $this;
}
+
+ /**
+ * Get the protocol version the client should identify with.
+ *
+ * @return int Version the client should claim to be.
+ * @task conduit
+ */
public function getConduitVersion() {
return nonempty($this->forcedConduitVersion, 5);
}
+
+ /**
+ * Override the default timeout for Conduit.
+ *
+ * Controlled by the --conduit-timeout flag.
+ *
+ * @param float Timeout, in seconds.
+ * @return this
+ * @task conduit
+ */
+ public function setConduitTimeout($timeout) {
+ $this->conduitTimeout = $timeout;
+ if ($this->conduit) {
+ $this->conduit->setConduitTimeout($timeout);
+ }
+ return $this;
+ }
+
+
/**
* Open and authenticate a conduit connection to a Phabricator server using
* provided credentials. Normally, Arcanist does this for you automatically
* @task conduit
*/
final protected function isConduitAuthenticated() {
- return (bool) $this->conduitAuthenticated;
+ return (bool)$this->conduitAuthenticated;
}
Ignore libraries listed in .arcconfig and explicitly load specified
libraries instead. Mostly useful for Arcanist development.
- __--conduit-uri=...__
+ __--conduit-uri__ __uri__
Ignore configured Conduit URI and use an explicit one instead. Mostly
useful for Arcanist development.
- __--conduit-version=...__
+ __--conduit-version__ __version__
Ignore software version and claim to be running some other version
instead. Mostly useful for Arcanist development. May cause bad things
to happen.
+ __--conduit-timeout__ __timeout__
+ Override the default Conduit timeout. Specified in seconds.
EOTEXT
);