]> khamidou — GitHub mirrors - arcanist.git/commitdiff
Search for SVN commit in Git SVN repository
authorvrana <jakubv@fb.com>
Fri, 21 Sep 2012 21:02:27 +0000 (14:02 -0700)
committervrana <jakubv@fb.com>
Fri, 28 Sep 2012 18:34:53 +0000 (11:34 -0700)
Summary: `arc patch` currently warns about "This diff is against commit svn+ssh://... but the commit is nowhere in the working copy" in Git SVN repository.

Test Plan:
  $ arc patch # in Git SVN repository
  $ svn find-rev r121212112 # invalid revision

Reviewers: epriestley

Reviewed By: epriestley

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

src/repository/api/ArcanistGitAPI.php

index d9b8465d7ef31501533d560c253c9bde0d30e4d6..f640da077a4fadf67c24d4249cd9756702a98e9e 100644 (file)
@@ -384,8 +384,17 @@ final class ArcanistGitAPI extends ArcanistRepositoryAPI {
   }
 
   public function getCanonicalRevisionName($string) {
-    list($stdout) = $this->execxLocal('show -s --format=%C %s',
-      '%H', $string);
+    $match = null;
+    if (preg_match('/@([0-9]+)$/', $string, $match)) {
+      list($stdout) = $this->execxLocal(
+        'svn find-rev r%d',
+        $match[1]);
+    } else {
+      list($stdout) = $this->execxLocal(
+        'show -s --format=%C %s',
+        '%H',
+        $string);
+    }
     return rtrim($stdout);
   }
 
@@ -682,7 +691,9 @@ final class ArcanistGitAPI extends ArcanistRepositoryAPI {
 
   public function hasLocalCommit($commit) {
     try {
-      $this->getCanonicalRevisionName($commit);
+      if (!$this->getCanonicalRevisionName($commit)) {
+        return false;
+      }
     } catch (CommandException $exception) {
       return false;
     }