@recaptime-dev's working patches + fork for Phorge, a community fork of Phabricator. (Upstream dev and stable branches are at upstream/main and upstream/stable respectively.) hq.recaptime.dev/wiki/Phorge
phorge phabricator
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Modernize commit/edge transaction when parsing commit messages

Summary: Ref T5245. With work elsewhere (notably, D9839) we can remove this TODO and use real transactions.

Test Plan: Pushed a `closes Txxx` commit and got a close + transaction.

Reviewers: chad, btrahan, joshuaspence

Reviewed By: joshuaspence

Subscribers: epriestley

Maniphest Tasks: T5245

Differential Revision: https://secure.phabricator.com/D9848

+219 -35
+4
src/__phutil_library_map__.php
··· 486 486 'DiffusionCommitChangeTableView' => 'applications/diffusion/view/DiffusionCommitChangeTableView.php', 487 487 'DiffusionCommitController' => 'applications/diffusion/controller/DiffusionCommitController.php', 488 488 'DiffusionCommitEditController' => 'applications/diffusion/controller/DiffusionCommitEditController.php', 489 + 'DiffusionCommitHasTaskEdgeType' => 'applications/diffusion/edge/DiffusionCommitHasTaskEdgeType.php', 489 490 'DiffusionCommitHash' => 'applications/diffusion/data/DiffusionCommitHash.php', 490 491 'DiffusionCommitHookEngine' => 'applications/diffusion/engine/DiffusionCommitHookEngine.php', 491 492 'DiffusionCommitHookRejectException' => 'applications/diffusion/exception/DiffusionCommitHookRejectException.php', ··· 945 946 'ManiphestTaskDescriptionPreviewController' => 'applications/maniphest/controller/ManiphestTaskDescriptionPreviewController.php', 946 947 'ManiphestTaskDetailController' => 'applications/maniphest/controller/ManiphestTaskDetailController.php', 947 948 'ManiphestTaskEditController' => 'applications/maniphest/controller/ManiphestTaskEditController.php', 949 + 'ManiphestTaskHasCommitEdgeType' => 'applications/maniphest/edge/ManiphestTaskHasCommitEdgeType.php', 948 950 'ManiphestTaskHasRevisionEdgeType' => 'applications/maniphest/edge/ManiphestTaskHasRevisionEdgeType.php', 949 951 'ManiphestTaskListController' => 'applications/maniphest/controller/ManiphestTaskListController.php', 950 952 'ManiphestTaskListView' => 'applications/maniphest/view/ManiphestTaskListView.php', ··· 3199 3201 'DiffusionCommitChangeTableView' => 'DiffusionView', 3200 3202 'DiffusionCommitController' => 'DiffusionController', 3201 3203 'DiffusionCommitEditController' => 'DiffusionController', 3204 + 'DiffusionCommitHasTaskEdgeType' => 'PhabricatorEdgeType', 3202 3205 'DiffusionCommitHash' => 'Phobject', 3203 3206 'DiffusionCommitHookEngine' => 'Phobject', 3204 3207 'DiffusionCommitHookRejectException' => 'Exception', ··· 3703 3706 'ManiphestTaskDescriptionPreviewController' => 'ManiphestController', 3704 3707 'ManiphestTaskDetailController' => 'ManiphestController', 3705 3708 'ManiphestTaskEditController' => 'ManiphestController', 3709 + 'ManiphestTaskHasCommitEdgeType' => 'PhabricatorEdgeType', 3706 3710 'ManiphestTaskHasRevisionEdgeType' => 'PhabricatorEdgeType', 3707 3711 'ManiphestTaskListController' => 'ManiphestController', 3708 3712 'ManiphestTaskListView' => 'ManiphestView',
+1 -1
src/applications/diffusion/conduit/ConduitAPI_diffusion_getcommits_Method.php
··· 269 269 * Enhances the commits list with Maniphest information. 270 270 */ 271 271 private function addManiphestInformation(array $commits) { 272 - $task_type = PhabricatorEdgeConfig::TYPE_COMMIT_HAS_TASK; 272 + $task_type = DiffusionCommitHasTaskEdgeType::EDGECONST; 273 273 274 274 $commit_phids = ipull($commits, 'commitPHID'); 275 275
+2 -2
src/applications/diffusion/controller/DiffusionCommitController.php
··· 420 420 $edge_query = id(new PhabricatorEdgeQuery()) 421 421 ->withSourcePHIDs(array($commit_phid)) 422 422 ->withEdgeTypes(array( 423 - PhabricatorEdgeConfig::TYPE_COMMIT_HAS_TASK, 423 + DiffusionCommitHasTaskEdgeType::EDGECONST, 424 424 PhabricatorEdgeConfig::TYPE_COMMIT_HAS_PROJECT, 425 425 PhabricatorEdgeConfig::TYPE_COMMIT_HAS_DREV, 426 426 )); ··· 428 428 $edges = $edge_query->execute(); 429 429 430 430 $task_phids = array_keys( 431 - $edges[$commit_phid][PhabricatorEdgeConfig::TYPE_COMMIT_HAS_TASK]); 431 + $edges[$commit_phid][DiffusionCommitHasTaskEdgeType::EDGECONST]); 432 432 $proj_phids = array_keys( 433 433 $edges[$commit_phid][PhabricatorEdgeConfig::TYPE_COMMIT_HAS_PROJECT]); 434 434 $revision_phid = key(
+103
src/applications/diffusion/edge/DiffusionCommitHasTaskEdgeType.php
··· 1 + <?php 2 + 3 + final class DiffusionCommitHasTaskEdgeType extends PhabricatorEdgeType { 4 + 5 + const EDGECONST = 2; 6 + 7 + public function shouldWriteInverseTransactions() { 8 + // TODO: This should happen after T4896, but Diffusion does not support 9 + // transactions yet. 10 + return false; 11 + } 12 + 13 + public function getTransactionAddString( 14 + $actor, 15 + $add_count, 16 + $add_edges) { 17 + 18 + return pht( 19 + '%s added %s task(s): %s.', 20 + $actor, 21 + $add_count, 22 + $add_edges); 23 + } 24 + 25 + public function getTransactionRemoveString( 26 + $actor, 27 + $rem_count, 28 + $rem_edges) { 29 + 30 + return pht( 31 + '%s removed %s task(s): %s.', 32 + $actor, 33 + $rem_count, 34 + $rem_edges); 35 + } 36 + 37 + public function getTransactionEditString( 38 + $actor, 39 + $total_count, 40 + $add_count, 41 + $add_edges, 42 + $rem_count, 43 + $rem_edges) { 44 + 45 + return pht( 46 + '%s edited %s task(s), added %s: %s; removed %s: %s.', 47 + $actor, 48 + $total_count, 49 + $add_count, 50 + $add_edges, 51 + $rem_count, 52 + $rem_edges); 53 + } 54 + 55 + public function getFeedAddString( 56 + $actor, 57 + $object, 58 + $add_count, 59 + $add_edges) { 60 + 61 + return pht( 62 + '%s added %s task(s) to %s: %s.', 63 + $actor, 64 + $add_count, 65 + $object, 66 + $add_edges); 67 + } 68 + 69 + public function getFeedRemoveString( 70 + $actor, 71 + $object, 72 + $rem_count, 73 + $rem_edges) { 74 + 75 + return pht( 76 + '%s removed %s task(s) from %s: %s.', 77 + $actor, 78 + $rem_count, 79 + $object, 80 + $rem_edges); 81 + } 82 + 83 + public function getFeedEditString( 84 + $actor, 85 + $object, 86 + $total_count, 87 + $add_count, 88 + $add_edges, 89 + $rem_count, 90 + $rem_edges) { 91 + 92 + return pht( 93 + '%s edited %s task(s) for %s, added %s: %s; removed %s: %s.', 94 + $actor, 95 + $total_count, 96 + $object, 97 + $add_count, 98 + $add_edges, 99 + $rem_count, 100 + $rem_edges); 101 + } 102 + 103 + }
+2 -2
src/applications/maniphest/controller/ManiphestTaskDetailController.php
··· 51 51 ->setViewer($user) 52 52 ->readFieldsFromStorage($task); 53 53 54 - $e_commit = PhabricatorEdgeConfig::TYPE_TASK_HAS_COMMIT; 54 + $e_commit = ManiphestTaskHasCommitEdgeType::EDGECONST; 55 55 $e_dep_on = PhabricatorEdgeConfig::TYPE_TASK_DEPENDS_ON_TASK; 56 56 $e_dep_by = PhabricatorEdgeConfig::TYPE_TASK_DEPENDED_ON_BY_TASK; 57 57 $e_rev = ManiphestTaskHasRevisionEdgeType::EDGECONST; ··· 603 603 $handles = $this->getLoadedHandles(); 604 604 605 605 $commit_phids = array_keys( 606 - $edges[PhabricatorEdgeConfig::TYPE_TASK_HAS_COMMIT]); 606 + $edges[ManiphestTaskHasCommitEdgeType::EDGECONST]); 607 607 if ($commit_phids) { 608 608 $commit_drev = PhabricatorEdgeConfig::TYPE_COMMIT_HAS_DREV; 609 609 $drev_edges = id(new PhabricatorEdgeQuery())
+103
src/applications/maniphest/edge/ManiphestTaskHasCommitEdgeType.php
··· 1 + <?php 2 + 3 + final class ManiphestTaskHasCommitEdgeType extends PhabricatorEdgeType { 4 + 5 + const EDGECONST = 1; 6 + 7 + public function shouldWriteInverseTransactions() { 8 + // TODO: This should happen after T4896, but Diffusion does not support 9 + // transactions yet. 10 + return false; 11 + } 12 + 13 + public function getTransactionAddString( 14 + $actor, 15 + $add_count, 16 + $add_edges) { 17 + 18 + return pht( 19 + '%s added %s commit(s): %s.', 20 + $actor, 21 + $add_count, 22 + $add_edges); 23 + } 24 + 25 + public function getTransactionRemoveString( 26 + $actor, 27 + $rem_count, 28 + $rem_edges) { 29 + 30 + return pht( 31 + '%s removed %s commit(s): %s.', 32 + $actor, 33 + $rem_count, 34 + $rem_edges); 35 + } 36 + 37 + public function getTransactionEditString( 38 + $actor, 39 + $total_count, 40 + $add_count, 41 + $add_edges, 42 + $rem_count, 43 + $rem_edges) { 44 + 45 + return pht( 46 + '%s edited %s commit(s), added %s: %s; removed %s: %s.', 47 + $actor, 48 + $total_count, 49 + $add_count, 50 + $add_edges, 51 + $rem_count, 52 + $rem_edges); 53 + } 54 + 55 + public function getFeedAddString( 56 + $actor, 57 + $object, 58 + $add_count, 59 + $add_edges) { 60 + 61 + return pht( 62 + '%s added %s commit(s) to %s: %s.', 63 + $actor, 64 + $add_count, 65 + $object, 66 + $add_edges); 67 + } 68 + 69 + public function getFeedRemoveString( 70 + $actor, 71 + $object, 72 + $rem_count, 73 + $rem_edges) { 74 + 75 + return pht( 76 + '%s removed %s commit(s) from %s: %s.', 77 + $actor, 78 + $rem_count, 79 + $object, 80 + $rem_edges); 81 + } 82 + 83 + public function getFeedEditString( 84 + $actor, 85 + $object, 86 + $total_count, 87 + $add_count, 88 + $add_edges, 89 + $rem_count, 90 + $rem_edges) { 91 + 92 + return pht( 93 + '%s edited %s commit(s) for %s, added %s: %s; removed %s: %s.', 94 + $actor, 95 + $total_count, 96 + $object, 97 + $add_count, 98 + $add_edges, 99 + $rem_count, 100 + $rem_edges); 101 + } 102 + 103 + }
+2 -14
src/applications/repository/worker/commitmessageparser/PhabricatorRepositoryCommitMessageParserWorker.php
··· 448 448 foreach ($tasks as $task_id => $task) { 449 449 $xactions = array(); 450 450 451 - // TODO: Swap this for a real edge transaction once the weirdness in 452 - // Maniphest edges is sorted out. Currently, Maniphest reacts to an edge 453 - // edit on this edge. 454 - id(new PhabricatorEdgeEditor()) 455 - ->addEdge( 456 - $task->getPHID(), 457 - PhabricatorEdgeConfig::TYPE_TASK_HAS_COMMIT, 458 - $commit->getPHID()) 459 - ->save(); 460 - 461 - /* TODO: Do this instead of the above. 462 - 451 + $edge_type = ManiphestTaskHasCommitEdgeType::EDGECONST; 463 452 $xactions[] = id(new ManiphestTransaction()) 464 453 ->setTransactionType(PhabricatorTransactions::TYPE_EDGE) 465 - ->setMetadataValue('edge:type', $edge_task_has_commit) 454 + ->setMetadataValue('edge:type', $edge_type) 466 455 ->setNewValue( 467 456 array( 468 457 '+' => array( 469 458 $commit->getPHID() => $commit->getPHID(), 470 459 ), 471 460 )); 472 - */ 473 461 474 462 $status = $task_statuses[$task_id]; 475 463 if ($status) {
+2 -2
src/applications/search/controller/PhabricatorSearchAttachController.php
··· 290 290 291 291 $map = array( 292 292 $t_cmit => array( 293 - $t_task => PhabricatorEdgeConfig::TYPE_COMMIT_HAS_TASK, 293 + $t_task => DiffusionCommitHasTaskEdgeType::EDGECONST, 294 294 ), 295 295 $t_task => array( 296 - $t_cmit => PhabricatorEdgeConfig::TYPE_TASK_HAS_COMMIT, 296 + $t_cmit => ManiphestTaskHasCommitEdgeType::EDGECONST, 297 297 $t_task => PhabricatorEdgeConfig::TYPE_TASK_DEPENDS_ON_TASK, 298 298 $t_drev => ManiphestTaskHasRevisionEdgeType::EDGECONST, 299 299 $t_mock => PhabricatorEdgeConfig::TYPE_TASK_HAS_MOCK,
-14
src/infrastructure/edges/constants/PhabricatorEdgeConfig.php
··· 5 5 const TABLE_NAME_EDGE = 'edge'; 6 6 const TABLE_NAME_EDGEDATA = 'edgedata'; 7 7 8 - const TYPE_TASK_HAS_COMMIT = 1; 9 - const TYPE_COMMIT_HAS_TASK = 2; 10 - 11 8 const TYPE_TASK_DEPENDS_ON_TASK = 3; 12 9 const TYPE_TASK_DEPENDED_ON_BY_TASK = 4; 13 10 ··· 136 133 137 134 private static function getInverse($edge_type) { 138 135 static $map = array( 139 - self::TYPE_TASK_HAS_COMMIT => self::TYPE_COMMIT_HAS_TASK, 140 - self::TYPE_COMMIT_HAS_TASK => self::TYPE_TASK_HAS_COMMIT, 141 - 142 136 self::TYPE_TASK_DEPENDS_ON_TASK => self::TYPE_TASK_DEPENDED_ON_BY_TASK, 143 137 self::TYPE_TASK_DEPENDED_ON_BY_TASK => self::TYPE_TASK_DEPENDS_ON_TASK, 144 138 ··· 259 253 260 254 public static function getEditStringForEdgeType($type) { 261 255 switch ($type) { 262 - case self::TYPE_TASK_HAS_COMMIT: 263 256 case self::TYPE_PROJECT_HAS_COMMIT: 264 257 case self::TYPE_DREV_HAS_COMMIT: 265 258 return '%s edited commit(s), added %d: %s; removed %d: %s.'; 266 - case self::TYPE_COMMIT_HAS_TASK: 267 259 case self::TYPE_TASK_DEPENDS_ON_TASK: 268 260 case self::TYPE_TASK_DEPENDED_ON_BY_TASK: 269 261 case self::TYPE_MOCK_HAS_TASK: ··· 335 327 336 328 public static function getAddStringForEdgeType($type) { 337 329 switch ($type) { 338 - case self::TYPE_TASK_HAS_COMMIT: 339 330 case self::TYPE_PROJECT_HAS_COMMIT: 340 331 case self::TYPE_DREV_HAS_COMMIT: 341 332 return '%s added %d commit(s): %s.'; ··· 345 336 return '%s added %d dependencie(s): %s.'; 346 337 case self::TYPE_TASK_DEPENDED_ON_BY_TASK: 347 338 return '%s added %d blocked task(s): %s.'; 348 - case self::TYPE_COMMIT_HAS_TASK: 349 339 case self::TYPE_MOCK_HAS_TASK: 350 340 return '%s added %d task(s): %s.'; 351 341 case self::TYPE_DREV_DEPENDED_ON_BY_DREV: ··· 413 403 414 404 public static function getRemoveStringForEdgeType($type) { 415 405 switch ($type) { 416 - case self::TYPE_TASK_HAS_COMMIT: 417 406 case self::TYPE_PROJECT_HAS_COMMIT: 418 407 case self::TYPE_DREV_HAS_COMMIT: 419 408 return '%s removed %d commit(s): %s.'; ··· 421 410 return '%s removed %d blocking task(s): %s.'; 422 411 case self::TYPE_TASK_DEPENDED_ON_BY_TASK: 423 412 return '%s removed %d blocked task(s): %s.'; 424 - case self::TYPE_COMMIT_HAS_TASK: 425 413 case self::TYPE_MOCK_HAS_TASK: 426 414 return '%s removed %d task(s): %s.'; 427 415 case self::TYPE_DREV_DEPENDS_ON_DREV: ··· 488 476 489 477 public static function getFeedStringForEdgeType($type) { 490 478 switch ($type) { 491 - case self::TYPE_TASK_HAS_COMMIT: 492 479 case self::TYPE_PROJECT_HAS_COMMIT: 493 480 case self::TYPE_DREV_HAS_COMMIT: 494 481 return '%s updated commits of %s.'; 495 - case self::TYPE_COMMIT_HAS_TASK: 496 482 case self::TYPE_TASK_DEPENDS_ON_TASK: 497 483 case self::TYPE_TASK_DEPENDED_ON_BY_TASK: 498 484 case self::TYPE_MOCK_HAS_TASK: