Diviner

Class ArcanistBaseWorkflow

Definedsrc/workflow/ArcanistBaseWorkflow.php:37
GroupWorkflows
ExtendsPhobject
This class is stable: you may safely extend it.

Implements a runnable command, like "arc diff" or "arc help".

Managing Conduit

Workflows have the builtin ability to open a Conduit connection to a Phabricator installation, so methods can be invoked over the API. Workflows may either not need this (e.g., "help"), or may need a Conduit but not authentication (e.g., calling only public APIs), or may need a Conduit and authentication (e.g., "arc diff").

To specify that you need an unauthenticated conduit, override requiresConduit() to return true. To specify that you need an authenticated conduit, override requiresAuthentication() to return true. You can also manually invoke establishConduit() and/or authenticateConduit() later in a workflow to upgrade it. Once a conduit is open, you can access the client by calling getConduit(), which allows you to invoke methods. You can get verified information about the user identity by calling getUserPHID() or getUserName() after authentication occurs.

Scratch Files

Arcanist workflows can read and write 'scratch files', which are temporary files stored in the project that persist across commands. They can be useful if you want to save some state, or keep a copy of a long message the user entered if something goes wrong.

Tasks

Conduit

Scratch Files

Unspecified

Methods

public this __construct()

returnthis
This method is not documented.

private askForAdd()

returnwild
This method is not documented.

final public this authenticateConduit()

returnthis

Open and authenticate a conduit connection to a Phabricator server using provided credentials. Normally, Arcanist does this for you automatically when you return true from requiresAuthentication(), but you can also upgrade an existing workflow to one with an authenticated conduit by invoking this method manually.

You must authenticate the conduit before you can make authenticated conduit calls (almost all calls require authentication).

This method uses credentials provided via setConduitCredentials() to authenticate to the server:

  • user (required) The username to authenticate with.
  • certificate (required) The Conduit certificate to use.
  • description (optional) Description of the invoking command.

Successful authentication allows you to call getUserPHID() and getUserName(), as well as use the client you access with getConduit() to make authenticated calls.

NOTE: You must call setConduitURI() and setConduitCredentials() before you invoke this method.

public buildChildWorkflow($command, array $argv)

parameterswild$command
array$argv
returnwild
This method is not documented.

public desiresRepositoryAPI()

returnwild
This method is not documented.

public desiresWorkingCopy()

returnwild
This method is not documented.

protected didParseArguments()

returnwild
This method is not documented.

protected dispatchEvent($type, array $data)

parameterswild$type
array$data
returnwild
This method is not documented.

final public this establishConduit()

returnthis

Open a conduit channel to the server which was previously configured by calling setConduitURI(). Arcanist will do this automatically if the workflow returns true from requiresConduit(), or you can later upgrade a workflow and build a conduit by invoking it manually.

You must establish a conduit before you can make conduit calls.

NOTE: You must call setConduitURI() before you can call this method.

public finalize()

returnwild

Finalizes any cleanup operations that need to occur regardless of whether the command succeeded or failed.

public finalizeWorkingCopy()

returnwild
This method is not documented.

public this forceConduitVersion($version)

parametersint$versionVersion the client should pretend to be.
returnthis

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.

public getArcanistConfiguration()

returnwild
This method is not documented.

public getArgument($key, $default = null)

parameterswild$key
wild$default
returnwild
This method is not documented.

public getArguments()

returnwild
This method is not documented.

protected getChange($path)

parameterswild$path
returnwild
This method is not documented.

protected list|null getChangedLines($path, $mode)

parametersstring$pathPath within the repository.
string$modeChange selection mode (see ArcanistDiffHunk).
returnlist|nullList of changed line numbers, or null to indicate that the path is not a line-oriented text file.

Return a list of lines changed by the current diff, or null if the change list is meaningless (for example, because the path is a directory or binary file).

public getCommand()

returnwild
This method is not documented.

public abstract string getCommandHelp()

returnstring10-space indented help to use the command.

Return console formatted string with command help printed in arc help.

public abstract string getCommandSynopses()

returnstring6-space indented list of available command synopses.

Return console formatted string with all command synopses.

final public getCompleteArgumentSpecification()

returnwild
This method is not documented.

final public ConduitClient getConduit()

returnConduitClientLive conduit client.

Get the established ConduitClient in order to make Conduit method calls. Before the client is available it must be connected, either implicitly by making requireConduit() or requireAuthentication() return true, or explicitly by calling establishConduit() or authenticateConduit().

final public string getConduitURI()

returnstring

Returns the URI the conduit connection within the workflow uses.

public int getConduitVersion()

returnintVersion the client should claim to be.

Get the protocol version the client should identify with.

final public getConfigFromWhateverSourceAvailiable($key)

parameterswild$key
returnwild
This method is not documented.

protected getParentWorkflow()

returnwild
This method is not documented.

public getPassedArguments()

returnwild
This method is not documented.

protected getPassthruArgumentsAsArgv($command)

parameterswild$command
returnwild
This method is not documented.

protected getPassthruArgumentsAsMap($command)

parameterswild$command
returnwild
This method is not documented.

protected getProjectInfo()

returnwild
This method is not documented.

protected mixed getReadableScratchFilePath($path)

parametersstring$pathScratch file name.
returnmixedString, or false on failure.

Get a human-readable description of the scratch file location.

public getRepositoryAPI()

returnwild
This method is not documented.

protected getRepositoryEncoding()

returnwild
This method is not documented.

protected getRepositoryVersion()

returnwild
This method is not documented.

protected mixed getScratchFilePath($path)

parametersstring$pathScratch file name.
returnmixedFile path, or false on failure.

Get the path to a scratch file, if possible.

protected getShellCompletions(array $argv)

parametersarray$argv
returnwild
This method is not documented.

protected getSupportedRevisionControlSystems()

returnwild
This method is not documented.

public static getSystemArcConfigLocation()

returnwild
This method is not documented.

public static getUserConfigurationFileLocation()

returnwild
This method is not documented.

final public getUserGUID()

returnwild

Deprecated. See getUserPHID().

final public string getUserName()

returnstringAuthenticated username.

Return the username for the user once they've authenticated via Conduit.

final public phid getUserPHID()

returnphidAuthenticated user PHID.

Returns the PHID for the user once they've authenticated via Conduit.

public abstract string getWorkflowName()

returnstringThe command a user types to invoke this workflow.

Return the command used to invoke this workflow from the command like, e.g. "help" for ArcanistHelpWorkflow.

public getWorkingCopy()

returnwild
This method is not documented.

public getWorkingDirectory()

returnwild
This method is not documented.

final protected bool isConduitAuthenticated()

returnboolTrue if conduit is authenticated, false otherwise.
This method is not documented.

protected isHistoryImmutable()

returnwild
This method is not documented.

private loadBundleFromConduit(ConduitClient $conduit, $params)

parametersConduitClient$conduit
wild$params
returnwild
This method is not documented.

protected loadDiffBundleFromConduit(ConduitClient $conduit, $diff_id)

parametersConduitClient$conduit
wild$diff_id
returnwild
This method is not documented.

protected loadProjectRepository()

returnwild
This method is not documented.

protected loadRevisionBundleFromConduit(ConduitClient $conduit, $revision_id)

parametersConduitClient$conduit
wild$revision_id
returnwild
This method is not documented.

protected newDiffParser()

returnwild
This method is not documented.

protected newInteractiveEditor($text)

parameterswild$text
returnwild
This method is not documented.

protected normalizeRevisionID($revision_id)

parameterswild$revision_id
returnwild
This method is not documented.

public parseArguments(array $args)

parametersarray$args
returnwild
This method is not documented.

public parseBaseCommitArgument(array $argv)

parametersarray$argv
returnwild
This method is not documented.

public static readGlobalArcConfig()

returnwild
This method is not documented.

public readLocalArcConfig()

returnwild
This method is not documented.

protected mixed readScratchFile($path)

parametersstring$pathScratch file name.
returnmixedString for file contents, or false for failure.

Try to read a scratch file, if it exists and is readable.

protected array readScratchJSONFile($path)

parametersstring$pathScratch file name.
returnarrayEmpty array for failure.

Try to read a scratch JSON file, if it exists and is readable.

public static readSystemArcConfig()

returnwild
This method is not documented.

public static readUserConfigurationFile()

returnwild
This method is not documented.

protected bool removeScratchFile($path)

parametersstring$pathScratch file name to remove.
returnboolTrue if the file was removed successfully.

Try to remove a scratch file.

protected renderRevisionList(array $revisions)

parametersarray$revisions
returnwild
This method is not documented.

public requireCleanWorkingCopy()

returnwild
This method is not documented.

public bool requiresAuthentication()

returnboolTrue if arc should build an authenticated conduit channel before running the workflow.

Override this to return true if your workflow requires an authenticated conduit channel. This implies that it requires a conduit. Arc will build and authenticate the channel for you before the workflow executes.

public bool requiresConduit()

returnboolTrue if arc should build a conduit channel before running the workflow.

Override this to return true if your workflow requires a conduit channel. Arc will build the channel for you before your workflow executes. This implies that you only need an unauthenticated channel; if you need authentication, override requiresAuthentication().

public requiresRepositoryAPI()

returnwild
This method is not documented.

public requiresWorkingCopy()

returnwild
This method is not documented.

protected resolveCall(ConduitFuture $method, $timeout = null)

parametersConduitFuture$method
wild$timeout
returnwild
This method is not documented.

public abstract run()

returnwild
This method is not documented.

protected list selectPathsForWorkflow(array $paths, $rev, $omit_mask = null)

parameterslist$pathsList of explicitly provided paths.
string|null$revRevision name, if provided.
mask$omit_maskMask of ArcanistRepositoryAPI flags to exclude. Defaults to ArcanistRepositoryAPI::FLAG_UNTRACKED.
returnlistList of paths the workflow should act on.

Workflows like 'lint' and 'unit' operate on a list of working copy paths. The user can either specify the paths explicitly ("a.js b.php"), or by specfifying a revision ("--rev a3f10f1f") to select all paths modified since that revision, or by omitting both and letting arc choose the default relative revision.

This method takes the user's selections and returns the paths that the workflow should act upon.

public setArcanistConfiguration(ArcanistConfiguration $arcanist_configuration)

parametersArcanistConfiguration$arcanist_configuration
returnwild
This method is not documented.

public setCommand($command)

parameterswild$command
returnwild
This method is not documented.

public setCommitMode($mode)

parameterswild$mode
returnwild
This method is not documented.

final public this setConduitCredentials(array $credentials)

parametersdict$credentialsA credential dictionary, see authenticateConduit().
returnthis

Set credentials which will be used to authenticate against Conduit. These credentials can then be used to establish an authenticated connection to conduit by calling authenticateConduit(). Arcanist sets some defaults for all workflows regardless of whether or not they return true from requireAuthentication(), based on the ~/.arcrc and .arcconf files if they are present. Thus, you can generally upgrade a workflow which does not require authentication into an authenticated workflow by later invoking requireAuthentication(). You should not normally need to call this method unless you are specifically overriding the defaults.

NOTE: You can not call this method after calling authenticateConduit().

public this setConduitTimeout($timeout)

parametersfloat$timeoutTimeout, in seconds.
returnthis

Override the default timeout for Conduit.

Controlled by the --conduit-timeout flag.

final public this setConduitURI($conduit_uri)

parametersstring$conduit_uriThe URI to open a conduit to when establishConduit() is called.
returnthis

Set the URI which the workflow will open a conduit connection to when establishConduit() is called. Arcanist makes an effort to set this by default for all workflows (by reading .arcconfig and/or the value of --conduit-uri) even if they don't need Conduit, so a workflow can generally upgrade into a conduit workflow later by just calling establishConduit().

You generally should not need to call this method unless you are specifically overriding the default URI. It is normally sufficient to just invoke establishConduit().

NOTE: You can not call this after a conduit has been established.

private setParentWorkflow($parent_workflow)

parameterswild$parent_workflow
returnwild
This method is not documented.

public setRepositoryAPI($api)

parameterswild$api
returnwild
This method is not documented.

public setWorkingCopy(ArcanistWorkingCopyIdentity $working_copy)

parametersArcanistWorkingCopyIdentity$working_copy
returnwild
This method is not documented.

public setWorkingDirectory($working_directory)

parameterswild$working_directory
returnwild
This method is not documented.

private shouldAmend()

returnwild
This method is not documented.

protected shouldRequireCleanUntrackedFiles()

returnwild
This method is not documented.

protected shouldShellComplete()

returnwild
This method is not documented.

final public willRunWorkflow()

returnwild
This method is not documented.

public static writeGlobalArcConfig(array $options)

parametersarray$options
returnwild
This method is not documented.

public writeLocalArcConfig(array $config)

parametersarray$config
returnwild
This method is not documented.

protected bool writeScratchFile($path, $data)

parametersstring$pathScratch file name to write.
string$dataData to write.
returnboolTrue on success, false on failure.

Try to write a scratch file, if there's somewhere to put it and we can write there.

protected bool writeScratchJSONFile($path, array $data)

parametersstring$pathScratch file name to write.
array$dataData to write.
returnboolTrue on success, false on failure.

Try to write a scratch JSON file, if there's somewhere to put it and we can write there.

protected void writeStatusMessage($msg)

parametersstring$msgMessage to write to stderr.
returnvoid

Write a message to stderr so that '--json' flags or stdout which is meant to be piped somewhere aren't disrupted.

public static writeUserConfigurationFile($config)

parameterswild$config
returnwild
This method is not documented.