]> khamidou — GitHub mirrors - arcanist.git/commitdiff
arc browse: Support line number and reduce conduit call
authorAviv Eyal <avivey@gmail.com>
Mon, 15 Jul 2013 02:14:34 +0000 (19:14 -0700)
committerepriestley <git@epriestley.com>
Mon, 15 Jul 2013 02:17:02 +0000 (19:17 -0700)
Summary:
support common "filename:line number" format.
Also, remove redundent conduit call.

Test Plan: arc browse with and without :33 suffix.

Reviewers: epriestley, vrana

Reviewed By: epriestley

CC: aran, Korvin
Differential Revision: https://secure.phabricator.com/D6451

src/workflow/ArcanistBrowseWorkflow.php

index df247be430de786c566b96fb05d64cf789947d5a..347824bc0ee6207eb93d34a40aa2de7320a03d2e 100644 (file)
@@ -79,6 +79,7 @@ EOTEXT
     $in_paths = $this->getArgument('paths');
     $paths = array();
     foreach ($in_paths as $key => $path) {
+      $path = preg_replace('/:([0-9]+)$/', '$\1', $path);
       $full_path = Filesystem::resolvePath($path);
 
       $paths[$key] = Filesystem::readablePath(
@@ -87,7 +88,7 @@ EOTEXT
     }
 
     if (!$paths) {
-      throw new ArcanistUsageException("Specify a path to browse");
+      throw new ArcanistUsageException("Specify a path to browse.");
     }
 
     $base_uri = $this->getBaseURI();
@@ -97,7 +98,7 @@ EOTEXT
       $ret_code = phutil_passthru("%s %s", $browser, $base_uri . $path);
       if ($ret_code) {
         throw new ArcanistUsageException(
-          "It seems we failed to open the browser; Perhaps you should try to ".
+          "It seems we failed to open the browser; perhaps you should try to ".
           "set the 'browser' config option. The command we tried to use was: ".
           $browser);
       }
@@ -115,16 +116,10 @@ EOTEXT
         'name' => $project_id,
       ));
 
-    $repo_phid = $project_info['repositoryPHID'];
-    $repo_info = $this->getConduit()->callMethodSynchronous(
-      'phid.query',
-      array(
-        'phids' => array($repo_phid),
-      ));
-
+    $repo_info = $project_info['repository'];
     $branch = $this->getArgument('branch', 'master');
 
-    return $repo_info[$repo_phid]['uri'].'browse/'.$branch.'/';
+    return $repo_info['uri'].'browse/'.$branch.'/';
   }
 
   private function getBrowserCommand() {