diff --git a/src/workflow/ArcanistPatchWorkflow.php b/src/workflow/ArcanistPatchWorkflow.php --- a/src/workflow/ArcanistPatchWorkflow.php +++ b/src/workflow/ArcanistPatchWorkflow.php @@ -463,7 +463,8 @@ if ($repository_api instanceof ArcanistSubversionAPI) { $patch_err = 0; - $copies = array(); + $file_copies = array(); + $dir_copies = array(); $deletes = array(); $patches = array(); $propset = array(); @@ -525,10 +526,15 @@ throw new ArcanistUserAbortException(); } } else { - $copies[] = array( + $copy = array( $change->getOldPath(), $change->getCurrentPath(), ); + if (is_dir($repository_api->getPath($copy[0]))) { + $dir_copies[] = $copy; + } else { + $file_copies[] = $copy; + } } break; case ArcanistDiffChangeType::TYPE_ADD: @@ -549,9 +555,18 @@ } } - // Before we start doing anything, create all the directories we're going + // TODO: The SVN patch workflow likely does not work on windows because + // of the (cd ...) stuff. + + + // Do directory copying first + foreach ($dir_copies as $copy) { + $this->executeSubversionCopy($repository_api, $copy); + } + + // Create all the directories we're going // to add files to if they don't already exist. - foreach ($copies as $copy) { + foreach ($file_copies as $copy) { list($src, $dst) = $copy; $this->createParentDirectoryOf($dst); } @@ -564,17 +579,8 @@ $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( - csprintf( - '(cd %s; svn cp %s %s)', - $repository_api->getPath(), - ArcanistSubversionAPI::escapeFileNameForSVN($src), - ArcanistSubversionAPI::escapeFileNameForSVN($dst))); + foreach ($file_copies as $copy) { + $this->executeSubversionCopy($repository_api, $copy); } foreach ($deletes as $delete) { @@ -629,7 +635,7 @@ foreach ($adds as $add) { passthru( csprintf( - '(cd %s; svn add %s)', + '(cd %s; svn add --force %s)', $repository_api->getPath(), ArcanistSubversionAPI::escapeFileNameForSVN($add))); } @@ -835,6 +841,18 @@ return 0; } + private function executeSubversionCopy( + ArcanistRepositoryAPI $repository_api, + array $copy) { + list($src, $dst) = $copy; + passthru( + csprintf( + '(cd %s; svn cp --parents %s %s)', + $repository_api->getPath(), + ArcanistSubversionAPI::escapeFileNameForSVN($src), + ArcanistSubversionAPI::escapeFileNameForSVN($dst))); + } + private function getCommitMessage(ArcanistBundle $bundle) { $revision_id = $bundle->getRevisionID(); $commit_message = null;