From: Bob Trahan Date: Tue, 17 Jan 2012 01:12:34 +0000 (-0800) Subject: Make arc patch be less ROFL for mercurial X-Git-Tag: conduit-4~185 X-Git-Url: http://git.khamidou.com/?a=commitdiff_plain;h=6c613292f7d580234470e3d4e8e211f7a739a326;p=arcanist.git Make arc patch be less ROFL for mercurial Summary: pretty easy stuff as mercurial accepts git style patches...! also fixed two issues where we were 1) storing the short hash and 2) storing it with a trailing "\n". This diff makes us store the full hash AND no trailing return character Test Plan: in my mercurial repo hg commit -m "something dumb" arc diff hg checkout $foo arc patch DX use conduit console to verify a few diffs were returning the correct full revision hash with a trailing \n Reviewers: epriestley Reviewed By: epriestley CC: aran Maniphest Tasks: T630 Differential Revision: https://secure.phabricator.com/D1431 --- 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;