Changeset View
Changeset View
Standalone View
Standalone View
src/workflow/ArcanistBrowseWorkflow.php
| Show All 31 Lines | EOTEXT | ||||
| ); | ); | ||||
| } | } | ||||
| public function getArguments() { | public function getArguments() { | ||||
| return array( | return array( | ||||
| 'branch' => array( | 'branch' => array( | ||||
| 'param' => 'branch_name', | 'param' => 'branch_name', | ||||
| 'help' => pht( | 'help' => pht( | ||||
| 'Default branch name to view on server. Defaults to "master".'), | 'Default branch name to view on server. Defaults to "%s".', | ||||
| 'master'), | |||||
| ), | ), | ||||
| 'force' => array( | 'force' => array( | ||||
| 'help' => pht( | 'help' => pht( | ||||
| 'Open arguments as paths, even if they do not exist in the '. | 'Open arguments as paths, even if they do not exist in the '. | ||||
| 'working copy.'), | 'working copy.'), | ||||
| ), | ), | ||||
| '*' => 'paths', | '*' => 'paths', | ||||
| ); | ); | ||||
| Show All 20 Lines | public function run() { | ||||
| $is_force = $this->getArgument('force'); | $is_force = $this->getArgument('force'); | ||||
| $things = $this->getArgument('paths'); | $things = $this->getArgument('paths'); | ||||
| if (!$things) { | if (!$things) { | ||||
| throw new ArcanistUsageException( | throw new ArcanistUsageException( | ||||
| pht( | pht( | ||||
| 'Specify one or more paths or objects to browse. Use the command '. | 'Specify one or more paths or objects to browse. Use the command '. | ||||
| '"arc browse ." if you want to browse this directory.')); | '"%s" if you want to browse this directory.', | ||||
| 'arc browse .')); | |||||
| } | } | ||||
| $things = array_fuse($things); | $things = array_fuse($things); | ||||
| $objects = $this->getConduit()->callMethodSynchronous( | $objects = $this->getConduit()->callMethodSynchronous( | ||||
| 'phid.lookup', | 'phid.lookup', | ||||
| array( | array( | ||||
| 'names' => array_keys($things), | 'names' => array_keys($things), | ||||
| )); | )); | ||||
| ▲ Show 20 Lines • Show All 91 Lines • ▼ Show 20 Lines | if ($this->hasRepositoryAPI()) { | ||||
| $uri = $uri.'$'.$lines; | $uri = $uri.'$'.$lines; | ||||
| } | } | ||||
| $uris[] = $uri; | $uris[] = $uri; | ||||
| } | } | ||||
| } else { | } else { | ||||
| if ($things) { | if ($things) { | ||||
| $console->writeOut( | $console->writeOut( | ||||
| "%s\n", | |||||
| 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 or ". | "copy, so remaining arguments can not be resolved as paths or ". | ||||
| "commits. To browse paths or symbolic commits in Diffusion, run ". | "commits. To browse paths or symbolic commits in Diffusion, run ". | ||||
| "'arc browse' from inside a working copy.")."\n"); | "'%s' from inside a working copy.", | ||||
| 'arc browse')); | |||||
| } | } | ||||
| } | } | ||||
| foreach ($things as $thing) { | foreach ($things as $thing) { | ||||
| $console->writeOut( | $console->writeOut( | ||||
| "%s\n", | |||||
| pht( | pht( | ||||
| 'Unable to find an object named **%s**, no such commit exists in '. | 'Unable to find an object named **%s**, no such commit exists in '. | ||||
| 'the remote, and no such path exists in the working copy. Use '. | 'the remote, and no such path exists in the working copy. Use '. | ||||
| '__--force__ to treat this as a path anyway.', | '__%s__ to treat this as a path anyway.', | ||||
| $thing)."\n"); | $thing, | ||||
| '--force')); | |||||
| } | } | ||||
| if ($uris) { | if ($uris) { | ||||
| $this->openURIsInBrowser($uris); | $this->openURIsInBrowser($uris); | ||||
| } | } | ||||
| return 0; | return 0; | ||||
| } | } | ||||
| private function getBaseURI() { | private function getBaseURI() { | ||||
| $repo_uri = $this->getRepositoryURI(); | $repo_uri = $this->getRepositoryURI(); | ||||
| if ($repo_uri === null) { | if ($repo_uri === null) { | ||||
| throw new ArcanistUsageException( | throw new ArcanistUsageException( | ||||
| pht( | pht( | ||||
| 'arc is unable to determine which repository in Diffusion '. | 'arc is unable to determine which repository in Diffusion '. | ||||
| 'this working copy belongs to. Use "arc which" to understand how '. | 'this working copy belongs to. Use "%s" to understand how '. | ||||
| 'arc looks for a repository.')); | '%s looks for a repository.', | ||||
| 'arc which', | |||||
| 'arc')); | |||||
| } | } | ||||
| $branch = $this->getArgument('branch', 'master'); | $branch = $this->getArgument('branch', 'master'); | ||||
| return $repo_uri.'browse/'.$branch.'/'; | return $repo_uri.'browse/'.$branch.'/'; | ||||
| } | } | ||||
| } | } | ||||