From: epriestley Date: Sun, 25 Mar 2012 16:32:20 +0000 (-0700) Subject: Improve compatibility of "arc patch" on Windows X-Git-Tag: conduit-4~77 X-Git-Url: http://git.khamidou.com/?a=commitdiff_plain;h=4ca58d11298e91363b8a81f9d61ba81aea57fff8;p=arcanist.git Improve compatibility of "arc patch" on Windows Summary: Can't use (cd ...) on windows. Test Plan: Ran "arc patch" successfully. Reviewers: Makinde, btrahan Reviewed By: btrahan CC: aran, epriestley Maniphest Tasks: T124, T1034 Differential Revision: https://secure.phabricator.com/D1987 --- diff --git a/src/repository/api/base/ArcanistRepositoryAPI.php b/src/repository/api/base/ArcanistRepositoryAPI.php index d97aa882..af86d025 100644 --- a/src/repository/api/base/ArcanistRepositoryAPI.php +++ b/src/repository/api/base/ArcanistRepositoryAPI.php @@ -97,9 +97,10 @@ abstract class ArcanistRepositoryAPI { public function getPath($to_file = null) { if ($to_file !== null) { - return $this->path.'/'.ltrim($to_file, '/'); + return $this->path.DIRECTORY_SEPARATOR. + ltrim($to_file, DIRECTORY_SEPARATOR); } else { - return $this->path.'/'; + return $this->path.DIRECTORY_SEPARATOR; } } @@ -201,6 +202,11 @@ abstract class ArcanistRepositoryAPI { return $this->buildLocalFuture($args)->resolve(); } + public function execFutureLocal($pattern /*, ... */) { + $args = func_get_args(); + return $this->buildLocalFuture($args); + } + abstract protected function buildLocalFuture(array $argv); } diff --git a/src/workflow/patch/ArcanistPatchWorkflow.php b/src/workflow/patch/ArcanistPatchWorkflow.php index 9df29ac0..f5b97579 100644 --- a/src/workflow/patch/ArcanistPatchWorkflow.php +++ b/src/workflow/patch/ArcanistPatchWorkflow.php @@ -233,11 +233,9 @@ EOTEXT foreach ($suffixes as $suffix) { $proposed_name = $base_name.$suffix; - list($err) = exec_manual( - '(cd %s; git rev-parse --verify %s)', - $repository_api->getPath(), - $proposed_name - ); + list($err) = $repository_api->execManualLocal( + 'rev-parse --verify %s', + $proposed_name); // no error means git rev-parse found a branch if (!$err) { @@ -273,21 +271,18 @@ EOTEXT // NOTE: Use 'cat-file', not 'rev-parse --verify', because 'rev-parse' // always "verifies" any properly-formatted commit even if it does not // exist. - list($err) = exec_manual( - '(cd %s; git cat-file -t %s)', - $repository_api->getPath(), + list($err) = $repository_api->execManualLocal( + 'cat-file -t %s', $base_revision); if ($base_revision && !$err) { - execx( - '(cd %s; git checkout -b %s %s)', - $repository_api->getPath(), + $repository_api->execxLocal( + 'checkout -b %s %s', $branch_name, $base_revision); } else { - execx( - '(cd %s; git checkout -b %s)', - $repository_api->getPath(), + $repository_api->execxLocal( + 'checkout -b %s', $branch_name); } @@ -481,6 +476,9 @@ EOTEXT $this->createParentDirectoryOf($add); } + // TODO: The SVN patch workflow likely does not work on windows because + // of the (cd ...) stuff. + foreach ($copies as $copy) { list($src, $dst) = $copy; passthru( @@ -580,17 +578,15 @@ EOTEXT return $patch_err; } else if ($repository_api instanceof ArcanistGitAPI) { - $future = new ExecFuture( - '(cd %s; git apply --index --reject)', - $repository_api->getPath()); + $future = $repository_api->execFutureLocal( + 'apply --index --reject'); $future->write($bundle->toGitPatch()); $future->resolvex(); if ($this->shouldCommit()) { $commit_message = $this->getCommitMessage($bundle); - $future = new ExecFuture( - '(cd %s; git commit -a -F -)', - $repository_api->getPath()); + $future = $repository_api->execFutureLocal( + 'commit -a -F -'); $future->write($commit_message); $future->resolvex(); $verb = 'committed'; @@ -600,9 +596,8 @@ EOTEXT echo phutil_console_format( "** OKAY ** Successfully {$verb} patch.\n"); } else if ($repository_api instanceof ArcanistMercurialAPI) { - $future = new ExecFuture( - '(cd %s; hg import --no-commit -)', - $repository_api->getPath()); + $future = $repository_api->execFutureLocal( + 'import --no-commit -'); $future->write($bundle->toGitPatch()); $future->resolvex();