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

Update "AffectedPath" table when a revision's repository changes

Summary:
Ref T13639. There's currently a hard-to-hit bug where editing the "Repository" of a revision doesn't update this index.

Instead: update the index on repository change, not just diff update.

Test Plan:
- Updated a revision, used debug view to see index update.
- Changed repository on a revision, used debug view to see index update.

Maniphest Tasks: T13639

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

+40 -12
+40 -12
src/applications/differential/editor/DifferentialTransactionEditor.php
··· 340 340 pht('Failed to load revision from transaction finalization.')); 341 341 } 342 342 343 + $active_diff = $new_revision->getActiveDiff(); 344 + $new_diff_phid = $active_diff->getPHID(); 345 + 343 346 $object->attachReviewers($new_revision->getReviewers()); 344 - $object->attachActiveDiff($new_revision->getActiveDiff()); 347 + $object->attachActiveDiff($active_diff); 345 348 $object->attachRepository($new_revision->getRepository()); 346 349 350 + $has_new_diff = false; 351 + $should_index_paths = false; 352 + $should_index_hashes = false; 353 + $need_changesets = false; 354 + 347 355 foreach ($xactions as $xaction) { 348 356 switch ($xaction->getTransactionType()) { 349 357 case DifferentialRevisionUpdateTransaction::TRANSACTIONTYPE: 350 - $diff = $this->requireDiff($xaction->getNewValue(), true); 351 - 352 - $this->ownersDiff = $diff; 353 - $this->ownersChangesets = $diff->getChangesets(); 358 + $need_changesets = true; 354 359 355 - // Update these denormalized index tables when we attach a new 356 - // diff to a revision. 360 + $new_diff_phid = $xaction->getNewValue(); 361 + $has_new_diff = true; 357 362 358 - $this->updateRevisionHashTable($object, $diff); 363 + $should_index_paths = true; 364 + $should_index_hashes = true; 365 + break; 366 + case DifferentialRevisionRepositoryTransaction::TRANSACTIONTYPE: 367 + // The "AffectedPath" table denormalizes the repository, so we 368 + // want to update the index if the repository changes. 359 369 360 - id(new DifferentialAffectedPathEngine()) 361 - ->setRevision($object) 362 - ->setDiff($diff) 363 - ->updateAffectedPaths(); 370 + $need_changesets = true; 364 371 372 + $should_index_paths = true; 365 373 break; 374 + } 375 + } 376 + 377 + if ($need_changesets) { 378 + $new_diff = $this->requireDiff($new_diff_phid, true); 379 + 380 + if ($should_index_paths) { 381 + id(new DifferentialAffectedPathEngine()) 382 + ->setRevision($object) 383 + ->setDiff($new_diff) 384 + ->updateAffectedPaths(); 385 + } 386 + 387 + if ($should_index_hashes) { 388 + $this->updateRevisionHashTable($object, $new_diff); 389 + } 390 + 391 + if ($has_new_diff) { 392 + $this->ownersDiff = $new_diff; 393 + $this->ownersChangesets = $new_diff->getChangesets(); 366 394 } 367 395 } 368 396