@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.

Provide an "Add blocking reviewer..." Herald action

Summary: Ref T1279. These reviewers don't actually create a logical block yet (that is, revisions still transition to "accepted" even in their presence), but this handles everything except that.

Test Plan: Added Herald rules and updated revisions; see screenshots.

Reviewers: btrahan

Reviewed By: btrahan

CC: aran

Maniphest Tasks: T1279

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

+52 -9
+1
src/applications/differential/constants/DifferentialReviewerStatus.php
··· 2 2 3 3 final class DifferentialReviewerStatus { 4 4 5 + const STATUS_BLOCKING = 'blocking'; 5 6 const STATUS_ADDED = 'added'; 6 7 const STATUS_ACCEPTED = 'accepted'; 7 8 const STATUS_REJECTED = 'rejected';
+22 -8
src/applications/differential/editor/DifferentialRevisionEditor.php
··· 276 276 'ccs' => $adapter->getCCsAddedByHerald(), 277 277 ); 278 278 $rem_ccs = $adapter->getCCsRemovedByHerald(); 279 + $blocking_reviewers = array_keys( 280 + $adapter->getBlockingReviewersAddedByHerald()); 279 281 } else { 280 282 $sub = array( 281 283 'rev' => array(), 282 284 'ccs' => array(), 283 285 ); 286 + $blocking_reviewers = array(); 284 287 } 285 288 286 289 // Remove any CCs which are prevented by Herald rules. ··· 314 317 $this->getActor(), 315 318 array_keys($add['rev']), 316 319 array_keys($rem['rev']), 317 - $this->getActorPHID()); 320 + $blocking_reviewers); 318 321 319 322 // We want to attribute new CCs to a "reasonPHID", representing the reason 320 323 // they were added. This is either a user (if some user explicitly CCs ··· 602 605 DifferentialRevision $revision, 603 606 PhabricatorUser $actor, 604 607 array $add_phids, 605 - array $remove_phids) { 608 + array $remove_phids, 609 + array $blocking_phids = array()) { 606 610 607 611 $reviewers = $revision->getReviewers(); 608 612 ··· 618 622 $editor = id(new PhabricatorEdgeEditor()) 619 623 ->setActor($actor); 620 624 621 - $options = array( 622 - 'data' => array( 623 - 'status' => DifferentialReviewerStatus::STATUS_ADDED 624 - ) 625 - ); 626 - 627 625 $reviewer_phids_map = array_fill_keys($reviewers, true); 628 626 627 + $blocking_phids = array_fuse($blocking_phids); 629 628 foreach ($add_phids as $phid) { 630 629 631 630 // Adding an already existing edge again would have cause memory loss 632 631 // That is, the previous state for that reviewer would be lost 633 632 if (isset($reviewer_phids_map[$phid])) { 633 + // TODO: If we're writing a blocking edge, we should overwrite an 634 + // existing weaker edge (like "added" or "commented"), just not a 635 + // stronger existing edge. 634 636 continue; 635 637 } 638 + 639 + if (isset($blocking_phids[$phid])) { 640 + $status = DifferentialReviewerStatus::STATUS_BLOCKING; 641 + } else { 642 + $status = DifferentialReviewerStatus::STATUS_ADDED; 643 + } 644 + 645 + $options = array( 646 + 'data' => array( 647 + 'status' => $status, 648 + ) 649 + ); 636 650 637 651 $editor->addEdge( 638 652 $revision->getPHID(),
+4
src/applications/differential/view/DifferentialReviewersView.php
··· 82 82 } 83 83 break; 84 84 85 + case DifferentialReviewerStatus::STATUS_BLOCKING: 86 + $item->setIcon('minus-red', pht('Blocking Review')); 87 + break; 88 + 85 89 default: 86 90 $item->setIcon('question-dark', pht('%s?', $reviewer->getStatus())); 87 91 break;
+7
src/applications/herald/adapter/HeraldAdapter.php
··· 53 53 const ACTION_ASSIGN_TASK = 'assigntask'; 54 54 const ACTION_ADD_PROJECTS = 'addprojects'; 55 55 const ACTION_ADD_REVIEWERS = 'addreviewers'; 56 + const ACTION_ADD_BLOCKING_REVIEWERS = 'addblockingreviewers'; 56 57 57 58 const VALUE_TEXT = 'text'; 58 59 const VALUE_NONE = 'none'; ··· 488 489 self::ACTION_ASSIGN_TASK => pht('Assign task to'), 489 490 self::ACTION_ADD_PROJECTS => pht('Add projects'), 490 491 self::ACTION_ADD_REVIEWERS => pht('Add reviewers'), 492 + self::ACTION_ADD_BLOCKING_REVIEWERS => pht('Add blocking reviewers'), 491 493 ); 492 494 case HeraldRuleTypeConfig::RULE_TYPE_PERSONAL: 493 495 return array( ··· 500 502 self::ACTION_ASSIGN_TASK => pht('Assign task to me'), 501 503 self::ACTION_ADD_PROJECTS => pht('Add projects'), 502 504 self::ACTION_ADD_REVIEWERS => pht('Add me as a reviewer'), 505 + self::ACTION_ADD_BLOCKING_REVIEWERS => 506 + pht('Add me as a blocking reviewer'), 503 507 ); 504 508 default: 505 509 throw new Exception("Unknown rule type '{$rule_type}'!"); ··· 525 529 case self::ACTION_REMOVE_CC: 526 530 case self::ACTION_AUDIT: 527 531 case self::ACTION_ASSIGN_TASK: 532 + case self::ACTION_ADD_REVIEWERS: 528 533 case self::ACTION_ADD_REVIEWERS: 529 534 // For personal rules, force these actions to target the rule owner. 530 535 $target = array($author_phid); ··· 623 628 case self::ACTION_AUDIT: 624 629 case self::ACTION_ASSIGN_TASK: 625 630 case self::ACTION_ADD_REVIEWERS: 631 + case self::ACTION_ADD_BLOCKING_REVIEWERS: 626 632 return self::VALUE_NONE; 627 633 case self::ACTION_FLAG: 628 634 return self::VALUE_FLAG_COLOR; ··· 647 653 case self::ACTION_ASSIGN_TASK: 648 654 return self::VALUE_USER; 649 655 case self::ACTION_ADD_REVIEWERS: 656 + case self::ACTION_ADD_BLOCKING_REVIEWERS: 650 657 return self::VALUE_USER_OR_PROJECT; 651 658 default: 652 659 throw new Exception("Unknown or invalid action '{$action}'.");
+17
src/applications/herald/adapter/HeraldDifferentialRevisionAdapter.php
··· 115 115 return $this->addReviewerPHIDs; 116 116 } 117 117 118 + public function getBlockingReviewersAddedByHerald() { 119 + return $this->blockingReviewerPHIDs; 120 + } 121 + 118 122 public function getPHID() { 119 123 return $this->revision->getPHID(); 120 124 } ··· 346 350 self::ACTION_REMOVE_CC, 347 351 self::ACTION_EMAIL, 348 352 self::ACTION_ADD_REVIEWERS, 353 + self::ACTION_ADD_BLOCKING_REVIEWERS, 349 354 self::ACTION_NOTHING, 350 355 ); 351 356 case HeraldRuleTypeConfig::RULE_TYPE_PERSONAL: ··· 355 360 self::ACTION_EMAIL, 356 361 self::ACTION_FLAG, 357 362 self::ACTION_ADD_REVIEWERS, 363 + self::ACTION_ADD_BLOCKING_REVIEWERS, 358 364 self::ACTION_NOTHING, 359 365 ); 360 366 } ··· 452 458 $effect, 453 459 true, 454 460 pht('Added reviewers.')); 461 + break; 462 + case self::ACTION_ADD_BLOCKING_REVIEWERS: 463 + // This adds reviewers normally, it just also marks them blocking. 464 + foreach ($effect->getTarget() as $phid) { 465 + $this->addReviewerPHIDs[$phid] = true; 466 + $this->blockingReviewerPHIDs[$phid] = true; 467 + } 468 + $result[] = new HeraldApplyTranscript( 469 + $effect, 470 + true, 471 + pht('Added blocking reviewers.')); 455 472 break; 456 473 default: 457 474 throw new Exception("No rules to handle action '{$action}'.");
+1 -1
src/applications/herald/storage/HeraldRule.php
··· 13 13 protected $repetitionPolicy; 14 14 protected $ruleType; 15 15 16 - protected $configVersion = 13; 16 + protected $configVersion = 14; 17 17 18 18 private $ruleApplied = self::ATTACHABLE; // phids for which this rule has been applied 19 19 private $validAuthor = self::ATTACHABLE;