diff --git a/src/workflow/diff/ArcanistDiffWorkflow.php b/src/workflow/diff/ArcanistDiffWorkflow.php index 6e928ea4..7135c255 100644 --- a/src/workflow/diff/ArcanistDiffWorkflow.php +++ b/src/workflow/diff/ArcanistDiffWorkflow.php @@ -20,7 +20,7 @@ class ArcanistDiffWorkflow extends ArcanistBaseWorkflow { private $hasWarnedExternals = false; private $unresolvedLint; - private $unresolvedUnit; + private $unresolvedTests; public function getCommandHelp() { return phutil_console_format(<<getRepositoryAPI(); if ($repository_api instanceof ArcanistSubversionAPI) { + $patch_err = 0; + $copies = array(); $deletes = array(); $patches = array(); @@ -248,11 +250,16 @@ EOTEXT foreach ($patches as $path => $patch) { $tmp = new TempFile(); Filesystem::writeFile($tmp, $patch); + $err = null; passthru( csprintf( '(cd %s; patch -p0 < %s)', $repository_api->getPath(), - $tmp)); + $tmp), + $err); + if ($err) { + $patch_err = max($patch_err, $err); + } } foreach ($adds as $add) { @@ -286,13 +293,32 @@ EOTEXT } } - echo "Applied patch.\n"; + if ($patch_err == 0) { + echo phutil_console_format( + "** OKAY ** Successfully applied patch to the ". + "working copy.\n"); + } else { + echo phutil_console_format( + "\n\n** WARNING ** Some hunks could not be applied ". + "cleanly by the unix 'patch' utility. Your working copy may be ". + "different from the revision's base, or you may be in the wrong ". + "subdirectory. You can export the raw patch file using ". + "'arc export --unified', and then try to apply it by fiddling with ". + "options to 'patch' (particularly, -p), or manually. The output ". + "above, from 'patch', may be helpful in figuring out what went ". + "wrong.\n"); + } + + return $patch_err; } else { $future = new ExecFuture( '(cd %s; git apply --index)', $repository_api->getPath()); $future->write($bundle->toGitPatch()); $future->resolvex(); + + echo phutil_console_format( + "** OKAY ** Successfully applied patch.\n"); } return 0;