1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-12-18 19:40:55 +01:00

Migrate Maniphest task blockers to modern EdgeType classes

Summary:
Prevents "edited tasks, added: 1; removed: 1"

Fixes T6757, using D9839 as an example

Test Plan: Added and removed blockers to/from tasks, saw the expected history entries.

Reviewers: epriestley, #blessed_reviewers

Reviewed By: epriestley, #blessed_reviewers

Subscribers: Korvin, epriestley

Maniphest Tasks: T6757

Differential Revision: https://secure.phabricator.com/D11045
This commit is contained in:
Alex Monk 2014-12-28 06:10:49 -08:00 committed by epriestley
parent 9219645287
commit 102e431feb
13 changed files with 270 additions and 38 deletions

View file

@ -18,7 +18,7 @@ foreach (new LiskMigrationIterator($table) as $task) {
foreach ($deps as $dep) { foreach ($deps as $dep) {
$editor->addEdge( $editor->addEdge(
$task->getPHID(), $task->getPHID(),
PhabricatorEdgeConfig::TYPE_TASK_DEPENDS_ON_TASK, ManiphestTaskDependsOnTaskEdgeType::EDGECONST,
$dep); $dep);
} }
$editor->save(); $editor->save();

View file

@ -1013,6 +1013,8 @@ phutil_register_library_map(array(
'ManiphestStatusConfigOptionType' => 'applications/maniphest/config/ManiphestStatusConfigOptionType.php', 'ManiphestStatusConfigOptionType' => 'applications/maniphest/config/ManiphestStatusConfigOptionType.php',
'ManiphestSubpriorityController' => 'applications/maniphest/controller/ManiphestSubpriorityController.php', 'ManiphestSubpriorityController' => 'applications/maniphest/controller/ManiphestSubpriorityController.php',
'ManiphestTask' => 'applications/maniphest/storage/ManiphestTask.php', 'ManiphestTask' => 'applications/maniphest/storage/ManiphestTask.php',
'ManiphestTaskDependedOnByTaskEdgeType' => 'applications/maniphest/edge/ManiphestTaskDependedOnByTaskEdgeType.php',
'ManiphestTaskDependsOnTaskEdgeType' => 'applications/maniphest/edge/ManiphestTaskDependsOnTaskEdgeType.php',
'ManiphestTaskDescriptionPreviewController' => 'applications/maniphest/controller/ManiphestTaskDescriptionPreviewController.php', 'ManiphestTaskDescriptionPreviewController' => 'applications/maniphest/controller/ManiphestTaskDescriptionPreviewController.php',
'ManiphestTaskDetailController' => 'applications/maniphest/controller/ManiphestTaskDetailController.php', 'ManiphestTaskDetailController' => 'applications/maniphest/controller/ManiphestTaskDetailController.php',
'ManiphestTaskEditController' => 'applications/maniphest/controller/ManiphestTaskEditController.php', 'ManiphestTaskEditController' => 'applications/maniphest/controller/ManiphestTaskEditController.php',
@ -4121,6 +4123,8 @@ phutil_register_library_map(array(
'PhabricatorApplicationTransactionInterface', 'PhabricatorApplicationTransactionInterface',
'PhabricatorProjectInterface', 'PhabricatorProjectInterface',
), ),
'ManiphestTaskDependedOnByTaskEdgeType' => 'PhabricatorEdgeType',
'ManiphestTaskDependsOnTaskEdgeType' => 'PhabricatorEdgeType',
'ManiphestTaskDescriptionPreviewController' => 'ManiphestController', 'ManiphestTaskDescriptionPreviewController' => 'ManiphestController',
'ManiphestTaskDetailController' => 'ManiphestController', 'ManiphestTaskDetailController' => 'ManiphestController',
'ManiphestTaskEditController' => 'ManiphestController', 'ManiphestTaskEditController' => 'ManiphestController',

View file

@ -251,7 +251,7 @@ abstract class ManiphestConduitAPIMethod extends ConduitAPIMethod {
$all_deps = id(new PhabricatorEdgeQuery()) $all_deps = id(new PhabricatorEdgeQuery())
->withSourcePHIDs($task_phids) ->withSourcePHIDs($task_phids)
->withEdgeTypes(array(PhabricatorEdgeConfig::TYPE_TASK_DEPENDS_ON_TASK)); ->withEdgeTypes(array(ManiphestTaskDependsOnTaskEdgeType::EDGECONST));
$all_deps->execute(); $all_deps->execute();
$result = array(); $result = array();
@ -269,7 +269,7 @@ abstract class ManiphestConduitAPIMethod extends ConduitAPIMethod {
$task_deps = $all_deps->getDestinationPHIDs( $task_deps = $all_deps->getDestinationPHIDs(
array($task->getPHID()), array($task->getPHID()),
array(PhabricatorEdgeConfig::TYPE_TASK_DEPENDS_ON_TASK)); array(ManiphestTaskDependsOnTaskEdgeType::EDGECONST));
$result[$task->getPHID()] = array( $result[$task->getPHID()] = array(
'id' => $task->getID(), 'id' => $task->getID(),

View file

@ -46,8 +46,8 @@ final class ManiphestTaskDetailController extends ManiphestController {
->readFieldsFromStorage($task); ->readFieldsFromStorage($task);
$e_commit = ManiphestTaskHasCommitEdgeType::EDGECONST; $e_commit = ManiphestTaskHasCommitEdgeType::EDGECONST;
$e_dep_on = PhabricatorEdgeConfig::TYPE_TASK_DEPENDS_ON_TASK; $e_dep_on = ManiphestTaskDependsOnTaskEdgeType::EDGECONST;
$e_dep_by = PhabricatorEdgeConfig::TYPE_TASK_DEPENDED_ON_BY_TASK; $e_dep_by = ManiphestTaskDependedOnByTaskEdgeType::EDGECONST;
$e_rev = ManiphestTaskHasRevisionEdgeType::EDGECONST; $e_rev = ManiphestTaskHasRevisionEdgeType::EDGECONST;
$e_mock = PhabricatorEdgeConfig::TYPE_TASK_HAS_MOCK; $e_mock = PhabricatorEdgeConfig::TYPE_TASK_HAS_MOCK;
@ -482,9 +482,9 @@ final class ManiphestTaskDetailController extends ManiphestController {
} }
$edge_types = array( $edge_types = array(
PhabricatorEdgeConfig::TYPE_TASK_DEPENDED_ON_BY_TASK ManiphestTaskDependedOnByTaskEdgeType::EDGECONST
=> pht('Blocks'), => pht('Blocks'),
PhabricatorEdgeConfig::TYPE_TASK_DEPENDS_ON_TASK ManiphestTaskDependsOnTaskEdgeType::EDGECONST
=> pht('Blocked By'), => pht('Blocked By'),
ManiphestTaskHasRevisionEdgeType::EDGECONST ManiphestTaskHasRevisionEdgeType::EDGECONST
=> pht('Differential Revisions'), => pht('Differential Revisions'),

View file

@ -349,7 +349,7 @@ final class ManiphestTaskEditController extends ManiphestController {
id(new PhabricatorEdgeEditor()) id(new PhabricatorEdgeEditor())
->addEdge( ->addEdge(
$parent_task->getPHID(), $parent_task->getPHID(),
PhabricatorEdgeConfig::TYPE_TASK_DEPENDS_ON_TASK, ManiphestTaskDependsOnTaskEdgeType::EDGECONST,
$task->getPHID()) $task->getPHID())
->save(); ->save();
$workflow = $parent_task->getID(); $workflow = $parent_task->getID();

View file

@ -0,0 +1,101 @@
<?php
final class ManiphestTaskDependedOnByTaskEdgeType extends PhabricatorEdgeType {
const EDGECONST = 4;
public function getInverseEdgeConstant() {
return ManiphestTaskDependsOnTaskEdgeType::EDGECONST;
}
public function shouldWriteInverseTransaction() {
return true;
}
public function getTransactionAddString(
$actor,
$add_count,
$add_edges) {
return pht(
'%s added %s blocked task(s): %s.',
$actor,
$add_count,
$add_edges);
}
public function getTransactionRemoveString(
$actor,
$rem_count,
$rem_edges) {
return pht(
'%s removed %s blocked task(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 blocked task(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 blocked task(s) for %s: %s.',
$actor,
$add_count,
$object,
$add_edges);
}
public function getFeedRemoveString(
$actor,
$object,
$rem_count,
$rem_edges) {
return pht(
'%s removed %s blocked task(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 blocked task(s) for %s, added %s: %s; removed %s: %s.',
$actor,
$object,
$add_count,
$add_edges,
$rem_count,
$rem_edges);
}
}

View file

@ -0,0 +1,106 @@
<?php
final class ManiphestTaskDependsOnTaskEdgeType extends PhabricatorEdgeType {
const EDGECONST = 3;
public function getInverseEdgeConstant() {
return ManiphestTaskDependedOnByTaskEdgeType::EDGECONST;
}
public function shouldWriteInverseTransaction() {
return true;
}
public function shouldPreventCycles() {
return true;
}
public function getTransactionAddString(
$actor,
$add_count,
$add_edges) {
return pht(
'%s added %s blocking task(s): %s.',
$actor,
$add_count,
$add_edges);
}
public function getTransactionRemoveString(
$actor,
$rem_count,
$rem_edges) {
return pht(
'%s removed %s blocking task(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 blocking task(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 blocking task(s) for %s: %s.',
$actor,
$add_count,
$object,
$add_edges);
}
public function getFeedRemoveString(
$actor,
$object,
$rem_count,
$rem_edges) {
return pht(
'%s removed %s blocking task(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 blocking task(s) for %s, added %s: %s; removed %s: %s.',
$actor,
$object,
$add_count,
$add_edges,
$rem_count,
$rem_edges);
}
}

View file

@ -362,7 +362,7 @@ final class ManiphestTransactionEditor
if ($unblock_xaction !== null) { if ($unblock_xaction !== null) {
$blocked_phids = PhabricatorEdgeQuery::loadDestinationPHIDs( $blocked_phids = PhabricatorEdgeQuery::loadDestinationPHIDs(
$object->getPHID(), $object->getPHID(),
PhabricatorEdgeConfig::TYPE_TASK_DEPENDED_ON_BY_TASK); ManiphestTaskDependedOnByTaskEdgeType::EDGECONST);
if ($blocked_phids) { if ($blocked_phids) {
// In theory we could apply these through policies, but that seems a // In theory we could apply these through policies, but that seems a
// little bit surprising. For now, use the actor's vision. // little bit surprising. For now, use the actor's vision.

View file

@ -27,8 +27,8 @@ final class ManiphestHovercardEventListener extends PhabricatorEventListener {
$e_project = PhabricatorProjectObjectHasProjectEdgeType::EDGECONST; $e_project = PhabricatorProjectObjectHasProjectEdgeType::EDGECONST;
// Fun with "Unbeta Pholio", hua hua // Fun with "Unbeta Pholio", hua hua
$e_dep_on = PhabricatorEdgeConfig::TYPE_TASK_DEPENDS_ON_TASK; $e_dep_on = ManiphestTaskDependsOnTaskEdgeType::EDGECONST;
$e_dep_by = PhabricatorEdgeConfig::TYPE_TASK_DEPENDED_ON_BY_TASK; $e_dep_by = ManiphestTaskDependedOnByTaskEdgeType::EDGECONST;
$edge_query = id(new PhabricatorEdgeQuery()) $edge_query = id(new PhabricatorEdgeQuery())
->withSourcePHIDs(array($phid)) ->withSourcePHIDs(array($phid))

View file

@ -125,13 +125,13 @@ final class ManiphestTask extends ManiphestDAO
public function loadDependsOnTaskPHIDs() { public function loadDependsOnTaskPHIDs() {
return PhabricatorEdgeQuery::loadDestinationPHIDs( return PhabricatorEdgeQuery::loadDestinationPHIDs(
$this->getPHID(), $this->getPHID(),
PhabricatorEdgeConfig::TYPE_TASK_DEPENDS_ON_TASK); ManiphestTaskDependsOnTaskEdgeType::EDGECONST);
} }
public function loadDependedOnByTaskPHIDs() { public function loadDependedOnByTaskPHIDs() {
return PhabricatorEdgeQuery::loadDestinationPHIDs( return PhabricatorEdgeQuery::loadDestinationPHIDs(
$this->getPHID(), $this->getPHID(),
PhabricatorEdgeConfig::TYPE_TASK_DEPENDED_ON_BY_TASK); ManiphestTaskDependedOnByTaskEdgeType::EDGECONST);
} }
public function getAttachedPHIDs($type) { public function getAttachedPHIDs($type) {

View file

@ -292,7 +292,7 @@ final class PhabricatorSearchAttachController
), ),
$t_task => array( $t_task => array(
$t_cmit => ManiphestTaskHasCommitEdgeType::EDGECONST, $t_cmit => ManiphestTaskHasCommitEdgeType::EDGECONST,
$t_task => PhabricatorEdgeConfig::TYPE_TASK_DEPENDS_ON_TASK, $t_task => ManiphestTaskDependsOnTaskEdgeType::EDGECONST,
$t_drev => ManiphestTaskHasRevisionEdgeType::EDGECONST, $t_drev => ManiphestTaskHasRevisionEdgeType::EDGECONST,
$t_mock => PhabricatorEdgeConfig::TYPE_TASK_HAS_MOCK, $t_mock => PhabricatorEdgeConfig::TYPE_TASK_HAS_MOCK,
), ),

View file

@ -5,9 +5,6 @@ final class PhabricatorEdgeConfig extends PhabricatorEdgeConstants {
const TABLE_NAME_EDGE = 'edge'; const TABLE_NAME_EDGE = 'edge';
const TABLE_NAME_EDGEDATA = 'edgedata'; const TABLE_NAME_EDGEDATA = 'edgedata';
const TYPE_TASK_DEPENDS_ON_TASK = 3;
const TYPE_TASK_DEPENDED_ON_BY_TASK = 4;
const TYPE_DREV_DEPENDS_ON_DREV = 5; const TYPE_DREV_DEPENDS_ON_DREV = 5;
const TYPE_DREV_DEPENDED_ON_BY_DREV = 6; const TYPE_DREV_DEPENDED_ON_BY_DREV = 6;
@ -131,9 +128,6 @@ final class PhabricatorEdgeConfig extends PhabricatorEdgeConstants {
private static function getInverse($edge_type) { private static function getInverse($edge_type) {
static $map = array( static $map = array(
self::TYPE_TASK_DEPENDS_ON_TASK => self::TYPE_TASK_DEPENDED_ON_BY_TASK,
self::TYPE_TASK_DEPENDED_ON_BY_TASK => self::TYPE_TASK_DEPENDS_ON_TASK,
self::TYPE_DREV_DEPENDS_ON_DREV => self::TYPE_DREV_DEPENDED_ON_BY_DREV, self::TYPE_DREV_DEPENDS_ON_DREV => self::TYPE_DREV_DEPENDED_ON_BY_DREV,
self::TYPE_DREV_DEPENDED_ON_BY_DREV => self::TYPE_DREV_DEPENDS_ON_DREV, self::TYPE_DREV_DEPENDED_ON_BY_DREV => self::TYPE_DREV_DEPENDS_ON_DREV,
@ -203,7 +197,6 @@ final class PhabricatorEdgeConfig extends PhabricatorEdgeConstants {
private static function shouldPreventCycles($edge_type) { private static function shouldPreventCycles($edge_type) {
static $map = array( static $map = array(
self::TYPE_TEST_NO_CYCLE => true, self::TYPE_TEST_NO_CYCLE => true,
self::TYPE_TASK_DEPENDS_ON_TASK => true,
self::TYPE_DREV_DEPENDS_ON_DREV => true, self::TYPE_DREV_DEPENDS_ON_DREV => true,
); );
return isset($map[$edge_type]); return isset($map[$edge_type]);
@ -238,8 +231,6 @@ final class PhabricatorEdgeConfig extends PhabricatorEdgeConstants {
switch ($type) { switch ($type) {
case self::TYPE_DREV_HAS_COMMIT: case self::TYPE_DREV_HAS_COMMIT:
return '%s edited commit(s), added %d: %s; removed %d: %s.'; return '%s edited commit(s), added %d: %s; removed %d: %s.';
case self::TYPE_TASK_DEPENDS_ON_TASK:
case self::TYPE_TASK_DEPENDED_ON_BY_TASK:
case self::TYPE_MOCK_HAS_TASK: case self::TYPE_MOCK_HAS_TASK:
return '%s edited task(s), added %d: %s; removed %d: %s.'; return '%s edited task(s), added %d: %s; removed %d: %s.';
case self::TYPE_DREV_DEPENDS_ON_DREV: case self::TYPE_DREV_DEPENDS_ON_DREV:
@ -304,12 +295,8 @@ final class PhabricatorEdgeConfig extends PhabricatorEdgeConstants {
switch ($type) { switch ($type) {
case self::TYPE_DREV_HAS_COMMIT: case self::TYPE_DREV_HAS_COMMIT:
return '%s added %d commit(s): %s.'; return '%s added %d commit(s): %s.';
case self::TYPE_TASK_DEPENDS_ON_TASK:
return '%s added %d blocking task(s): %s.';
case self::TYPE_DREV_DEPENDS_ON_DREV: case self::TYPE_DREV_DEPENDS_ON_DREV:
return '%s added %d dependencie(s): %s.'; return '%s added %d dependencie(s): %s.';
case self::TYPE_TASK_DEPENDED_ON_BY_TASK:
return '%s added %d blocked task(s): %s.';
case self::TYPE_MOCK_HAS_TASK: case self::TYPE_MOCK_HAS_TASK:
return '%s added %d task(s): %s.'; return '%s added %d task(s): %s.';
case self::TYPE_DREV_DEPENDED_ON_BY_DREV: case self::TYPE_DREV_DEPENDED_ON_BY_DREV:
@ -372,10 +359,6 @@ final class PhabricatorEdgeConfig extends PhabricatorEdgeConstants {
switch ($type) { switch ($type) {
case self::TYPE_DREV_HAS_COMMIT: case self::TYPE_DREV_HAS_COMMIT:
return '%s removed %d commit(s): %s.'; return '%s removed %d commit(s): %s.';
case self::TYPE_TASK_DEPENDS_ON_TASK:
return '%s removed %d blocking task(s): %s.';
case self::TYPE_TASK_DEPENDED_ON_BY_TASK:
return '%s removed %d blocked task(s): %s.';
case self::TYPE_MOCK_HAS_TASK: case self::TYPE_MOCK_HAS_TASK:
return '%s removed %d task(s): %s.'; return '%s removed %d task(s): %s.';
case self::TYPE_DREV_DEPENDS_ON_DREV: case self::TYPE_DREV_DEPENDS_ON_DREV:
@ -437,8 +420,6 @@ final class PhabricatorEdgeConfig extends PhabricatorEdgeConstants {
switch ($type) { switch ($type) {
case self::TYPE_DREV_HAS_COMMIT: case self::TYPE_DREV_HAS_COMMIT:
return '%s updated commits of %s.'; return '%s updated commits of %s.';
case self::TYPE_TASK_DEPENDS_ON_TASK:
case self::TYPE_TASK_DEPENDED_ON_BY_TASK:
case self::TYPE_MOCK_HAS_TASK: case self::TYPE_MOCK_HAS_TASK:
return '%s updated tasks of %s.'; return '%s updated tasks of %s.';
case self::TYPE_DREV_DEPENDS_ON_DREV: case self::TYPE_DREV_DEPENDS_ON_DREV:

View file

@ -382,34 +382,74 @@ abstract class PhabricatorBaseEnglishTranslation
), ),
), ),
'%s added %d blocking task(s): %s.' => array( '%s added %s blocking task(s): %s.' => array(
array( array(
'%s added a blocking task: %3$s.', '%s added a blocking task: %3$s.',
'%s added blocking tasks: %3$s.', '%s added blocking tasks: %3$s.',
), ),
), ),
'%s added %d blocked task(s): %s.' => array( '%s added %s blocked task(s): %s.' => array(
array( array(
'%s added a blocked task: %3$s.', '%s added a blocked task: %3$s.',
'%s added blocked tasks: %3$s.', '%s added blocked tasks: %3$s.',
), ),
), ),
'%s removed %d blocking task(s): %s.' => array( '%s removed %s blocking task(s): %s.' => array(
array( array(
'%s removed a blocking task: %3$s.', '%s removed a blocking task: %3$s.',
'%s removed blocking tasks: %3$s.', '%s removed blocking tasks: %3$s.',
), ),
), ),
'%s removed %d blocked task(s): %s.' => array( '%s removed %s blocked task(s): %s.' => array(
array( array(
'%s removed a blocked task: %3$s.', '%s removed a blocked task: %3$s.',
'%s removed blocked tasks: %3$s.', '%s removed blocked tasks: %3$s.',
), ),
), ),
'%s added %s blocking task(s) for %s: %s.' => array(
array(
'%s added a blocking task for %3$s: %4$s.',
'%s added blocking tasks for %3$s: %4$s.',
),
),
'%s added %s blocked task(s) for %s: %s.' => array(
array(
'%s added a blocked task for %3$s: %4$s.',
'%s added blocked tasks for %3$s: %4$s.',
),
),
'%s removed %s blocking task(s) for %s: %s.' => array(
array(
'%s removed a blocking task for %3$s: %4$s.',
'%s removed blocking tasks for %3$s: %4$s.',
),
),
'%s removed %s blocked task(s) for %s: %s.' => array(
array(
'%s removed a blocked task for %3$s: %4$s.',
'%s removed blocked tasks for %3$s: %4$s.',
),
),
'%s edited blocking task(s), added %s: %s; removed %s: %s.' =>
'%s edited blocking tasks, added: %3$s; removed: %5$s',
'%s edited blocking task(s) for %s, added %s: %s; removed %s: %s.' =>
'%s edited blocking tasks for %s, added: %4$s; removed: %6$s',
'%s edited blocked task(s), added %s: %s; removed %s: %s.' =>
'%s edited blocked tasks, added: %3$s; removed: %5$s',
'%s edited blocked task(s) for %s, added %s: %s; removed %s: %s.' =>
'%s edited blocked tasks for %s, added: %4$s; removed: %6$s',
'%s edited answer(s), added %d: %s; removed %d: %s.' => '%s edited answer(s), added %d: %s; removed %d: %s.' =>
'%s edited answers, added: %3$s; removed: %5$s', '%s edited answers, added: %3$s; removed: %5$s',
@ -461,7 +501,7 @@ abstract class PhabricatorBaseEnglishTranslation
), ),
), ),
'%s edited task(s), added %d: %s; removed %d: %s.' => '%s edited task(s), added %d: %s; removed %s: %s.' =>
'%s edited tasks, added: %3$s; removed: %5$s', '%s edited tasks, added: %3$s; removed: %5$s',
'%s added %d task(s): %s.' => array( '%s added %d task(s): %s.' => array(