Skip to content

Commit 93b3bc8

Browse files
author
epriestley
committed
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
1 parent e0b86cc commit 93b3bc8

File tree

4 files changed

+81
-14
lines changed

4 files changed

+81
-14
lines changed

src/__phutil_library_map__.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -579,6 +579,7 @@
579579
'PhabricatorRepositoryGitHubPostReceiveController' => 'applications/repository/controller/github-post-receive',
580580
'PhabricatorRepositoryListController' => 'applications/repository/controller/list',
581581
'PhabricatorRepositoryMercurialCommitDiscoveryDaemon' => 'applications/repository/daemon/commitdiscovery/mercurial',
582+
'PhabricatorRepositoryMercurialCommitMessageParserWorker' => 'applications/repository/worker/commitmessageparser/mercurial',
582583
'PhabricatorRepositoryMercurialPullDaemon' => 'applications/repository/daemon/mercurialpull',
583584
'PhabricatorRepositoryPullLocalDaemon' => 'applications/repository/daemon/pulllocal',
584585
'PhabricatorRepositoryShortcut' => 'applications/repository/storage/shortcut',
@@ -1180,6 +1181,7 @@
11801181
'PhabricatorRepositoryGitHubPostReceiveController' => 'PhabricatorRepositoryController',
11811182
'PhabricatorRepositoryListController' => 'PhabricatorRepositoryController',
11821183
'PhabricatorRepositoryMercurialCommitDiscoveryDaemon' => 'PhabricatorRepositoryCommitDiscoveryDaemon',
1184+
'PhabricatorRepositoryMercurialCommitMessageParserWorker' => 'PhabricatorRepositoryCommitMessageParserWorker',
11831185
'PhabricatorRepositoryMercurialPullDaemon' => 'PhabricatorRepositoryPullLocalDaemon',
11841186
'PhabricatorRepositoryPullLocalDaemon' => 'PhabricatorRepositoryDaemon',
11851187
'PhabricatorRepositoryShortcut' => 'PhabricatorRepositoryDAO',

src/applications/repository/daemon/committask/PhabricatorRepositoryCommitTaskDaemon.php

Lines changed: 11 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -51,28 +51,25 @@ final public function run() {
5151
switch ($vcs) {
5252
case PhabricatorRepositoryType::REPOSITORY_TYPE_GIT:
5353
$class = 'PhabricatorRepositoryGitCommitMessageParserWorker';
54-
$task = new PhabricatorWorkerTask();
55-
$task->setTaskClass($class);
56-
$task->setData(
57-
array(
58-
'commitID' => $commit->getID(),
59-
));
60-
$task->save();
6154
break;
6255
case PhabricatorRepositoryType::REPOSITORY_TYPE_SVN:
6356
$class = 'PhabricatorRepositorySvnCommitMessageParserWorker';
64-
$task = new PhabricatorWorkerTask();
65-
$task->setTaskClass($class);
66-
$task->setData(
67-
array(
68-
'commitID' => $commit->getID(),
69-
));
70-
$task->save();
57+
break;
58+
case PhabricatorRepositoryType::REPOSITORY_TYPE_MERCURIAL:
59+
$class = 'PhabricatorRepositoryMercurialCommitMessageParserWorker';
7160
break;
7261
default:
7362
throw new Exception("Unknown repository type.");
7463
}
7564

65+
$task = new PhabricatorWorkerTask();
66+
$task->setTaskClass($class);
67+
$task->setData(
68+
array(
69+
'commitID' => $commit->getID(),
70+
));
71+
$task->save();
72+
7673
$this->stillWorking();
7774
}
7875
sleep(1);
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
<?php
2+
3+
/*
4+
* Copyright 2011 Facebook, Inc.
5+
*
6+
* Licensed under the Apache License, Version 2.0 (the "License");
7+
* you may not use this file except in compliance with the License.
8+
* You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing, software
13+
* distributed under the License is distributed on an "AS IS" BASIS,
14+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
* See the License for the specific language governing permissions and
16+
* limitations under the License.
17+
*/
18+
19+
class PhabricatorRepositoryMercurialCommitMessageParserWorker
20+
extends PhabricatorRepositoryCommitMessageParserWorker {
21+
22+
public function parseCommit(
23+
PhabricatorRepository $repository,
24+
PhabricatorRepositoryCommit $commit) {
25+
26+
$local_path = $repository->getDetail('local-path');
27+
28+
list($stdout) = $repository->execxLocalCommand(
29+
'log --template %s --rev %s',
30+
'{author}\\n{desc}',
31+
$commit->getCommitIdentifier());
32+
33+
list($author, $message) = explode("\n", $stdout, 2);
34+
35+
$author = phutil_utf8ize($author);
36+
$message = phutil_utf8ize($message);
37+
$message = trim($message);
38+
39+
$this->updateCommitData($author, $message);
40+
41+
if ($this->shouldQueueFollowupTasks()) {
42+
$task = new PhabricatorWorkerTask();
43+
$task->setTaskClass(
44+
'PhabricatorRepositoryMercurialCommitChangeParserWorker');
45+
$task->setData(
46+
array(
47+
'commitID' => $commit->getID(),
48+
));
49+
$task->save();
50+
}
51+
}
52+
53+
}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
<?php
2+
/**
3+
* This file is automatically generated. Lint this module to rebuild it.
4+
* @generated
5+
*/
6+
7+
8+
9+
phutil_require_module('phabricator', 'applications/repository/worker/commitmessageparser/base');
10+
phutil_require_module('phabricator', 'infrastructure/daemon/workers/storage/task');
11+
12+
phutil_require_module('phutil', 'utils');
13+
14+
15+
phutil_require_source('PhabricatorRepositoryMercurialCommitMessageParserWorker.php');

0 commit comments

Comments
 (0)