diff --git a/src/applications/diffusion/edge/DiffusionCommitRevertedByCommitEdgeType.php b/src/applications/diffusion/edge/DiffusionCommitRevertedByCommitEdgeType.php index c0502478bf..923c602e57 100644 --- a/src/applications/diffusion/edge/DiffusionCommitRevertedByCommitEdgeType.php +++ b/src/applications/diffusion/edge/DiffusionCommitRevertedByCommitEdgeType.php @@ -13,4 +13,92 @@ final class DiffusionCommitRevertedByCommitEdgeType return true; } + public function getTransactionAddString( + $actor, + $add_count, + $add_edges) { + + return pht( + '%s added %s reverted commit(s): %s.', + $actor, + $add_count, + $add_edges); + } + + public function getTransactionRemoveString( + $actor, + $rem_count, + $rem_edges) { + + return pht( + '%s removed %s reverted commit(s): %s.', + $actor, + $rem_count, + $rem_edges); + } + + public function getTransactionEditString( + $actor, + $total_count, + $add_count, + $add_edges, + $rem_count, + $rem_edges) { + + return pht( + '%s edited reverted commit(s), added %s: %s; removed %s: %s.', + $actor, + $add_count, + $add_edges, + $rem_count, + $rem_edges); + } + + public function getFeedAddString( + $actor, + $object, + $add_count, + $add_edges) { + + return pht( + '%s added %s reverted commit(s) for %s: %s.', + $actor, + $add_count, + $object, + $add_edges); + } + + public function getFeedRemoveString( + $actor, + $object, + $rem_count, + $rem_edges) { + + return pht( + '%s removed %s reverted commit(s) for %s: %s.', + $actor, + $rem_count, + $object, + $rem_edges); + } + + public function getFeedEditString( + $actor, + $object, + $total_count, + $add_count, + $add_edges, + $rem_count, + $rem_edges) { + + return pht( + '%s edited reverted commit(s) for %s, added %s: %s; removed %s: %s.', + $actor, + $object, + $add_count, + $add_edges, + $rem_count, + $rem_edges); + } + } diff --git a/src/applications/diffusion/edge/DiffusionCommitRevertsCommitEdgeType.php b/src/applications/diffusion/edge/DiffusionCommitRevertsCommitEdgeType.php index cf878f59f3..2984d2f526 100644 --- a/src/applications/diffusion/edge/DiffusionCommitRevertsCommitEdgeType.php +++ b/src/applications/diffusion/edge/DiffusionCommitRevertsCommitEdgeType.php @@ -16,4 +16,92 @@ final class DiffusionCommitRevertsCommitEdgeType extends PhabricatorEdgeType { return true; } + public function getTransactionAddString( + $actor, + $add_count, + $add_edges) { + + return pht( + '%s added %s reverting commit(s): %s.', + $actor, + $add_count, + $add_edges); + } + + public function getTransactionRemoveString( + $actor, + $rem_count, + $rem_edges) { + + return pht( + '%s removed %s reverting commit(s): %s.', + $actor, + $rem_count, + $rem_edges); + } + + public function getTransactionEditString( + $actor, + $total_count, + $add_count, + $add_edges, + $rem_count, + $rem_edges) { + + return pht( + '%s edited reverting commit(s), added %s: %s; removed %s: %s.', + $actor, + $add_count, + $add_edges, + $rem_count, + $rem_edges); + } + + public function getFeedAddString( + $actor, + $object, + $add_count, + $add_edges) { + + return pht( + '%s added %s reverting commit(s) for %s: %s.', + $actor, + $add_count, + $object, + $add_edges); + } + + public function getFeedRemoveString( + $actor, + $object, + $rem_count, + $rem_edges) { + + return pht( + '%s removed %s reverting commit(s) for %s: %s.', + $actor, + $rem_count, + $object, + $rem_edges); + } + + public function getFeedEditString( + $actor, + $object, + $total_count, + $add_count, + $add_edges, + $rem_count, + $rem_edges) { + + return pht( + '%s edited reverting commit(s) for %s, added %s: %s; removed %s: %s.', + $actor, + $object, + $add_count, + $add_edges, + $rem_count, + $rem_edges); + } + } diff --git a/src/applications/repository/worker/PhabricatorRepositoryCommitHeraldWorker.php b/src/applications/repository/worker/PhabricatorRepositoryCommitHeraldWorker.php index c7af5215dd..9d34cb3371 100644 --- a/src/applications/repository/worker/PhabricatorRepositoryCommitHeraldWorker.php +++ b/src/applications/repository/worker/PhabricatorRepositoryCommitHeraldWorker.php @@ -59,12 +59,36 @@ final class PhabricatorRepositoryCommitHeraldWorker 'committerName' => $data->getCommitDetail('committer'), 'committerPHID' => $data->getCommitDetail('committerPHID'), )); + + $reverts_refs = id(new DifferentialCustomFieldRevertsParser()) + ->parseCorpus($data->getCommitMessage()); + $reverts = array_mergev(ipull($reverts_refs, 'monograms')); + + if ($reverts) { + $reverted_commits = id(new DiffusionCommitQuery()) + ->setViewer(PhabricatorUser::getOmnipotentUser()) + ->withIdentifiers($reverts) + ->execute(); + $reverted_commit_phids = mpull($reverted_commits, 'getPHID', 'getPHID'); + + // NOTE: Skip any write attempts if a user cleverly implies a commit + // reverts itself. + unset($reverted_commit_phids[$commit->getPHID()]); + + $reverts_edge = DiffusionCommitRevertsCommitEdgeType::EDGECONST; + $xactions[] = id(new PhabricatorAuditTransaction()) + ->setTransactionType(PhabricatorTransactions::TYPE_EDGE) + ->setMetadataValue('edge:type', $reverts_edge) + ->setNewValue(array('+' => array_fuse($reverted_commit_phids))); + } + try { $raw_patch = $this->loadRawPatchText($repository, $commit); } catch (Exception $ex) { $raw_patch = pht('Unable to generate patch: %s', $ex->getMessage()); } $editor->setRawPatch($raw_patch); + return $editor->applyTransactions($commit, $xactions); } diff --git a/src/applications/repository/worker/commitmessageparser/PhabricatorRepositoryCommitMessageParserWorker.php b/src/applications/repository/worker/commitmessageparser/PhabricatorRepositoryCommitMessageParserWorker.php index 39ed2b5711..57bed93f25 100644 --- a/src/applications/repository/worker/commitmessageparser/PhabricatorRepositoryCommitMessageParserWorker.php +++ b/src/applications/repository/worker/commitmessageparser/PhabricatorRepositoryCommitMessageParserWorker.php @@ -102,35 +102,6 @@ abstract class PhabricatorRepositoryCommitMessageParserWorker $conn_w = id(new DifferentialRevision())->establishConnection('w'); - $reverts_refs = id(new DifferentialCustomFieldRevertsParser()) - ->parseCorpus($message); - $reverts = array_mergev(ipull($reverts_refs, 'monograms')); - - if ($reverts) { - $reverted_commits = id(new DiffusionCommitQuery()) - ->setViewer($actor) - ->withIdentifiers($reverts) - ->execute(); - $reverted_commit_phids = mpull($reverted_commits, 'getPHID', 'getPHID'); - - // NOTE: Skip any write attempts if a user cleverly implies a commit - // reverts itself. - unset($reverted_commit_phids[$commit->getPHID()]); - - $editor = new PhabricatorEdgeEditor(); - foreach ($reverted_commit_phids as $commit_phid) { - try { - $editor->addEdge( - $commit->getPHID(), - DiffusionCommitRevertsCommitEdgeType::EDGECONST, - $commit_phid); - } catch (PhabricatorEdgeCycleException $ex) { - continue; - } - } - $editor->save(); - } - // NOTE: The `differential_commit` table has a unique ID on `commitPHID`, // preventing more than one revision from being associated with a commit. // Generally this is good and desirable, but with the advent of hash diff --git a/src/infrastructure/internationalization/translation/PhabricatorBaseEnglishTranslation.php b/src/infrastructure/internationalization/translation/PhabricatorBaseEnglishTranslation.php index a28c5321c6..c086d72ef9 100644 --- a/src/infrastructure/internationalization/translation/PhabricatorBaseEnglishTranslation.php +++ b/src/infrastructure/internationalization/translation/PhabricatorBaseEnglishTranslation.php @@ -600,6 +600,40 @@ abstract class PhabricatorBaseEnglishTranslation '%s edited commit(s), added %s: %s; removed %s: %s.' => '%s edited commits, added %3$s; removed %5$s.', + '%s added %s reverted commit(s): %s.' => array( + array( + '%s added a reverted commit: %3$s.', + '%s added reverted commits: %3$s.', + ), + ), + + '%s removed %s reverted commit(s): %s.' => array( + array( + '%s removed a reverted commit: %3$s.', + '%s removed reverted commits: %3$s.', + ), + ), + + '%s edited reverted commit(s), added %s: %s; removed %s: %s.' => + '%s edited reverted commits, added %3$s; removed %5$s.', + + '%s added %s reverting commit(s): %s.' => array( + array( + '%s added a reverting commit: %3$s.', + '%s added reverting commits: %3$s.', + ), + ), + + '%s removed %s reverting commit(s): %s.' => array( + array( + '%s removed a reverting commit: %3$s.', + '%s removed reverting commits: %3$s.', + ), + ), + + '%s edited reverting commit(s), added %s: %s; removed %s: %s.' => + '%s edited reverting commits, added %3$s; removed %5$s.', + '%s changed project member(s), added %d: %s; removed %d: %s.' => '%s changed project members, added %3$s; removed %5$s.',