Page MenuHomePhabricator

D7804.diff
No OneTemporary

D7804.diff

Index: src/__phutil_library_map__.php
===================================================================
--- src/__phutil_library_map__.php
+++ src/__phutil_library_map__.php
@@ -478,6 +478,7 @@
'DiffusionCommitChangeTableView' => 'applications/diffusion/view/DiffusionCommitChangeTableView.php',
'DiffusionCommitController' => 'applications/diffusion/controller/DiffusionCommitController.php',
'DiffusionCommitEditController' => 'applications/diffusion/controller/DiffusionCommitEditController.php',
+ 'DiffusionCommitHash' => 'applications/diffusion/data/DiffusionCommitHash.php',
'DiffusionCommitHookEngine' => 'applications/diffusion/engine/DiffusionCommitHookEngine.php',
'DiffusionCommitHookRejectException' => 'applications/diffusion/exception/DiffusionCommitHookRejectException.php',
'DiffusionCommitParentsQuery' => 'applications/diffusion/query/parents/DiffusionCommitParentsQuery.php',
@@ -2866,6 +2867,7 @@
'DiffusionCommitChangeTableView' => 'DiffusionView',
'DiffusionCommitController' => 'DiffusionController',
'DiffusionCommitEditController' => 'DiffusionController',
+ 'DiffusionCommitHash' => 'Phobject',
'DiffusionCommitHookEngine' => 'Phobject',
'DiffusionCommitHookRejectException' => 'Exception',
'DiffusionCommitParentsQuery' => 'DiffusionQuery',
Index: src/applications/diffusion/data/DiffusionCommitHash.php
===================================================================
--- /dev/null
+++ src/applications/diffusion/data/DiffusionCommitHash.php
@@ -0,0 +1,26 @@
+<?php
+
+final class DiffusionCommitHash extends Phobject {
+
+ private $hashType;
+ private $hashValue;
+
+ public function setHashValue($hash_value) {
+ $this->hashValue = $hash_value;
+ return $this;
+ }
+
+ public function getHashValue() {
+ return $this->hashValue;
+ }
+
+ public function setHashType($hash_type) {
+ $this->hashType = $hash_type;
+ return $this;
+ }
+
+ public function getHashType() {
+ return $this->hashType;
+ }
+
+}
Index: src/applications/diffusion/data/DiffusionCommitRef.php
===================================================================
--- src/applications/diffusion/data/DiffusionCommitRef.php
+++ src/applications/diffusion/data/DiffusionCommitRef.php
@@ -7,6 +7,16 @@
private $authorEmail;
private $committerName;
private $committerEmail;
+ private $hashes = array();
+
+ public function setHashes(array $hashes) {
+ $this->hashes = $hashes;
+ return $this;
+ }
+
+ public function getHashes() {
+ return $this->hashes;
+ }
public function setCommitterEmail($committer_email) {
$this->committerEmail = $committer_email;
Index: src/applications/diffusion/query/lowlevel/DiffusionLowLevelCommitQuery.php
===================================================================
--- src/applications/diffusion/query/lowlevel/DiffusionLowLevelCommitQuery.php
+++ src/applications/diffusion/query/lowlevel/DiffusionLowLevelCommitQuery.php
@@ -51,7 +51,9 @@
list($info) = $repository->execxLocalCommand(
'log -n 1 --encoding=%s --format=%s %s --',
'UTF-8',
- implode('%x00', array('%e', '%cn', '%ce', '%an', '%ae', '%s%n%n%b')),
+ implode(
+ '%x00',
+ array('%e', '%cn', '%ce', '%an', '%ae', '%T', '%s%n%n%b')),
$this->identifier);
$parts = explode("\0", $info);
@@ -67,12 +69,22 @@
}
}
+ $hashes = array(
+ id(new DiffusionCommitHash())
+ ->setHashType(ArcanistDifferentialRevisionHash::HASH_GIT_COMMIT)
+ ->setHashValue($this->identifier),
+ id(new DiffusionCommitHash())
+ ->setHashType(ArcanistDifferentialRevisionHash::HASH_GIT_TREE)
+ ->setHashValue($parts[4]),
+ );
+
return id(new DiffusionCommitRef())
->setCommitterName($parts[0])
->setCommitterEmail($parts[1])
->setAuthorName($parts[2])
->setAuthorEmail($parts[3])
- ->setMessage($parts[4]);
+ ->setHashes($hashes)
+ ->setMessage($parts[5]);
}
private function loadMercurialCommitRef() {
@@ -90,10 +102,17 @@
list($author_name, $author_email) = $this->splitUserIdentifier($author);
+ $hashes = array(
+ id(new DiffusionCommitHash())
+ ->setHashType(ArcanistDifferentialRevisionHash::HASH_MERCURIAL_COMMIT)
+ ->setHashValue($this->identifier),
+ );
+
return id(new DiffusionCommitRef())
->setAuthorName($author_name)
->setAuthorEmail($author_email)
- ->setMessage($message);
+ ->setMessage($message)
+ ->setHashes($hashes);
}
private function loadSubversionCommitRef() {
@@ -114,10 +133,14 @@
list($author_name, $author_email) = $this->splitUserIdentifier($author);
+ // No hashes in Subversion.
+ $hashes = array();
+
return id(new DiffusionCommitRef())
->setAuthorName($author_name)
->setAuthorEmail($author_email)
- ->setMessage($message);
+ ->setMessage($message)
+ ->setHashes($hashes);
}
private function splitUserIdentifier($user) {
Index: src/applications/repository/worker/commitmessageparser/PhabricatorRepositoryCommitMessageParserWorker.php
===================================================================
--- src/applications/repository/worker/commitmessageparser/PhabricatorRepositoryCommitMessageParserWorker.php
+++ src/applications/repository/worker/commitmessageparser/PhabricatorRepositoryCommitMessageParserWorker.php
@@ -3,14 +3,12 @@
abstract class PhabricatorRepositoryCommitMessageParserWorker
extends PhabricatorRepositoryCommitParserWorker {
- abstract protected function getCommitHashes(
- PhabricatorRepository $repository,
- PhabricatorRepositoryCommit $commit);
-
- final protected function updateCommitData($author, $message,
- $committer = null) {
-
+ final protected function updateCommitData(DiffusionCommitRef $ref) {
$commit = $this->commit;
+ $author = $ref->getAuthor();
+ $message = $ref->getMessage();
+ $committer = $ref->getCommitter();
+ $hashes = $ref->getHashes();
$data = id(new PhabricatorRepositoryCommitData())->loadOneWhere(
'commitID = %d',
@@ -26,7 +24,7 @@
$data->setCommitMessage($message);
- if ($committer) {
+ if (strlen($committer)) {
$data->setCommitDetail('committer', $committer);
$data->setCommitDetail(
'committerPHID',
@@ -63,20 +61,19 @@
}
$revision_id = idx($field_values, 'revisionID');
- if (!$revision_id) {
- $hashes = $this->getCommitHashes(
- $repository,
- $commit);
- if ($hashes) {
- $revisions = id(new DifferentialRevisionQuery())
- ->setViewer(PhabricatorUser::getOmnipotentUser())
- ->withCommitHashes($hashes)
- ->execute();
+ if (!$revision_id && $hashes) {
+ $hash_list = array();
+ foreach ($hashes as $hash) {
+ $hash_list[] = array($hash->getHashType(), $hash->getHashValue());
+ }
+ $revisions = id(new DifferentialRevisionQuery())
+ ->setViewer(PhabricatorUser::getOmnipotentUser())
+ ->withCommitHashes($hash_list)
+ ->execute();
- if (!empty($revisions)) {
- $revision = $this->identifyBestRevision($revisions);
- $revision_id = $revision->getID();
- }
+ if (!empty($revisions)) {
+ $revision = $this->identifyBestRevision($revisions);
+ $revision_id = $revision->getID();
}
}
Index: src/applications/repository/worker/commitmessageparser/PhabricatorRepositoryGitCommitMessageParserWorker.php
===================================================================
--- src/applications/repository/worker/commitmessageparser/PhabricatorRepositoryGitCommitMessageParserWorker.php
+++ src/applications/repository/worker/commitmessageparser/PhabricatorRepositoryGitCommitMessageParserWorker.php
@@ -12,15 +12,7 @@
->withIdentifier($commit->getCommitIdentifier())
->execute();
- $committer = $ref->getCommitter();
- $author = $ref->getAuthor();
- $message = $ref->getMessage();
-
- if ($committer == $author) {
- $committer = null;
- }
-
- $this->updateCommitData($author, $message, $committer);
+ $this->updateCommitData($ref);
if ($this->shouldQueueFollowupTasks()) {
PhabricatorWorker::scheduleTask(
@@ -31,24 +23,4 @@
}
}
- 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(ArcanistDifferentialRevisionHash::HASH_GIT_COMMIT,
- $commit_hash),
- array(ArcanistDifferentialRevisionHash::HASH_GIT_TREE,
- $tree_hash),
- );
- }
-
}
Index: src/applications/repository/worker/commitmessageparser/PhabricatorRepositoryMercurialCommitMessageParserWorker.php
===================================================================
--- src/applications/repository/worker/commitmessageparser/PhabricatorRepositoryMercurialCommitMessageParserWorker.php
+++ src/applications/repository/worker/commitmessageparser/PhabricatorRepositoryMercurialCommitMessageParserWorker.php
@@ -12,10 +12,7 @@
->withIdentifier($commit->getCommitIdentifier())
->execute();
- $author = $ref->getAuthor();
- $message = $ref->getMessage();
-
- $this->updateCommitData($author, $message);
+ $this->updateCommitData($ref);
if ($this->shouldQueueFollowupTasks()) {
PhabricatorWorker::scheduleTask(
@@ -26,16 +23,4 @@
}
}
- protected function getCommitHashes(
- PhabricatorRepository $repository,
- PhabricatorRepositoryCommit $commit) {
-
- $commit_hash = $commit->getCommitIdentifier();
-
- return array(
- array(ArcanistDifferentialRevisionHash::HASH_MERCURIAL_COMMIT,
- $commit_hash),
- );
- }
-
}
Index: src/applications/repository/worker/commitmessageparser/PhabricatorRepositorySvnCommitMessageParserWorker.php
===================================================================
--- src/applications/repository/worker/commitmessageparser/PhabricatorRepositorySvnCommitMessageParserWorker.php
+++ src/applications/repository/worker/commitmessageparser/PhabricatorRepositorySvnCommitMessageParserWorker.php
@@ -12,10 +12,7 @@
->withIdentifier($commit->getCommitIdentifier())
->execute();
- $author = $ref->getAuthor();
- $message = $ref->getMessage();
-
- $this->updateCommitData($author, $message);
+ $this->updateCommitData($ref);
if ($this->shouldQueueFollowupTasks()) {
PhabricatorWorker::scheduleTask(
@@ -26,10 +23,4 @@
}
}
- protected function getCommitHashes(
- PhabricatorRepository $repository,
- PhabricatorRepositoryCommit $commit) {
- return array();
- }
-
}

File Metadata

Mime Type
text/plain
Expires
Oct 17 2024, 7:16 AM (4 w, 6 d ago)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
6721112
Default Alt Text
D7804.diff (10 KB)

Event Timeline