diff --git a/src/repository/api/base/ArcanistRepositoryAPI.php b/src/repository/api/base/ArcanistRepositoryAPI.php index 534b2408..d97aa882 100644 --- a/src/repository/api/base/ArcanistRepositoryAPI.php +++ b/src/repository/api/base/ArcanistRepositoryAPI.php @@ -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); diff --git a/src/repository/api/git/ArcanistGitAPI.php b/src/repository/api/git/ArcanistGitAPI.php index 0b8fb562..ecbc5b45 100644 --- a/src/repository/api/git/ArcanistGitAPI.php +++ b/src/repository/api/git/ArcanistGitAPI.php @@ -672,4 +672,8 @@ final class ArcanistGitAPI extends ArcanistRepositoryAPI { return $results; } + public function updateWorkingCopy() { + $this->execxLocal('pull'); + } + } diff --git a/src/repository/api/mercurial/ArcanistMercurialAPI.php b/src/repository/api/mercurial/ArcanistMercurialAPI.php index 9804dde5..c78f38ee 100644 --- a/src/repository/api/mercurial/ArcanistMercurialAPI.php +++ b/src/repository/api/mercurial/ArcanistMercurialAPI.php @@ -430,4 +430,8 @@ final class ArcanistMercurialAPI extends ArcanistRepositoryAPI { return $results; } + public function updateWorkingCopy() { + $this->execxLocal('up'); + } + } diff --git a/src/repository/api/subversion/ArcanistSubversionAPI.php b/src/repository/api/subversion/ArcanistSubversionAPI.php index 4498b60a..9c0c3ae6 100644 --- a/src/repository/api/subversion/ArcanistSubversionAPI.php +++ b/src/repository/api/subversion/ArcanistSubversionAPI.php @@ -549,4 +549,8 @@ EODIFF; return $results; } + public function updateWorkingCopy() { + $this->execxLocal('up'); + } + } diff --git a/src/workflow/patch/ArcanistPatchWorkflow.php b/src/workflow/patch/ArcanistPatchWorkflow.php index 2241fe66..536154d6 100644 --- a/src/workflow/patch/ArcanistPatchWorkflow.php +++ b/src/workflow/patch/ArcanistPatchWorkflow.php @@ -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; + } } }