From d90f44ef2058f74c19ae0f6cdd2d2f17b25bea46 Mon Sep 17 00:00:00 2001 From: epriestley Date: Wed, 18 Dec 2013 14:19:18 -0800 Subject: [PATCH] Support content pre-commit hooks in Mercurial Summary: Ref T4195. Add Mercurial support to the content hook phase. Test Plan: Here are some `commit` push logs for a Mercurial repo: {F90689} Reviewers: btrahan Reviewed By: btrahan CC: aran Maniphest Tasks: T4195 Differential Revision: https://secure.phabricator.com/D7792 --- .../diffusion/engine/DiffusionCommitHookEngine.php | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/src/applications/diffusion/engine/DiffusionCommitHookEngine.php b/src/applications/diffusion/engine/DiffusionCommitHookEngine.php index eeb4a44ced..5471cd9165 100644 --- a/src/applications/diffusion/engine/DiffusionCommitHookEngine.php +++ b/src/applications/diffusion/engine/DiffusionCommitHookEngine.php @@ -25,6 +25,7 @@ final class DiffusionCommitHookEngine extends Phobject { private $remoteProtocol; private $transactionKey; private $mercurialHook; + private $mercurialCommits = array(); private $heraldViewerProjects; @@ -578,6 +579,7 @@ final class DiffusionCommitHookEngine extends Phobject { list($commit_raw) = $futures['commits']->resolvex(); $commit_map = $this->parseMercurialCommits($commit_raw); + $this->mercurialCommits = $commit_map; list($old_raw) = $futures['old']->resolvex(); $old_refs = $this->parseMercurialHeads($old_raw); @@ -797,8 +799,16 @@ final class DiffusionCommitHookEngine extends Phobject { } private function findMercurialContentUpdates(array $ref_updates) { - // TODO: Implement. - return array(); + $content_updates = array(); + + foreach ($this->mercurialCommits as $commit => $branches) { + $content_updates[$commit] = $this->newPushLog() + ->setRefType(PhabricatorRepositoryPushLog::REFTYPE_COMMIT) + ->setRefNew($commit) + ->setChangeFlags(PhabricatorRepositoryPushLog::CHANGEFLAG_ADD); + } + + return $content_updates; } private function parseMercurialCommits($raw) {