]> khamidou — GitHub mirrors - arcanist.git/commitdiff
Don't fatal without Conduit for "--patch" and "--bundle"
authorepriestley <git@epriestley.com>
Fri, 16 Mar 2012 20:40:33 +0000 (13:40 -0700)
committerepriestley <git@epriestley.com>
Fri, 16 Mar 2012 20:40:33 +0000 (13:40 -0700)
Summary:
In some workflows, we don't have Conduit at all, so we'll fail with a raw exception. Test for conduit presence before trying to make the encoding call.

Also move some "instanceof" logic for updates into RepositoryAPI (factoring, windows compat).

Test Plan: Ran "arc patch --patch some.patch".

Reviewers: 20after4, davidreuss, nh, btrahan

Reviewed By: 20after4

CC: aran, epriestley
Differential Revision: https://secure.phabricator.com/D1935

src/repository/api/base/ArcanistRepositoryAPI.php
src/repository/api/git/ArcanistGitAPI.php
src/repository/api/mercurial/ArcanistMercurialAPI.php
src/repository/api/subversion/ArcanistSubversionAPI.php
src/workflow/patch/ArcanistPatchWorkflow.php

index 534b24089f03b071da4d9ea17266d0873b5b3c2d..d97aa8829800bb270f196de9add544e5413a36f5 100644 (file)
@@ -160,6 +160,7 @@ abstract class ArcanistRepositoryAPI {
   abstract public function getCanonicalRevisionName($string);
   abstract public function supportsRelativeLocalCommits();
   abstract public function getWorkingCopyRevision();
+  abstract public function updateWorkingCopy();
   abstract public function loadWorkingCopyDifferentialRevisions(
     ConduitClient $conduit,
     array $query);
index 0b8fb562b7fdb243c657e91c9a332136079e9f03..ecbc5b45b544ef92e15aa46c196d098da14c9109 100644 (file)
@@ -672,4 +672,8 @@ final class ArcanistGitAPI extends ArcanistRepositoryAPI {
     return $results;
   }
 
+  public function updateWorkingCopy() {
+    $this->execxLocal('pull');
+  }
+
 }
index 9804dde5c56a893007be51de1469ab663c9ef018..c78f38eee9debe12679f6746423efa047386a9bb 100644 (file)
@@ -430,4 +430,8 @@ final class ArcanistMercurialAPI extends ArcanistRepositoryAPI {
     return $results;
   }
 
+  public function updateWorkingCopy() {
+    $this->execxLocal('up');
+  }
+
 }
index 4498b60a0026747e078d26a81cd808597abef1bc..9c0c3ae6a9321df0c6671fab169a24cb18f2973f 100644 (file)
@@ -549,4 +549,8 @@ EODIFF;
     return $results;
   }
 
+  public function updateWorkingCopy() {
+    $this->execxLocal('up');
+  }
+
 }
index 2241fe66446ef44991e838cb09371c76dc2d9e79..536154d6c6d0269e2c2b6e1217cdb251bf5c474a 100644 (file)
@@ -298,27 +298,9 @@ EOTEXT
   }
 
   private function updateWorkingCopy() {
-    $repository_api = $this->getRepositoryAPI();
-    if ($repository_api instanceof ArcanistSubversionAPI) {
-      execx(
-        '(cd %s; svn up)',
-        $repository_api->getPath());
-      $message = "Updated to HEAD.  ";
-    } else if ($repository_api instanceof ArcanistGitAPI) {
-      execx(
-        '(cd %s; git pull)',
-        $repository_api->getPath());
-      $message = "Updated to HEAD.  ";
-    } else if ($repository_api instanceof ArcanistMercurialAPI) {
-      execx(
-        '(cd %s; hg up)',
-        $repository_api->getPath());
-      $message = "Updated to tip.  ";
-    } else {
-      throw new Exception('Unknown version control system.');
-    }
-
-    echo phutil_console_format($message."\n");
+    echo "Updating working copy...\n";
+    $this->getRepositoryAPI()->updateWorkingCopy();
+    echo "Done.\n";
   }
 
   public function run() {
@@ -367,10 +349,12 @@ EOTEXT
 
     $try_encoding = nonempty($this->getArgument('encoding'), null);
     if (!$try_encoding) {
-      try {
-        $try_encoding = $this->getRepositoryEncoding();
-      } catch (ConduitClientException $e) {
-        $try_encoding = null;
+      if ($this->requiresConduit()) {
+        try {
+          $try_encoding = $this->getRepositoryEncoding();
+        } catch (ConduitClientException $e) {
+          $try_encoding = null;
+        }
       }
     }