1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2025-01-28 07:28:20 +01:00
phorge-phorge/src/applications/differential/constants/DifferentialAction.php

139 lines
4.9 KiB
PHP
Raw Normal View History

<?php
final class DifferentialAction {
const ACTION_CLOSE = 'commit';
const ACTION_COMMENT = 'none';
const ACTION_ACCEPT = 'accept';
const ACTION_REJECT = 'reject';
const ACTION_RETHINK = 'rethink';
const ACTION_ABANDON = 'abandon';
const ACTION_REQUEST = 'request_review';
const ACTION_RECLAIM = 'reclaim';
const ACTION_UPDATE = 'update';
const ACTION_RESIGN = 'resign';
const ACTION_SUMMARIZE = 'summarize';
const ACTION_TESTPLAN = 'testplan';
const ACTION_CREATE = 'create';
const ACTION_ADDREVIEWERS = 'add_reviewers';
const ACTION_ADDCCS = 'add_ccs';
const ACTION_CLAIM = 'claim';
const ACTION_REOPEN = 'reopen';
public static function getBasicStoryText($action, $author_name) {
switch ($action) {
case DifferentialAction::ACTION_COMMENT:
$title = pht('%s commented on this revision.',
$author_name);
break;
case DifferentialAction::ACTION_ACCEPT:
$title = pht('%s accepted this revision.',
$author_name);
break;
case DifferentialAction::ACTION_REJECT:
$title = pht('%s requested changes to this revision.',
$author_name);
break;
case DifferentialAction::ACTION_RETHINK:
$title = pht('%s planned changes to this revision.',
$author_name);
break;
case DifferentialAction::ACTION_ABANDON:
$title = pht('%s abandoned this revision.',
$author_name);
break;
case DifferentialAction::ACTION_CLOSE:
$title = pht('%s closed this revision.',
$author_name);
break;
case DifferentialAction::ACTION_REQUEST:
$title = pht('%s requested a review of this revision.',
$author_name);
break;
case DifferentialAction::ACTION_RECLAIM:
$title = pht('%s reclaimed this revision.',
$author_name);
break;
case DifferentialAction::ACTION_UPDATE:
$title = pht('%s updated this revision.',
$author_name);
break;
case DifferentialAction::ACTION_RESIGN:
$title = pht('%s resigned from this revision.',
$author_name);
break;
case DifferentialAction::ACTION_SUMMARIZE:
$title = pht('%s summarized this revision.',
$author_name);
break;
case DifferentialAction::ACTION_TESTPLAN:
$title = pht('%s explained the test plan for this revision.',
$author_name);
break;
case DifferentialAction::ACTION_CREATE:
$title = pht('%s created this revision.',
$author_name);
break;
case DifferentialAction::ACTION_ADDREVIEWERS:
$title = pht('%s added reviewers to this revision.',
$author_name);
break;
case DifferentialAction::ACTION_ADDCCS:
$title = pht('%s added CCs to this revision.',
$author_name);
break;
case DifferentialAction::ACTION_CLAIM:
$title = pht('%s commandeered this revision.',
$author_name);
break;
case DifferentialAction::ACTION_REOPEN:
$title = pht('%s reopened this revision.',
$author_name);
break;
Migrate Differential comments to ApplicationTransactions Summary: Ref T2222. This is the big one. This migrates each `DifferentialComment` to one or more ApplicationTransactions (action, cc, reviewers, update, comment, inlines), and makes `DifferentialComment` a double-reader for ApplicationTransactions. The migration is pretty straightforward: - If a comment took an action not otherwise covered, it gets an "action" transaction. This is something like "epriestley abandoned this revision.". - If a comment updated the diff, it gets an "updated diff" transaction. Very old transactions of this type may not have a diff ID (probably only at Facebook). - If a comment added or removed reviewers, it gets a "changed reviewers" transaction. - If a comment added CCs, it gets a "subscribers" transaction. - If a comment added comment text, it gets a "comment" transaction. - For each inline attached to a comment, we generate an "inline" transaction. Most comments generate a small number of transactions, but a few generate a significant number. At HEAD, the code is basically already doing this, so comments in the last day or two already obey these rules, roughly, and will all generate only one transaction (except inlines). Because we've already preallocated PHIDs in the comment text table, we only need to write to the transaction table. NOTE: This significantly degrades Differential, making inline comments pretty much useless (they each get their own transaction, and don't show line numbers or files). The data is all fine, but the UI is garbage now. This needs to be fixed before we can deploy this to users, but it's easily separable since it's all just display code. Specifically, they look like this: {F112270} Test Plan: I've migrated locally and put things through their paces, but it's hard to catch sketchy stuff locally because most of my test data is nonsense and bad migrations wouldn't necessarily look out of place. IMPORTANT: I'm planning to push this to a branch and then shift production over to the branch, and run it for a day or two before bringing it to master. I generally feel good about this change: it's not that big since we were able to separate a lot of pieces out of it, and it's pretty straightforward. That said, it's still one of the most scary/dangerous changes we've ever made. Reviewers: btrahan CC: chad, aran Maniphest Tasks: T2222 Differential Revision: https://secure.phabricator.com/D8210
2014-02-11 15:36:58 -08:00
case DifferentialTransaction::TYPE_INLINE:
$title = pht(
'%s added an inline comment.',
$author_name);
break;
default:
$title = pht('Ghosts happened to this revision.');
break;
}
return $title;
}
2011-01-30 11:02:22 -08:00
public static function getActionVerb($action) {
$verbs = array(
self::ACTION_COMMENT => pht('Comment'),
self::ACTION_ACCEPT => pht("Accept Revision \xE2\x9C\x94"),
self::ACTION_REJECT => pht("Request Changes \xE2\x9C\x98"),
self::ACTION_RETHINK => pht("Plan Changes \xE2\x9C\x98"),
self::ACTION_ABANDON => pht('Abandon Revision'),
self::ACTION_REQUEST => pht('Request Review'),
self::ACTION_RECLAIM => pht('Reclaim Revision'),
self::ACTION_RESIGN => pht('Resign as Reviewer'),
self::ACTION_ADDREVIEWERS => pht('Add Reviewers'),
self::ACTION_ADDCCS => pht('Add CCs'),
self::ACTION_CLOSE => pht('Close Revision'),
self::ACTION_CLAIM => pht('Commandeer Revision'),
self::ACTION_REOPEN => pht('Reopen'),
2011-01-30 11:02:22 -08:00
);
if (!empty($verbs[$action])) {
return $verbs[$action];
} else {
return 'brazenly '.$action;
}
}
public static function allowReviewers($action) {
if ($action == DifferentialAction::ACTION_ADDREVIEWERS ||
$action == DifferentialAction::ACTION_REQUEST ||
$action == DifferentialAction::ACTION_RESIGN) {
return true;
}
return false;
}
}