Page MenuHomePhabricator

D7795.id17646.diff
No OneTemporary

D7795.id17646.diff

Index: src/__phutil_library_map__.php
===================================================================
--- src/__phutil_library_map__.php
+++ src/__phutil_library_map__.php
@@ -510,6 +510,7 @@
'DiffusionLowLevelGitCommitQuery' => 'applications/diffusion/query/lowlevel/DiffusionLowLevelGitCommitQuery.php',
'DiffusionLowLevelGitRefQuery' => 'applications/diffusion/query/lowlevel/DiffusionLowLevelGitRefQuery.php',
'DiffusionLowLevelMercurialBranchesQuery' => 'applications/diffusion/query/lowlevel/DiffusionLowLevelMercurialBranchesQuery.php',
+ 'DiffusionLowLevelMercurialCommitQuery' => 'applications/diffusion/query/lowlevel/DiffusionLowLevelMercurialCommitQuery.php',
'DiffusionLowLevelQuery' => 'applications/diffusion/query/lowlevel/DiffusionLowLevelQuery.php',
'DiffusionLowLevelResolveRefsQuery' => 'applications/diffusion/query/lowlevel/DiffusionLowLevelResolveRefsQuery.php',
'DiffusionMercurialCommitParentsQuery' => 'applications/diffusion/query/parents/DiffusionMercurialCommitParentsQuery.php',
@@ -2893,6 +2894,7 @@
'DiffusionLowLevelGitCommitQuery' => 'DiffusionLowLevelQuery',
'DiffusionLowLevelGitRefQuery' => 'DiffusionLowLevelQuery',
'DiffusionLowLevelMercurialBranchesQuery' => 'DiffusionLowLevelQuery',
+ 'DiffusionLowLevelMercurialCommitQuery' => 'DiffusionLowLevelQuery',
'DiffusionLowLevelQuery' => 'Phobject',
'DiffusionLowLevelResolveRefsQuery' => 'DiffusionLowLevelQuery',
'DiffusionMercurialCommitParentsQuery' => 'DiffusionCommitParentsQuery',
Index: src/applications/diffusion/data/DiffusionCommitRef.php
===================================================================
--- src/applications/diffusion/data/DiffusionCommitRef.php
+++ src/applications/diffusion/data/DiffusionCommitRef.php
@@ -56,4 +56,24 @@
return $this->message;
}
+ public function getAuthor() {
+ return $this->formatUser($this->authorName, $this->authorEmail);
+ }
+
+ public function getCommitter() {
+ return $this->formatUser($this->committerName, $this->committerEmail);
+ }
+
+ private function formatUser($name, $email) {
+ if (strlen($name) && strlen($email)) {
+ return "{$name} <{$email}>";
+ } else if (strlen($email)) {
+ return $email;
+ } else if (strlen($name)) {
+ return $name;
+ } else {
+ return null;
+ }
+ }
+
}
Index: src/applications/diffusion/query/lowlevel/DiffusionLowLevelMercurialCommitQuery.php
===================================================================
--- /dev/null
+++ src/applications/diffusion/query/lowlevel/DiffusionLowLevelMercurialCommitQuery.php
@@ -0,0 +1,41 @@
+<?php
+
+final class DiffusionLowLevelMercurialCommitQuery
+ extends DiffusionLowLevelQuery {
+
+ private $identifier;
+
+ public function withIdentifier($identifier) {
+ $this->identifier = $identifier;
+ return $this;
+ }
+
+ protected function executeQuery() {
+ $repository = $this->getRepository();
+
+ list($stdout) = $repository->execxLocalCommand(
+ 'log --template %s --rev %s',
+ '{author}\\n{desc}',
+ hgsprintf('%s', $this->identifier));
+
+ list($author, $message) = explode("\n", $stdout, 2);
+
+ $author = phutil_utf8ize($author);
+ $message = phutil_utf8ize($message);
+
+ $email = new PhutilEmailAddress($author);
+ if ($email->getDisplayName() || $email->getDomainName()) {
+ $author_name = $email->getDisplayName();
+ $author_email = $email->getAddress();
+ } else {
+ $author_name = $email->getAddress();
+ $author_email = null;
+ }
+
+ return id(new DiffusionCommitRef())
+ ->setAuthorName($author_name)
+ ->setAuthorEmail($author_email)
+ ->setMessage($message);
+ }
+
+}
Index: src/applications/repository/worker/commitmessageparser/PhabricatorRepositoryGitCommitMessageParserWorker.php
===================================================================
--- src/applications/repository/worker/commitmessageparser/PhabricatorRepositoryGitCommitMessageParserWorker.php
+++ src/applications/repository/worker/commitmessageparser/PhabricatorRepositoryGitCommitMessageParserWorker.php
@@ -12,23 +12,9 @@
->withIdentifier($commit->getCommitIdentifier())
->execute();
- $committer_name = $ref->getCommitterName();
- $committer_email = $ref->getCommitterEmail();
- $author_name = $ref->getAuthorName();
- $author_email = $ref->getAuthorEmail();
- $message = $ref->getMessage();
-
- if (strlen($author_email)) {
- $author = "{$author_name} <{$author_email}>";
- } else {
- $author = "{$author_name}";
- }
-
- if (strlen($committer_email)) {
- $committer = "{$committer_name} <{$committer_email}>";
- } else {
- $committer = "{$committer_name}";
- }
+ $committer = $ref->getCommitter();
+ $author = $ref->getAuthor();
+ $message = $ref->getMessage();
if ($committer == $author) {
$committer = null;
Index: src/applications/repository/worker/commitmessageparser/PhabricatorRepositoryMercurialCommitMessageParserWorker.php
===================================================================
--- src/applications/repository/worker/commitmessageparser/PhabricatorRepositoryMercurialCommitMessageParserWorker.php
+++ src/applications/repository/worker/commitmessageparser/PhabricatorRepositoryMercurialCommitMessageParserWorker.php
@@ -7,16 +7,13 @@
PhabricatorRepository $repository,
PhabricatorRepositoryCommit $commit) {
- list($stdout) = $repository->execxLocalCommand(
- 'log --template %s --rev %s',
- '{author}\\n{desc}',
- $commit->getCommitIdentifier());
+ $ref = id(new DiffusionLowLevelMercurialCommitQuery())
+ ->setRepository($repository)
+ ->withIdentifier($commit->getCommitIdentifier())
+ ->execute();
- list($author, $message) = explode("\n", $stdout, 2);
-
- $author = phutil_utf8ize($author);
- $message = phutil_utf8ize($message);
- $message = trim($message);
+ $author = $ref->getAuthor();
+ $message = $ref->getMessage();
$this->updateCommitData($author, $message);

File Metadata

Mime Type
text/plain
Expires
Tue, Oct 15, 8:47 PM (4 w, 5 h ago)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
6713708
Default Alt Text
D7795.id17646.diff (5 KB)

Event Timeline