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

Mostly modularize the Differential "update" transaction

Summary: Ref T13099. Move most of the "Update" logic to modular transactions

Test Plan: Created and updated revisions. Flushed the task queue. Grepped for `TYPE_UPDATE`. Reviewed update transactions in the timeline and feed.

Maniphest Tasks: T13099

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

+208 -208
+1 -1
resources/sql/autopatches/20140212.dx.1.armageddon.php
··· 75 75 76 76 if ($diff_id || $row['action'] == DifferentialAction::ACTION_UPDATE) { 77 77 $xactions[] = array( 78 - 'type' => DifferentialTransaction::TYPE_UPDATE, 78 + 'type' => DifferentialRevisionUpdateTransaction::TRANSACTIONTYPE, 79 79 'old' => null, 80 80 'new' => $diff_id, 81 81 );
+2
src/__phutil_library_map__.php
··· 598 598 'DifferentialRevisionTitleTransaction' => 'applications/differential/xaction/DifferentialRevisionTitleTransaction.php', 599 599 'DifferentialRevisionTransactionType' => 'applications/differential/xaction/DifferentialRevisionTransactionType.php', 600 600 'DifferentialRevisionUpdateHistoryView' => 'applications/differential/view/DifferentialRevisionUpdateHistoryView.php', 601 + 'DifferentialRevisionUpdateTransaction' => 'applications/differential/xaction/DifferentialRevisionUpdateTransaction.php', 601 602 'DifferentialRevisionViewController' => 'applications/differential/controller/DifferentialRevisionViewController.php', 602 603 'DifferentialRevisionVoidTransaction' => 'applications/differential/xaction/DifferentialRevisionVoidTransaction.php', 603 604 'DifferentialRevisionWrongStateTransaction' => 'applications/differential/xaction/DifferentialRevisionWrongStateTransaction.php', ··· 5822 5823 'DifferentialRevisionTitleTransaction' => 'DifferentialRevisionTransactionType', 5823 5824 'DifferentialRevisionTransactionType' => 'PhabricatorModularTransactionType', 5824 5825 'DifferentialRevisionUpdateHistoryView' => 'AphrontView', 5826 + 'DifferentialRevisionUpdateTransaction' => 'DifferentialRevisionTransactionType', 5825 5827 'DifferentialRevisionViewController' => 'DifferentialController', 5826 5828 'DifferentialRevisionVoidTransaction' => 'DifferentialRevisionTransactionType', 5827 5829 'DifferentialRevisionWrongStateTransaction' => 'DifferentialRevisionTransactionType',
+1 -1
src/applications/differential/conduit/DifferentialConduitAPIMethod.php
··· 58 58 59 59 $xactions = array(); 60 60 $xactions[] = array( 61 - 'type' => DifferentialRevisionEditEngine::KEY_UPDATE, 61 + 'type' => DifferentialRevisionUpdateTransaction::EDITKEY, 62 62 'value' => $diff->getPHID(), 63 63 ); 64 64
+3 -4
src/applications/differential/editor/DifferentialRevisionEditEngine.php
··· 7 7 8 8 const ENGINECONST = 'differential.revision'; 9 9 10 - const KEY_UPDATE = 'update'; 11 - 12 10 const ACTIONGROUP_REVIEW = 'review'; 13 11 const ACTIONGROUP_REVISION = 'revision'; 14 12 ··· 123 121 $fields = array(); 124 122 125 123 $fields[] = id(new PhabricatorHandlesEditField()) 126 - ->setKey(self::KEY_UPDATE) 124 + ->setKey(DifferentialRevisionUpdateTransaction::EDITKEY) 127 125 ->setLabel(pht('Update Diff')) 128 126 ->setDescription(pht('New diff to create or update the revision with.')) 129 127 ->setConduitDescription(pht('Create or update a revision with a diff.')) 130 128 ->setConduitTypeDescription(pht('PHID of the diff.')) 131 - ->setTransactionType(DifferentialTransaction::TYPE_UPDATE) 129 + ->setTransactionType( 130 + DifferentialRevisionUpdateTransaction::TRANSACTIONTYPE) 132 131 ->setHandleParameterType(new AphrontPHIDListHTTPParameterType()) 133 132 ->setSingleValue($diff_phid) 134 133 ->setIsConduitOnly(!$diff)
+9 -139
src/applications/differential/editor/DifferentialTransactionEditor.php
··· 33 33 } 34 34 35 35 public function getDiffUpdateTransaction(array $xactions) { 36 - $type_update = DifferentialTransaction::TYPE_UPDATE; 36 + $type_update = DifferentialRevisionUpdateTransaction::TRANSACTIONTYPE; 37 37 38 38 foreach ($xactions as $xaction) { 39 39 if ($xaction->getTransactionType() == $type_update) { ··· 76 76 $types[] = PhabricatorTransactions::TYPE_INLINESTATE; 77 77 78 78 $types[] = DifferentialTransaction::TYPE_INLINE; 79 - $types[] = DifferentialTransaction::TYPE_UPDATE; 80 79 81 80 return $types; 82 81 } ··· 88 87 switch ($xaction->getTransactionType()) { 89 88 case DifferentialTransaction::TYPE_INLINE: 90 89 return null; 91 - case DifferentialTransaction::TYPE_UPDATE: 92 - if ($this->getIsNewObject()) { 93 - return null; 94 - } else { 95 - return $object->getActiveDiff()->getPHID(); 96 - } 97 90 } 98 91 99 92 return parent::getCustomTransactionOldValue($object, $xaction); ··· 104 97 PhabricatorApplicationTransaction $xaction) { 105 98 106 99 switch ($xaction->getTransactionType()) { 107 - case DifferentialTransaction::TYPE_UPDATE: 108 - return $xaction->getNewValue(); 109 100 case DifferentialTransaction::TYPE_INLINE: 110 101 return null; 111 102 } ··· 120 111 switch ($xaction->getTransactionType()) { 121 112 case DifferentialTransaction::TYPE_INLINE: 122 113 return; 123 - case DifferentialTransaction::TYPE_UPDATE: 124 - if (!$this->getIsCloseByCommit()) { 125 - if ($object->isNeedsRevision() || 126 - $object->isChangePlanned() || 127 - $object->isAbandoned()) { 128 - $object->setModernRevisionStatus( 129 - DifferentialRevisionStatus::NEEDS_REVIEW); 130 - } 131 - } 132 - 133 - $diff = $this->requireDiff($xaction->getNewValue()); 134 - 135 - $this->updateRevisionLineCounts($object, $diff); 136 - 137 - if ($this->repositoryPHIDOverride !== false) { 138 - $object->setRepositoryPHID($this->repositoryPHIDOverride); 139 - } else { 140 - $object->setRepositoryPHID($diff->getRepositoryPHID()); 141 - } 142 - 143 - $object->attachActiveDiff($diff); 144 - $object->setActiveDiffPHID($diff->getPHID()); 145 - return; 146 114 } 147 115 148 116 return parent::applyCustomInternalTransaction($object, $xaction); ··· 196 164 // commit. 197 165 } else { 198 166 switch ($xaction->getTransactionType()) { 199 - case DifferentialTransaction::TYPE_UPDATE: 167 + case DifferentialRevisionUpdateTransaction::TRANSACTIONTYPE: 200 168 $downgrade_rejects = true; 201 169 if (!$is_sticky_accept) { 202 170 // If "sticky accept" is disabled, also downgrade the accepts. ··· 243 211 244 212 $is_commandeer = false; 245 213 switch ($xaction->getTransactionType()) { 246 - case DifferentialTransaction::TYPE_UPDATE: 214 + case DifferentialRevisionUpdateTransaction::TRANSACTIONTYPE: 247 215 if ($this->getIsCloseByCommit()) { 248 216 // Don't bother with any of this if this update is a side effect of 249 217 // commit detection. ··· 293 261 if (!$this->didExpandInlineState) { 294 262 switch ($xaction->getTransactionType()) { 295 263 case PhabricatorTransactions::TYPE_COMMENT: 296 - case DifferentialTransaction::TYPE_UPDATE: 264 + case DifferentialRevisionUpdateTransaction::TRANSACTIONTYPE: 297 265 case DifferentialTransaction::TYPE_INLINE: 298 266 $this->didExpandInlineState = true; 299 267 ··· 344 312 $reply->setHasReplies(1)->save(); 345 313 } 346 314 return; 347 - case DifferentialTransaction::TYPE_UPDATE: 348 - // Now that we're inside the transaction, do a final check. 349 - $diff = $this->requireDiff($xaction->getNewValue()); 350 - 351 - // TODO: It would be slightly cleaner to just revalidate this 352 - // transaction somehow using the same validation code, but that's 353 - // not easy to do at the moment. 354 - 355 - $revision_id = $diff->getRevisionID(); 356 - if ($revision_id && ($revision_id != $object->getID())) { 357 - throw new Exception( 358 - pht( 359 - 'Diff is already attached to another revision. You lost '. 360 - 'a race?')); 361 - } 362 - 363 - // TODO: This can race with diff updates, particularly those from 364 - // Harbormaster. See discussion in T8650. 365 - $diff->setRevisionID($object->getID()); 366 - $diff->save(); 367 - 368 - // If there are any outstanding buildables for this diff, tell 369 - // Harbormaster that their containers need to be updated. This is 370 - // common, because `arc` creates buildables so it can upload lint 371 - // and unit results. 372 - 373 - $buildables = id(new HarbormasterBuildableQuery()) 374 - ->setViewer(PhabricatorUser::getOmnipotentUser()) 375 - ->withManualBuildables(false) 376 - ->withBuildablePHIDs(array($diff->getPHID())) 377 - ->execute(); 378 - foreach ($buildables as $buildable) { 379 - $buildable->sendMessage( 380 - $this->getActor(), 381 - HarbormasterMessageType::BUILDABLE_CONTAINER, 382 - true); 383 - } 384 - 385 - return; 386 315 } 387 316 388 317 return parent::applyCustomExternalTransaction($object, $xaction); ··· 437 366 438 367 foreach ($xactions as $xaction) { 439 368 switch ($xaction->getTransactionType()) { 440 - case DifferentialTransaction::TYPE_UPDATE: 369 + case DifferentialRevisionUpdateTransaction::TRANSACTIONTYPE: 441 370 $diff = $this->requireDiff($xaction->getNewValue(), true); 442 371 443 372 // Update these denormalized index tables when we attach a new ··· 554 483 return $xactions; 555 484 } 556 485 557 - 558 - protected function validateTransaction( 559 - PhabricatorLiskDAO $object, 560 - $type, 561 - array $xactions) { 562 - 563 - $errors = parent::validateTransaction($object, $type, $xactions); 564 - 565 - $config_self_accept_key = 'differential.allow-self-accept'; 566 - $allow_self_accept = PhabricatorEnv::getEnvConfig($config_self_accept_key); 567 - 568 - foreach ($xactions as $xaction) { 569 - switch ($type) { 570 - case DifferentialTransaction::TYPE_UPDATE: 571 - $diff = $this->loadDiff($xaction->getNewValue()); 572 - if (!$diff) { 573 - $errors[] = new PhabricatorApplicationTransactionValidationError( 574 - $type, 575 - pht('Invalid'), 576 - pht('The specified diff does not exist.'), 577 - $xaction); 578 - } else if (($diff->getRevisionID()) && 579 - ($diff->getRevisionID() != $object->getID())) { 580 - $errors[] = new PhabricatorApplicationTransactionValidationError( 581 - $type, 582 - pht('Invalid'), 583 - pht( 584 - 'You can not update this revision to the specified diff, '. 585 - 'because the diff is already attached to another revision.'), 586 - $xaction); 587 - } 588 - break; 589 - } 590 - } 591 - 592 - return $errors; 593 - } 594 - 595 486 protected function sortTransactions(array $xactions) { 596 487 $xactions = parent::sortTransactions($xactions); 597 488 ··· 674 565 $action = parent::getMailAction($object, $xactions); 675 566 676 567 $strongest = $this->getStrongestAction($object, $xactions); 677 - $type_update = DifferentialTransaction::TYPE_UPDATE; 568 + $type_update = DifferentialRevisionUpdateTransaction::TRANSACTIONTYPE; 678 569 if ($strongest->getTransactionType() == $type_update) { 679 570 $show_lines = true; 680 571 } ··· 772 663 $update_xaction = null; 773 664 foreach ($xactions as $xaction) { 774 665 switch ($xaction->getTransactionType()) { 775 - case DifferentialTransaction::TYPE_UPDATE: 666 + case DifferentialRevisionUpdateTransaction::TRANSACTIONTYPE: 776 667 $update_xaction = $xaction; 777 668 break; 778 669 } ··· 1053 944 return $query->executeOne(); 1054 945 } 1055 946 1056 - private function requireDiff($phid, $need_changesets = false) { 947 + public function requireDiff($phid, $need_changesets = false) { 1057 948 $diff = $this->loadDiff($phid, $need_changesets); 1058 949 if (!$diff) { 1059 950 throw new Exception(pht('Diff "%s" does not exist!', $phid)); ··· 1274 1165 $has_update = false; 1275 1166 $has_commit = false; 1276 1167 1277 - $type_update = DifferentialTransaction::TYPE_UPDATE; 1168 + $type_update = DifferentialRevisionUpdateTransaction::TRANSACTIONTYPE; 1278 1169 foreach ($xactions as $xaction) { 1279 1170 if ($xaction->getTransactionType() != $type_update) { 1280 1171 continue; ··· 1719 1610 } 1720 1611 1721 1612 return true; 1722 - } 1723 - 1724 - private function updateRevisionLineCounts( 1725 - DifferentialRevision $revision, 1726 - DifferentialDiff $diff) { 1727 - 1728 - $revision->setLineCount($diff->getLineCount()); 1729 - 1730 - $conn = $revision->establishConnection('r'); 1731 - 1732 - $row = queryfx_one( 1733 - $conn, 1734 - 'SELECT SUM(addLines) A, SUM(delLines) D FROM %T 1735 - WHERE diffID = %d', 1736 - id(new DifferentialChangeset())->getTableName(), 1737 - $diff->getID()); 1738 - 1739 - if ($row) { 1740 - $revision->setAddedLineCount((int)$row['A']); 1741 - $revision->setRemovedLineCount((int)$row['D']); 1742 - } 1743 1613 } 1744 1614 1745 1615 private function requireReviewers(DifferentialRevision $revision) {
+3 -1
src/applications/differential/engine/DifferentialDiffExtractionEngine.php
··· 278 278 ->setNewValue($revision->getModernRevisionStatus()); 279 279 } 280 280 281 + $type_update = DifferentialRevisionUpdateTransaction::TRANSACTIONTYPE; 282 + 281 283 $xactions[] = id(new DifferentialTransaction()) 282 - ->setTransactionType(DifferentialTransaction::TYPE_UPDATE) 284 + ->setTransactionType($type_update) 283 285 ->setIgnoreOnNoEffect(true) 284 286 ->setNewValue($new_diff->getPHID()) 285 287 ->setMetadataValue('isCommitUpdate', true);
+2 -2
src/applications/differential/lipsum/PhabricatorDifferentialRevisionTestDataGenerator.php
··· 22 22 $revision->setTestPlan($this->generateDescription()); 23 23 24 24 $diff = $this->generateDiff($author); 25 + $type_update = DifferentialRevisionUpdateTransaction::TRANSACTIONTYPE; 25 26 26 27 $xactions = array(); 27 28 28 29 $xactions[] = id(new DifferentialTransaction()) 29 - ->setTransactionType(DifferentialTransaction::TYPE_UPDATE) 30 + ->setTransactionType($type_update) 30 31 ->setNewValue($diff->getPHID()); 31 - 32 32 33 33 id(new DifferentialTransactionEditor()) 34 34 ->setActor($author)
+1 -59
src/applications/differential/storage/DifferentialTransaction.php
··· 6 6 private $isCommandeerSideEffect; 7 7 8 8 const TYPE_INLINE = 'differential:inline'; 9 - const TYPE_UPDATE = 'differential:update'; 10 9 const TYPE_ACTION = 'differential:action'; 11 10 12 11 const MAILTAG_REVIEWERS = 'differential-reviewers'; ··· 75 74 $new = $this->getNewValue(); 76 75 77 76 switch ($this->getTransactionType()) { 78 - case self::TYPE_UPDATE: 79 - // Older versions of this transaction have an ID for the new value, 80 - // and/or do not record the old value. Only hide the transaction if 81 - // the new value is a PHID, indicating that this is a newer style 82 - // transaction. 83 - if ($old === null) { 84 - if (phid_get_type($new) == DifferentialDiffPHIDType::TYPECONST) { 85 - return true; 86 - } 87 - } 88 - break; 89 - 90 77 case DifferentialRevisionRequestReviewTransaction::TRANSACTIONTYPE: 91 78 // Don't hide the initial "X requested review: ..." transaction from 92 79 // mail or feed even when it occurs during creation. We need this ··· 139 126 } 140 127 } 141 128 break; 142 - case self::TYPE_UPDATE: 143 - if ($new) { 144 - $phids[] = $new; 145 - } 146 - break; 147 129 } 148 130 149 131 return $phids; ··· 153 135 switch ($this->getTransactionType()) { 154 136 case self::TYPE_ACTION: 155 137 return 3; 156 - case self::TYPE_UPDATE: 157 - return 2; 158 138 } 159 139 160 140 return parent::getActionStrength(); ··· 165 145 switch ($this->getTransactionType()) { 166 146 case self::TYPE_INLINE: 167 147 return pht('Commented On'); 168 - case self::TYPE_UPDATE: 169 - $old = $this->getOldValue(); 170 - if ($old === null) { 171 - return pht('Request'); 172 - } else { 173 - return pht('Updated'); 174 - } 175 148 case self::TYPE_ACTION: 176 149 $map = array( 177 150 DifferentialAction::ACTION_ACCEPT => pht('Accepted'), ··· 209 182 break; 210 183 } 211 184 break; 212 - case self::TYPE_UPDATE: 185 + case DifferentialRevisionUpdateTransaction::TRANSACTIONTYPE: 213 186 $old = $this->getOldValue(); 214 187 if ($old === null) { 215 188 $tags[] = self::MAILTAG_REVIEW_REQUEST; ··· 248 221 return pht( 249 222 '%s added inline comments.', 250 223 $author_handle); 251 - case self::TYPE_UPDATE: 252 - if ($this->getMetadataValue('isCommitUpdate')) { 253 - return pht( 254 - 'This revision was automatically updated to reflect the '. 255 - 'committed changes.'); 256 - } else if ($new) { 257 - // TODO: Migrate to PHIDs and use handles here? 258 - if (phid_get_type($new) == DifferentialDiffPHIDType::TYPECONST) { 259 - return pht( 260 - '%s updated this revision to %s.', 261 - $author_handle, 262 - $this->renderHandleLink($new)); 263 - } else { 264 - return pht( 265 - '%s updated this revision.', 266 - $author_handle); 267 - } 268 - } else { 269 - return pht( 270 - '%s updated this revision.', 271 - $author_handle); 272 - } 273 224 case self::TYPE_ACTION: 274 225 switch ($new) { 275 226 case DifferentialAction::ACTION_CLOSE: ··· 347 298 '%s added inline comments to %s.', 348 299 $author_link, 349 300 $object_link); 350 - case self::TYPE_UPDATE: 351 - return pht( 352 - '%s updated the diff for %s.', 353 - $author_link, 354 - $object_link); 355 301 case self::TYPE_ACTION: 356 302 switch ($new) { 357 303 case DifferentialAction::ACTION_ACCEPT: ··· 462 408 switch ($this->getTransactionType()) { 463 409 case self::TYPE_INLINE: 464 410 return 'fa-comment'; 465 - case self::TYPE_UPDATE: 466 - return 'fa-refresh'; 467 411 case self::TYPE_ACTION: 468 412 switch ($this->getNewValue()) { 469 413 case DifferentialAction::ACTION_CLOSE: ··· 526 470 527 471 public function getColor() { 528 472 switch ($this->getTransactionType()) { 529 - case self::TYPE_UPDATE: 530 - return PhabricatorTransactions::COLOR_SKY; 531 473 case self::TYPE_ACTION: 532 474 switch ($this->getNewValue()) { 533 475 case DifferentialAction::ACTION_CLOSE:
+185
src/applications/differential/xaction/DifferentialRevisionUpdateTransaction.php
··· 1 + <?php 2 + 3 + final class DifferentialRevisionUpdateTransaction 4 + extends DifferentialRevisionTransactionType { 5 + 6 + const TRANSACTIONTYPE = 'differential:update'; 7 + const EDITKEY = 'update'; 8 + 9 + public function generateOldValue($object) { 10 + return $object->getActiveDiffPHID(); 11 + } 12 + 13 + public function applyInternalEffects($object, $value) { 14 + $should_review = $this->shouldRequestReviewAfterUpdate($object); 15 + if ($should_review) { 16 + $object->setModernRevisionStatus( 17 + DifferentialRevisionStatus::NEEDS_REVIEW); 18 + } 19 + 20 + $editor = $this->getEditor(); 21 + $diff = $editor->requireDiff($value); 22 + 23 + $this->updateRevisionLineCounts($object, $diff); 24 + 25 + $object->setRepositoryPHID($diff->getRepositoryPHID()); 26 + $object->setActiveDiffPHID($diff->getPHID()); 27 + $object->attachActiveDiff($diff); 28 + } 29 + 30 + private function shouldRequestReviewAfterUpdate($object) { 31 + if ($this->isCommitUpdate()) { 32 + return false; 33 + } 34 + 35 + $should_update = 36 + $object->isNeedsRevision() || 37 + $object->isChangePlanned() || 38 + $object->isAbandoned(); 39 + if ($should_update) { 40 + return true; 41 + } 42 + 43 + return false; 44 + } 45 + 46 + public function applyExternalEffects($object, $value) { 47 + $editor = $this->getEditor(); 48 + $diff = $editor->requireDiff($value); 49 + 50 + // TODO: This can race with diff updates, particularly those from 51 + // Harbormaster. See discussion in T8650. 52 + $diff->setRevisionID($object->getID()); 53 + $diff->save(); 54 + 55 + // If there are any outstanding buildables for this diff, tell 56 + // Harbormaster that their containers need to be updated. This is 57 + // common, because `arc` creates buildables so it can upload lint 58 + // and unit results. 59 + 60 + $buildables = id(new HarbormasterBuildableQuery()) 61 + ->setViewer(PhabricatorUser::getOmnipotentUser()) 62 + ->withManualBuildables(false) 63 + ->withBuildablePHIDs(array($diff->getPHID())) 64 + ->execute(); 65 + foreach ($buildables as $buildable) { 66 + $buildable->sendMessage( 67 + $this->getActor(), 68 + HarbormasterMessageType::BUILDABLE_CONTAINER, 69 + true); 70 + } 71 + } 72 + 73 + public function getColor() { 74 + return 'sky'; 75 + } 76 + 77 + public function getIcon() { 78 + return 'fa-refresh'; 79 + } 80 + 81 + public function getActionName() { 82 + if ($this->isCreateTransaction()) { 83 + return pht('Request'); 84 + } else { 85 + return pht('Updated'); 86 + } 87 + } 88 + 89 + public function getActionStrength() { 90 + return 2; 91 + } 92 + 93 + public function getTitle() { 94 + $old = $this->getOldValue(); 95 + $new = $this->getNewValue(); 96 + 97 + if ($this->isCommitUpdate()) { 98 + return pht( 99 + 'This revision was automatically updated to reflect the '. 100 + 'committed changes.'); 101 + } 102 + 103 + // NOTE: Very, very old update transactions did not have a new value or 104 + // did not use a diff PHID as a new value. This was changed years ago, 105 + // but wasn't migrated. We might consider migrating if this causes issues. 106 + 107 + return pht( 108 + '%s updated this revision to %s.', 109 + $this->renderAuthor(), 110 + $this->renderNewHandle()); 111 + } 112 + 113 + public function getTitleForFeed() { 114 + return pht( 115 + '%s updated the diff for %s.', 116 + $this->renderAuthor(), 117 + $this->renderObject()); 118 + } 119 + 120 + public function validateTransactions($object, array $xactions) { 121 + $errors = array(); 122 + 123 + $diff_phid = null; 124 + foreach ($xactions as $xaction) { 125 + $diff_phid = $xaction->getNewValue(); 126 + 127 + $diff = id(new DifferentialDiffQuery()) 128 + ->withPHIDs(array($diff_phid)) 129 + ->setViewer($this->getActor()) 130 + ->executeOne(); 131 + if (!$diff) { 132 + $errors[] = $this->newInvalidError( 133 + pht( 134 + 'Specified diff ("%s") does not exist.', 135 + $diff_phid), 136 + $xaction); 137 + continue; 138 + } 139 + 140 + if ($diff->getRevisionID()) { 141 + $errors[] = $this->newInvalidError( 142 + pht( 143 + 'You can not update this revision with the specified diff ("%s") '. 144 + 'because the diff is already attached to another revision.', 145 + $diff_phid), 146 + $xaction); 147 + continue; 148 + } 149 + } 150 + 151 + if (!$diff_phid && !$object->getActiveDiffPHID()) { 152 + $errors[] = $this->newInvalidError( 153 + pht( 154 + 'You must specify an initial diff when creating a revision.')); 155 + } 156 + 157 + return $errors; 158 + } 159 + 160 + public function isCommitUpdate() { 161 + return (bool)$this->getMetadataValue('isCommitUpdate'); 162 + } 163 + 164 + private function updateRevisionLineCounts( 165 + DifferentialRevision $revision, 166 + DifferentialDiff $diff) { 167 + 168 + $revision->setLineCount($diff->getLineCount()); 169 + 170 + $conn = $revision->establishConnection('r'); 171 + 172 + $row = queryfx_one( 173 + $conn, 174 + 'SELECT SUM(addLines) A, SUM(delLines) D FROM %T 175 + WHERE diffID = %d', 176 + id(new DifferentialChangeset())->getTableName(), 177 + $diff->getID()); 178 + 179 + if ($row) { 180 + $revision->setAddedLineCount((int)$row['A']); 181 + $revision->setRemovedLineCount((int)$row['D']); 182 + } 183 + } 184 + 185 + }
+1 -1
src/applications/releeph/field/specification/ReleephDiffChurnFieldSpecification.php
··· 37 37 case PhabricatorTransactions::TYPE_COMMENT: 38 38 $comments++; 39 39 break; 40 - case DifferentialTransaction::TYPE_UPDATE: 40 + case DifferentialRevisionUpdateTransaction::TRANSACTIONTYPE: 41 41 $updates++; 42 42 break; 43 43 case DifferentialTransaction::TYPE_ACTION: