Page MenuHomestyx hydra

No OneTemporary

diff --git a/src/applications/repository/worker/commitmessageparser/base/PhabricatorRepositoryCommitMessageParserWorker.php b/src/applications/repository/worker/commitmessageparser/base/PhabricatorRepositoryCommitMessageParserWorker.php
index 794a0d16b6..cb01c48b48 100644
--- a/src/applications/repository/worker/commitmessageparser/base/PhabricatorRepositoryCommitMessageParserWorker.php
+++ b/src/applications/repository/worker/commitmessageparser/base/PhabricatorRepositoryCommitMessageParserWorker.php
@@ -1,71 +1,109 @@
<?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.
*/
abstract class PhabricatorRepositoryCommitMessageParserWorker
extends PhabricatorRepositoryCommitParserWorker {
+ abstract protected function getCommitHashes(
+ PhabricatorRepository $repository,
+ PhabricatorRepositoryCommit $commit);
+
final protected function updateCommitData($author, $message) {
$commit = $this->commit;
$data = id(new PhabricatorRepositoryCommitData())->loadOneWhere(
'commitID = %d',
$commit->getID());
if (!$data) {
$data = new PhabricatorRepositoryCommitData();
}
$data->setCommitID($commit->getID());
$data->setAuthorName($author);
$data->setCommitMessage($message);
$repository = $this->repository;
$detail_parser = $repository->getDetail(
'detail-parser',
'PhabricatorRepositoryDefaultCommitMessageDetailParser');
if ($detail_parser) {
PhutilSymbolLoader::loadClass($detail_parser);
$parser_obj = newv($detail_parser, array($commit, $data));
$parser_obj->parseCommitDetails();
}
$data->save();
+ $conn_w = id(new DifferentialRevision())->establishConnection('w');
+
+ // NOTE: The `differential_commit` table has a unique ID on `commitPHID`,
+ // preventing more than one revision from being associated with a commit.
+ // Generally this is good and desirable, but with the advent of hash
+ // tracking we may end up in a situation where we match several different
+ // revisions. We just kind of ignore this and pick one, we might want to
+ // revisit this and do something differently. (If we match several revisions
+ // someone probably did something very silly, though.)
+
$revision_id = $data->getCommitDetail('differential.revisionID');
+ if (!$revision_id) {
+ $hashes = $this->getCommitHashes(
+ $this->repository,
+ $this->commit);
+ if ($hashes) {
+ $sql = array();
+ foreach ($hashes as $info) {
+ list($type, $hash) = $info;
+ $sql[] = qsprintf(
+ $conn_w,
+ '(type = %s AND hash = %s)',
+ $type,
+ $hash);
+ }
+ $revision = queryfx_one(
+ $conn_w,
+ 'SELECT revisionID FROM %T WHERE %Q LIMIT 1',
+ DifferentialRevisionHash::TABLE_NAME,
+ implode(' OR ', $sql));
+ if ($revision) {
+ $revision_id = $revision['revisionID'];
+ }
+ }
+ }
+
if ($revision_id) {
$revision = id(new DifferentialRevision())->load($revision_id);
if ($revision) {
-
queryfx(
- $revision->establishConnection('w'),
+ $conn_w,
'INSERT IGNORE INTO %T (revisionID, commitPHID) VALUES (%d, %s)',
DifferentialRevision::TABLE_COMMIT,
$revision->getID(),
$commit->getPHID());
if ($revision->getStatus() != DifferentialRevisionStatus::COMMITTED) {
$editor = new DifferentialCommentEditor(
$revision,
$revision->getAuthorPHID(),
DifferentialAction::ACTION_COMMIT);
$editor->save();
}
}
}
}
}
diff --git a/src/applications/repository/worker/commitmessageparser/base/__init__.php b/src/applications/repository/worker/commitmessageparser/base/__init__.php
index 2646add245..59dcb12de3 100644
--- a/src/applications/repository/worker/commitmessageparser/base/__init__.php
+++ b/src/applications/repository/worker/commitmessageparser/base/__init__.php
@@ -1,21 +1,23 @@
<?php
/**
* This file is automatically generated. Lint this module to rebuild it.
* @generated
*/
phutil_require_module('phabricator', 'applications/differential/constants/action');
+phutil_require_module('phabricator', 'applications/differential/constants/revisionhash');
phutil_require_module('phabricator', 'applications/differential/constants/revisionstatus');
phutil_require_module('phabricator', 'applications/differential/editor/comment');
phutil_require_module('phabricator', 'applications/differential/storage/revision');
phutil_require_module('phabricator', 'applications/repository/storage/commitdata');
phutil_require_module('phabricator', 'applications/repository/worker/base');
+phutil_require_module('phabricator', 'storage/qsprintf');
phutil_require_module('phabricator', 'storage/queryfx');
phutil_require_module('phutil', 'symbols');
phutil_require_module('phutil', 'utils');
phutil_require_source('PhabricatorRepositoryCommitMessageParserWorker.php');
diff --git a/src/applications/repository/worker/commitmessageparser/git/PhabricatorRepositoryGitCommitMessageParserWorker.php b/src/applications/repository/worker/commitmessageparser/git/PhabricatorRepositoryGitCommitMessageParserWorker.php
index 89cec4fc84..420c80f0bf 100644
--- a/src/applications/repository/worker/commitmessageparser/git/PhabricatorRepositoryGitCommitMessageParserWorker.php
+++ b/src/applications/repository/worker/commitmessageparser/git/PhabricatorRepositoryGitCommitMessageParserWorker.php
@@ -1,55 +1,70 @@
<?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 PhabricatorRepositoryGitCommitMessageParserWorker
extends PhabricatorRepositoryCommitMessageParserWorker {
public function parseCommit(
PhabricatorRepository $repository,
PhabricatorRepositoryCommit $commit) {
- $local_path = $repository->getDetail('local-path');
-
// NOTE: %B was introduced somewhat recently in git's history, so pull
// commit message information with %s and %b instead.
- list($info) = execx(
- '(cd %s && git log -n 1 --pretty=format:%%an%%x00%%s%%n%%n%%b %s)',
- $local_path,
+ list($info) = $repository->execxLocalCommand(
+ 'log -n 1 --pretty=format:%%an%%x00%%s%%n%%n%%b %s',
$commit->getCommitIdentifier());
list($author, $message) = explode("\0", $info);
// Make sure these are valid UTF-8.
$author = phutil_utf8ize($author);
$message = phutil_utf8ize($message);
$message = trim($message);
$this->updateCommitData($author, $message);
if ($this->shouldQueueFollowupTasks()) {
$task = new PhabricatorWorkerTask();
$task->setTaskClass('PhabricatorRepositoryGitCommitChangeParserWorker');
$task->setData(
array(
'commitID' => $commit->getID(),
));
$task->save();
}
}
+ protected function getCommitHashes(
+ PhabricatorRepository $repository,
+ PhabricatorRepositoryCommit $commit) {
+
+ list($stdout) = $repository->execxLocalCommand(
+ 'log -n 1 --format=%s %s --',
+ '%T',
+ $commit->getCommitIdentifier());
+
+ $commit_hash = $commit->getCommitIdentifier();
+ $tree_hash = trim($stdout);
+
+ return array(
+ array(DifferentialRevisionHash::HASH_GIT_COMMIT, $commit_hash),
+ array(DifferentialRevisionHash::HASH_GIT_TREE, $tree_hash),
+ );
+ }
+
}
diff --git a/src/applications/repository/worker/commitmessageparser/git/__init__.php b/src/applications/repository/worker/commitmessageparser/git/__init__.php
index 4f42580c9c..cbe011c05f 100644
--- a/src/applications/repository/worker/commitmessageparser/git/__init__.php
+++ b/src/applications/repository/worker/commitmessageparser/git/__init__.php
@@ -1,16 +1,16 @@
<?php
/**
* This file is automatically generated. Lint this module to rebuild it.
* @generated
*/
+phutil_require_module('phabricator', 'applications/differential/constants/revisionhash');
phutil_require_module('phabricator', 'applications/repository/worker/commitmessageparser/base');
phutil_require_module('phabricator', 'infrastructure/daemon/workers/storage/task');
-phutil_require_module('phutil', 'future/exec');
phutil_require_module('phutil', 'utils');
phutil_require_source('PhabricatorRepositoryGitCommitMessageParserWorker.php');
diff --git a/src/applications/repository/worker/commitmessageparser/mercurial/PhabricatorRepositoryMercurialCommitMessageParserWorker.php b/src/applications/repository/worker/commitmessageparser/mercurial/PhabricatorRepositoryMercurialCommitMessageParserWorker.php
index 70bc86d8ca..8447c068e0 100644
--- a/src/applications/repository/worker/commitmessageparser/mercurial/PhabricatorRepositoryMercurialCommitMessageParserWorker.php
+++ b/src/applications/repository/worker/commitmessageparser/mercurial/PhabricatorRepositoryMercurialCommitMessageParserWorker.php
@@ -1,53 +1,62 @@
<?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();
}
}
+ protected function getCommitHashes(
+ PhabricatorRepository $repository,
+ PhabricatorRepositoryCommit $commit) {
+
+ $commit_hash = $commit->getCommitIdentifier();
+
+ return array(
+ array(DifferentialRevisionHash::HASH_MERCURIAL_COMMIT, $commit_hash),
+ );
+ }
+
}
diff --git a/src/applications/repository/worker/commitmessageparser/mercurial/__init__.php b/src/applications/repository/worker/commitmessageparser/mercurial/__init__.php
index 1f22433b1c..a0bdf0a813 100644
--- a/src/applications/repository/worker/commitmessageparser/mercurial/__init__.php
+++ b/src/applications/repository/worker/commitmessageparser/mercurial/__init__.php
@@ -1,15 +1,16 @@
<?php
/**
* This file is automatically generated. Lint this module to rebuild it.
* @generated
*/
+phutil_require_module('phabricator', 'applications/differential/constants/revisionhash');
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');
diff --git a/src/applications/repository/worker/commitmessageparser/svn/PhabricatorRepositorySvnCommitMessageParserWorker.php b/src/applications/repository/worker/commitmessageparser/svn/PhabricatorRepositorySvnCommitMessageParserWorker.php
index c8c8d95478..c27c848016 100644
--- a/src/applications/repository/worker/commitmessageparser/svn/PhabricatorRepositorySvnCommitMessageParserWorker.php
+++ b/src/applications/repository/worker/commitmessageparser/svn/PhabricatorRepositorySvnCommitMessageParserWorker.php
@@ -1,51 +1,58 @@
<?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 PhabricatorRepositorySvnCommitMessageParserWorker
extends PhabricatorRepositoryCommitMessageParserWorker {
public function parseCommit(
PhabricatorRepository $repository,
PhabricatorRepositoryCommit $commit) {
$uri = $repository->getDetail('remote-uri');
$log = $this->getSVNLogXMLObject(
$uri,
$commit->getCommitIdentifier(),
$verbose = false);
$entry = $log->logentry[0];
$author = (string)$entry->author;
$message = (string)$entry->msg;
$this->updateCommitData($author, $message);
if ($this->shouldQueueFollowupTasks()) {
$task = new PhabricatorWorkerTask();
$task->setTaskClass('PhabricatorRepositorySvnCommitChangeParserWorker');
$task->setData(
array(
'commitID' => $commit->getID(),
));
$task->save();
}
}
+ protected function getCommitHashes(
+ PhabricatorRepository $repository,
+ PhabricatorRepositoryCommit $commit) {
+ return array();
+ }
+
+
}

File Metadata

Mime Type
text/x-diff
Expires
Tue, Jun 10, 12:32 AM (13 h, 19 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
140175
Default Alt Text
(14 KB)

Event Timeline