diff --git a/src/repository/api/mercurial/ArcanistMercurialAPI.php b/src/repository/api/mercurial/ArcanistMercurialAPI.php index fd893b42..4968a56d 100644 --- a/src/repository/api/mercurial/ArcanistMercurialAPI.php +++ b/src/repository/api/mercurial/ArcanistMercurialAPI.php @@ -33,10 +33,11 @@ class ArcanistMercurialAPI extends ArcanistRepositoryAPI { public function getSourceControlBaseRevision() { list($stdout) = execx( - '(cd %s && hg id -ir %s)', + '(cd %s && hg log -l 1 --template %s -r %s)', $this->getPath(), + '{node}\\n', $this->getRelativeCommit()); - return $stdout; + return rtrim($stdout, "\n"); } public function getSourceControlPath() { diff --git a/src/workflow/patch/ArcanistPatchWorkflow.php b/src/workflow/patch/ArcanistPatchWorkflow.php index eaaa100f..76cd249e 100644 --- a/src/workflow/patch/ArcanistPatchWorkflow.php +++ b/src/workflow/patch/ArcanistPatchWorkflow.php @@ -403,7 +403,7 @@ EOTEXT } return $patch_err; - } else { + } else if ($repository_api instanceof ArcanistGitAPI) { $future = new ExecFuture( '(cd %s; git apply --index --reject)', $repository_api->getPath()); @@ -412,6 +412,17 @@ EOTEXT echo phutil_console_format( "** OKAY ** Successfully applied patch.\n"); + } else if ($repository_api instanceof ArcanistMercurialAPI) { + $future = new ExecFuture( + '(cd %s; hg import --no-commit -)', + $repository_api->getPath()); + $future->write($bundle->toGitPatch()); + $future->resolvex(); + + echo phutil_console_format( + "** OKAY ** Successfully applied patch.\n"); + } else { + throw new Exception('Unknown version control system.'); } return 0;