Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F14016199
D7795.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
5 KB
Referenced Files
None
Subscribers
None
D7795.diff
View Options
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
Details
Attached
Mime Type
text/plain
Expires
Tue, Nov 5, 7:07 AM (1 w, 19 h ago)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
6713708
Default Alt Text
D7795.diff (5 KB)
Attached To
Mode
D7795: Move mercurial commit metadata parsing into a LowLevel query
Attached
Detach File
Event Timeline
Log In to Comment