From 99feb5c28e3cdcf61b9c99d9ff3e9924c2d507ee Mon Sep 17 00:00:00 2001 From: epriestley Date: Tue, 5 Feb 2013 20:11:20 -0800 Subject: [PATCH] Record commit email information from `arc` Summary: Record author email information in `arc diff`, so we can recreate it in `arc patch` and elsewhere without creating any kind of email exposure issues. In Mercurial, we currently store the whole string ("username "). Make this consistent with Git. Test Plan: Created git and hg diffs, saw authorEmail populated. Reviewers: btrahan, edward, vrana Reviewed By: btrahan CC: aran Differential Revision: https://secure.phabricator.com/D4825 --- src/repository/api/ArcanistGitAPI.php | 7 ++++--- src/repository/api/ArcanistMercurialAPI.php | 13 ++++++++----- 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/src/repository/api/ArcanistGitAPI.php b/src/repository/api/ArcanistGitAPI.php index 8fd29051..2420af5a 100644 --- a/src/repository/api/ArcanistGitAPI.php +++ b/src/repository/api/ArcanistGitAPI.php @@ -101,7 +101,7 @@ final class ArcanistGitAPI extends ArcanistRepositoryAPI { : 'log %C --format=%s --', $against, // NOTE: "%B" is somewhat new, use "%s%n%n%b" instead. - '%H%x01%T%x01%P%x01%at%x01%an%x01%s%x01%s%n%n%b%x02'); + '%H%x01%T%x01%P%x01%at%x01%an%x01%aE%x01%s%x01%s%n%n%b%x02'); $commits = array(); @@ -112,8 +112,8 @@ final class ArcanistGitAPI extends ArcanistRepositoryAPI { $info = explode("\2", $info); foreach ($info as $line) { - list($commit, $tree, $parents, $time, $author, $title, $message) - = explode("\1", trim($line), 7); + list($commit, $tree, $parents, $time, $author, $author_email, + $title, $message) = explode("\1", trim($line), 8); $message = rtrim($message); $commits[$commit] = array( @@ -124,6 +124,7 @@ final class ArcanistGitAPI extends ArcanistRepositoryAPI { 'author' => $author, 'summary' => $title, 'message' => $message, + 'authorEmail' => $author_email, ); } diff --git a/src/repository/api/ArcanistMercurialAPI.php b/src/repository/api/ArcanistMercurialAPI.php index 6ff488f8..9f80b2be 100644 --- a/src/repository/api/ArcanistMercurialAPI.php +++ b/src/repository/api/ArcanistMercurialAPI.php @@ -177,9 +177,11 @@ final class ArcanistMercurialAPI extends ArcanistRepositoryAPI { if ($this->localCommitInfo === null) { list($info) = $this->execxLocal( "log --template '%C' --rev %s --branch %s --", - "{node}\1{rev}\1{author}\1{date|rfc822date}\1". - "{branch}\1{tag}\1{parents}\1{desc}\2", - '(ancestors(.) - ancestors('.$this->getBaseCommit().'))', + "{node}\1{rev}\1{author|emailuser}\1{author|email}\1". + "{date|rfc822date}\1{branch}\1{tag}\1{parents}\1{desc}\2", + hgsprintf( + '(ancestors(.) - ancestors(%s))', + $this->getBaseCommit()), $this->getBranchName()); $logs = array_filter(explode("\2", $info)); @@ -189,8 +191,8 @@ final class ArcanistMercurialAPI extends ArcanistRepositoryAPI { $commits = array(); foreach ($logs as $log) { - list($node, $rev, $author, $date, $branch, $tag, $parents, $desc) = - explode("\1", $log); + list($node, $rev, $author, $author_email, $date, $branch, $tag, + $parents, $desc) = explode("\1", $log, 9); // NOTE: If a commit has only one parent, {parents} returns empty. // If it has two parents, {parents} returns revs and short hashes, not @@ -222,6 +224,7 @@ final class ArcanistMercurialAPI extends ArcanistRepositoryAPI { 'parents' => $commit_parents, 'summary' => head(explode("\n", $desc)), 'message' => $desc, + 'authorEmail' => $author_email, ); $last_node = $node;