mirror of
https://we.phorge.it/source/phorge.git
synced 2024-11-10 00:42:41 +01:00
Add a Mercurial message parser
Summary: See D943, this is the second parse stage. This will mark Differential revisions as "Committed" among other things. Almost all the logic here is shared between VCSes so the implementation itself is straightforward. Test Plan: Parsed all messages for the official Mercurial repository. Reviewers: Makinde, jungejason, nh, tuomaspelkonen, aran Reviewed By: Makinde CC: aran, Makinde Differential Revision: 944
This commit is contained in:
parent
e0b86cc81b
commit
93b3bc8e89
4 changed files with 81 additions and 14 deletions
|
@ -579,6 +579,7 @@ phutil_register_library_map(array(
|
|||
'PhabricatorRepositoryGitHubPostReceiveController' => 'applications/repository/controller/github-post-receive',
|
||||
'PhabricatorRepositoryListController' => 'applications/repository/controller/list',
|
||||
'PhabricatorRepositoryMercurialCommitDiscoveryDaemon' => 'applications/repository/daemon/commitdiscovery/mercurial',
|
||||
'PhabricatorRepositoryMercurialCommitMessageParserWorker' => 'applications/repository/worker/commitmessageparser/mercurial',
|
||||
'PhabricatorRepositoryMercurialPullDaemon' => 'applications/repository/daemon/mercurialpull',
|
||||
'PhabricatorRepositoryPullLocalDaemon' => 'applications/repository/daemon/pulllocal',
|
||||
'PhabricatorRepositoryShortcut' => 'applications/repository/storage/shortcut',
|
||||
|
@ -1180,6 +1181,7 @@ phutil_register_library_map(array(
|
|||
'PhabricatorRepositoryGitHubPostReceiveController' => 'PhabricatorRepositoryController',
|
||||
'PhabricatorRepositoryListController' => 'PhabricatorRepositoryController',
|
||||
'PhabricatorRepositoryMercurialCommitDiscoveryDaemon' => 'PhabricatorRepositoryCommitDiscoveryDaemon',
|
||||
'PhabricatorRepositoryMercurialCommitMessageParserWorker' => 'PhabricatorRepositoryCommitMessageParserWorker',
|
||||
'PhabricatorRepositoryMercurialPullDaemon' => 'PhabricatorRepositoryPullLocalDaemon',
|
||||
'PhabricatorRepositoryPullLocalDaemon' => 'PhabricatorRepositoryDaemon',
|
||||
'PhabricatorRepositoryShortcut' => 'PhabricatorRepositoryDAO',
|
||||
|
|
|
@ -51,28 +51,25 @@ class PhabricatorRepositoryCommitTaskDaemon
|
|||
switch ($vcs) {
|
||||
case PhabricatorRepositoryType::REPOSITORY_TYPE_GIT:
|
||||
$class = 'PhabricatorRepositoryGitCommitMessageParserWorker';
|
||||
$task = new PhabricatorWorkerTask();
|
||||
$task->setTaskClass($class);
|
||||
$task->setData(
|
||||
array(
|
||||
'commitID' => $commit->getID(),
|
||||
));
|
||||
$task->save();
|
||||
break;
|
||||
case PhabricatorRepositoryType::REPOSITORY_TYPE_SVN:
|
||||
$class = 'PhabricatorRepositorySvnCommitMessageParserWorker';
|
||||
$task = new PhabricatorWorkerTask();
|
||||
$task->setTaskClass($class);
|
||||
$task->setData(
|
||||
array(
|
||||
'commitID' => $commit->getID(),
|
||||
));
|
||||
$task->save();
|
||||
break;
|
||||
case PhabricatorRepositoryType::REPOSITORY_TYPE_MERCURIAL:
|
||||
$class = 'PhabricatorRepositoryMercurialCommitMessageParserWorker';
|
||||
break;
|
||||
default:
|
||||
throw new Exception("Unknown repository type.");
|
||||
}
|
||||
|
||||
$task = new PhabricatorWorkerTask();
|
||||
$task->setTaskClass($class);
|
||||
$task->setData(
|
||||
array(
|
||||
'commitID' => $commit->getID(),
|
||||
));
|
||||
$task->save();
|
||||
|
||||
$this->stillWorking();
|
||||
}
|
||||
sleep(1);
|
||||
|
|
|
@ -0,0 +1,53 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
* Copyright 2011 Facebook, Inc.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
class PhabricatorRepositoryMercurialCommitMessageParserWorker
|
||||
extends PhabricatorRepositoryCommitMessageParserWorker {
|
||||
|
||||
public function parseCommit(
|
||||
PhabricatorRepository $repository,
|
||||
PhabricatorRepositoryCommit $commit) {
|
||||
|
||||
$local_path = $repository->getDetail('local-path');
|
||||
|
||||
list($stdout) = $repository->execxLocalCommand(
|
||||
'log --template %s --rev %s',
|
||||
'{author}\\n{desc}',
|
||||
$commit->getCommitIdentifier());
|
||||
|
||||
list($author, $message) = explode("\n", $stdout, 2);
|
||||
|
||||
$author = phutil_utf8ize($author);
|
||||
$message = phutil_utf8ize($message);
|
||||
$message = trim($message);
|
||||
|
||||
$this->updateCommitData($author, $message);
|
||||
|
||||
if ($this->shouldQueueFollowupTasks()) {
|
||||
$task = new PhabricatorWorkerTask();
|
||||
$task->setTaskClass(
|
||||
'PhabricatorRepositoryMercurialCommitChangeParserWorker');
|
||||
$task->setData(
|
||||
array(
|
||||
'commitID' => $commit->getID(),
|
||||
));
|
||||
$task->save();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,15 @@
|
|||
<?php
|
||||
/**
|
||||
* This file is automatically generated. Lint this module to rebuild it.
|
||||
* @generated
|
||||
*/
|
||||
|
||||
|
||||
|
||||
phutil_require_module('phabricator', 'applications/repository/worker/commitmessageparser/base');
|
||||
phutil_require_module('phabricator', 'infrastructure/daemon/workers/storage/task');
|
||||
|
||||
phutil_require_module('phutil', 'utils');
|
||||
|
||||
|
||||
phutil_require_source('PhabricatorRepositoryMercurialCommitMessageParserWorker.php');
|
Loading…
Reference in a new issue