]> khamidou — GitHub mirrors - arcanist.git/commitdiff
Support `git svn dcommit` in `arc land`
authorvrana <jakubv@fb.com>
Sat, 8 Dec 2012 02:13:32 +0000 (18:13 -0800)
committervrana <jakubv@fb.com>
Mon, 10 Dec 2012 20:28:44 +0000 (12:28 -0800)
Test Plan:
  $ arc land # in Git SVN repository

Reviewers: epriestley

Reviewed By: epriestley

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

src/workflow/ArcanistBaseWorkflow.php
src/workflow/ArcanistLandWorkflow.php

index 86bf2eb7087bc1ff068859643010a814edeac22f..71f16a27927ce7f7a0dfa3dce6f05fb3c15a2f2f 100644 (file)
@@ -859,20 +859,14 @@ abstract class ArcanistBaseWorkflow {
 
     // TODO: Check commits since tracking branch. If empty then return false.
 
-    $repository_phid = idx($this->getProjectInfo(), 'repositoryPHID');
-    if ($repository_phid) {
-      $repositories = $this->getConduit()->callMethodSynchronous(
-        'repository.query',
-        array());
-      $callsigns = ipull($repositories, 'callsign', 'phid');
-      $callsign = idx($callsigns, $repository_phid);
-      if ($callsign) {
-        $known_commits = $this->getConduit()->callMethodSynchronous(
-          'diffusion.getcommits',
-          array('commits' => array('r'.$callsign.$commit['commit'])));
-        if (ifilter($known_commits, 'error', $negate = true)) {
-          return false;
-        }
+    $repository = $this->loadProjectRepository();
+    if ($repository) {
+      $callsign = $repository['callsign'];
+      $known_commits = $this->getConduit()->callMethodSynchronous(
+        'diffusion.getcommits',
+        array('commits' => array('r'.$callsign.$commit['commit'])));
+      if (ifilter($known_commits, 'error', $negate = true)) {
+        return false;
       }
     }
 
@@ -1432,6 +1426,20 @@ abstract class ArcanistBaseWorkflow {
     return $this->projectInfo;
   }
 
+  protected function loadProjectRepository() {
+    $repository_phid = idx($this->getProjectInfo(), 'repositoryPHID');
+    if (!$repository_phid) {
+      return array();
+    }
+
+    $repositories = $this->getConduit()->callMethodSynchronous(
+      'repository.query',
+      array());
+    $repositories = ipull($repositories, null, 'phid');
+
+    return idx($repositories, $repository_phid, array());
+  }
+
   protected function newInteractiveEditor($text) {
     $editor = new PhutilInteractiveEditor($text);
 
index e84bf610bfab973d3888fe777879dee8946b4eaa..1203b3d4e8e852ec6e44dd72d5728116fffd1386 100644 (file)
@@ -7,6 +7,7 @@
  */
 final class ArcanistLandWorkflow extends ArcanistBaseWorkflow {
   private $isGit;
+  private $isGitSvn;
   private $isHg;
 
   private $oldBranch;
@@ -170,6 +171,11 @@ EOTEXT
         "'arc land' only supports git and mercurial.");
     }
 
+    if ($this->isGit) {
+      $repository = $this->loadProjectRepository();
+      $this->isGitSvn = (idx($repository, 'vcs') == 'svn');
+    }
+
     $branch = $this->getArgument('branch');
     if (empty($branch)) {
       $branch = $this->getBranchOrBookmark();
@@ -205,7 +211,9 @@ EOTEXT
     }
 
     $this->ontoRemoteBranch = $this->onto;
-    if ($this->isGit) {
+    if ($this->isGitSvn) {
+      $this->ontoRemoteBranch = 'trunk';
+    } else if ($this->isGit) {
       $this->ontoRemoteBranch = $this->remote.'/'.$this->onto;
     }
 
@@ -362,13 +370,14 @@ EOTEXT
     if ($this->isGit) {
       $repository_api->execxLocal('pull --ff-only');
 
-      list($out) = $repository_api->execxLocal(
-        'log %s/%s..%s',
-        $this->remote,
-        $this->onto,
-        $this->onto);
-      if (strlen(trim($out))) {
-        $local_ahead_of_remote = true;
+      if (!$this->isGitSvn) {
+        list($out) = $repository_api->execxLocal(
+          'log %s..%s',
+          $this->ontoRemoteBranch,
+          $this->onto);
+        if (strlen(trim($out))) {
+          $local_ahead_of_remote = true;
+        }
       }
     } else if ($this->isHg) {
       // execManual instead of execx because outgoing returns
@@ -549,7 +558,9 @@ EOTEXT
 
       chdir($repository_api->getPath());
 
-      if ($this->isGit) {
+      if ($this->isGitSvn) {
+        $err = phutil_passthru('git svn dcommit');
+      } else if ($this->isGit) {
         $err = phutil_passthru(
           'git push %s %s',
           $this->remote,