Changeset View
Changeset View
Standalone View
Standalone View
src/workflow/ArcanistBrowseWorkflow.php
Show All 18 Lines | EOTEXT | ||||
public function getCommandHelp() { | public function getCommandHelp() { | ||||
return phutil_console_format(<<<EOTEXT | return phutil_console_format(<<<EOTEXT | ||||
Supports: git, hg, svn | Supports: git, hg, svn | ||||
Open a file or object (like a task or revision) in your web browser. | Open a file or object (like a task or revision) in your web browser. | ||||
$ arc browse README # Open a file in Diffusion. | $ arc browse README # Open a file in Diffusion. | ||||
$ arc browse T123 # View a task. | $ arc browse T123 # View a task. | ||||
$ arc browse HEAD # View a symbolic commit. | |||||
Set the 'browser' value using 'arc set-config' to select a browser. If | Set the 'browser' value using 'arc set-config' to select a browser. If | ||||
no browser is set, the command will try to guess which browser to use. | no browser is set, the command will try to guess which browser to use. | ||||
EOTEXT | EOTEXT | ||||
); | ); | ||||
} | } | ||||
public function getArguments() { | public function getArguments() { | ||||
▲ Show 20 Lines • Show All 59 Lines • ▼ Show 20 Lines | foreach ($objects as $name => $object) { | ||||
unset($things[$name]); | unset($things[$name]); | ||||
} | } | ||||
if ($this->hasRepositoryAPI()) { | if ($this->hasRepositoryAPI()) { | ||||
$repository_api = $this->getRepositoryAPI(); | $repository_api = $this->getRepositoryAPI(); | ||||
$project_root = $this->getWorkingCopy()->getProjectRoot(); | $project_root = $this->getWorkingCopy()->getProjectRoot(); | ||||
// First, try to resolve arguments as symbolic commits. | |||||
$commits = array(); | |||||
foreach ($things as $key => $thing) { | |||||
$commit = $repository_api->getCanonicalRevisionName($thing); | |||||
if ($commit) { | |||||
$commits[$commit] = $key; | |||||
} | |||||
} | |||||
if ($commits) { | |||||
$commit_info = $this->getConduit()->callMethodSynchronous( | |||||
'diffusion.querycommits', | |||||
array( | |||||
'repositoryPHID' => $this->getRepositoryPHID(), | |||||
'names' => array_keys($commits), | |||||
)); | |||||
foreach ($commit_info['identifierMap'] as $ckey => $cphid) { | |||||
$thing = $commits[$ckey]; | |||||
unset($things[$thing]); | |||||
$uris[] = $commit_info['data'][$cphid]['uri']; | |||||
$console->writeOut( | |||||
pht( | |||||
'Opening **%s** as a commit.', | |||||
$thing)."\n"); | |||||
} | |||||
} | |||||
// If we fail, try to resolve them as paths. | |||||
foreach ($things as $key => $path) { | foreach ($things as $key => $path) { | ||||
$path = preg_replace('/:([0-9]+)$/', '$\1', $path); | $path = preg_replace('/:([0-9]+)$/', '$\1', $path); | ||||
$full_path = Filesystem::resolvePath($path); | $full_path = Filesystem::resolvePath($path); | ||||
if (!$is_force && !Filesystem::pathExists($full_path)) { | if (!$is_force && !Filesystem::pathExists($full_path)) { | ||||
continue; | continue; | ||||
} | } | ||||
Show All 13 Lines | if ($this->hasRepositoryAPI()) { | ||||
$base_uri = $this->getBaseURI(); | $base_uri = $this->getBaseURI(); | ||||
$uris[] = $base_uri.$path; | $uris[] = $base_uri.$path; | ||||
} | } | ||||
} else { | } else { | ||||
if ($things) { | if ($things) { | ||||
$console->writeOut( | $console->writeOut( | ||||
pht( | pht( | ||||
"The current working directory is not a repository working ". | "The current working directory is not a repository working ". | ||||
"copy, so remaining arguments can not be resolved as paths. ". | "copy, so remaining arguments can not be resolved as paths or ". | ||||
"To browse paths in Diffusion, run 'arc browse' from inside ". | "commits. To browse paths or symbolic commits in Diffusion, run ". | ||||
"a working copy.")."\n"); | "'arc browse' from inside a working copy.")."\n"); | ||||
} | } | ||||
} | } | ||||
foreach ($things as $thing) { | foreach ($things as $thing) { | ||||
$console->writeOut( | $console->writeOut( | ||||
pht( | pht( | ||||
'Unable to find an object named **%s**, and no such path exists '. | 'Unable to find an object named **%s**, no such commit exists in '. | ||||
'in the working copy. Use __--force__ to treat this as a path '. | 'the remote, and no such path exists in the working copy. Use '. | ||||
'anyway.', | '__--force__ to treat this as a path anyway.', | ||||
$thing)."\n"); | $thing)."\n"); | ||||
} | } | ||||
if ($uris) { | if ($uris) { | ||||
$this->openURIsInBrowser($uris); | $this->openURIsInBrowser($uris); | ||||
} | } | ||||
return 0; | return 0; | ||||
Show All 18 Lines |