1
0
Fork 0
mirror of https://we.phorge.it/source/arcanist.git synced 2024-11-25 16:22:42 +01:00

Refactor author handling in the Mercurial API

Summary: There were two callsites which needed some information from the username. Only one worked "correctly", causing `arc diff` to not amend commits anymore because the author could not be parser.

Test Plan: run `arc diff` with changes

Reviewers: #blessed_reviewers, epriestley

Reviewed By: #blessed_reviewers, epriestley

Subscribers: epriestley, Korvin

Differential Revision: https://secure.phabricator.com/D9797
This commit is contained in:
Richard van Velzen 2014-07-02 13:59:13 -07:00 committed by epriestley
parent ca5f05e62b
commit 792204db95

View file

@ -247,16 +247,7 @@ final class ArcanistMercurialAPI extends ArcanistRepositoryAPI {
list($node, $rev, $full_author, $date, $branch, $tag,
$parents, $desc) = explode("\1", $log, 9);
// Not everyone enters their email address as a part of the username
// field. Try to make it work when it's obvious
if (strpos($full_author, '@') === false) {
$author = $full_author;
$author_email = null;
} else {
$email = new PhutilEmailAddress($full_author);
$author = $email->getDisplayName();
$author_email = $email->getAddress();
}
list ($author, $author_email) = $this->parseFullAuthor($full_author);
// NOTE: If a commit has only one parent, {parents} returns empty.
// If it has two parents, {parents} returns revs and short hashes, not
@ -735,11 +726,32 @@ final class ArcanistMercurialAPI extends ArcanistRepositoryAPI {
public function getAuthor() {
$full_author = $this->getMercurialConfig('ui.username');
$email = new PhutilEmailAddress($full_author);
$author = $email->getDisplayName();
list($author, $author_email) = $this->parseFullAuthor($full_author);
return $author;
}
/**
* Parse the Mercurial author field
*
* Not everyone enters their email address as a part of the username
* field. Try to make it work when it's obvious
*
* @param string $full_author
* @return array
*/
protected function parseFullAuthor($full_author) {
if (strpos($full_author, '@') === false) {
$author = $full_author;
$author_email = null;
} else {
$email = new PhutilEmailAddress($full_author);
$author = $email->getDisplayName();
$author_email = $email->getAddress();
}
return array($author, $author_email);
}
public function addToCommit(array $paths) {
$this->execxLocal(
'addremove -- %Ls',