@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

lipsum revisions: fix missing 'created this revision' (adopt transactions)

Summary:
When generating test revisions, the 'created this revision' is not missing anymore,
and the nonsense 'updated this revision to Diff 123' is not shown anymore,
since this is a creation, and not an update.

Basically we avoid to manually call setters, and we use transactions instead.

Closes T16232

Test Plan:
./bin/lipsum generate revisions

Enjoy the new 'created this revision'.

You also don't see anymore the nonsense 'updated this revision'.

Enjoy the fake revisions that are now more similar to the real ones.

Reviewers: O1 Blessed Committers, aklapper

Reviewed By: O1 Blessed Committers, aklapper

Subscribers: aklapper, tobiaswiese, Matthew, Cigaryno

Maniphest Tasks: T16232

Differential Revision: https://we.phorge.it/D26286

+23 -10
+23 -10
src/applications/differential/lipsum/PhabricatorDifferentialRevisionTestDataGenerator.php
··· 13 13 $author = $this->loadPhabricatorUser(); 14 14 15 15 $revision = DifferentialRevision::initializeNewRevision($author); 16 - $revision->attachReviewers(array()); 17 - $revision->attachActiveDiff(null); 18 - 19 - // This could be a bit richer and more formal than it is. 20 - $revision->setTitle($this->generateTitle()); 21 - $revision->setSummary($this->generateDescription()); 22 - $revision->setTestPlan($this->generateDescription()); 23 16 24 17 $diff = $this->generateDiff($author); 18 + $type_create = PhabricatorTransactions::TYPE_CREATE; 25 19 $type_update = DifferentialRevisionUpdateTransaction::TRANSACTIONTYPE; 20 + $type_title = DifferentialRevisionTitleTransaction::TRANSACTIONTYPE; 21 + $type_summary = DifferentialRevisionSummaryTransaction::TRANSACTIONTYPE; 22 + $type_testplan = DifferentialRevisionTestPlanTransaction::TRANSACTIONTYPE; 26 23 24 + // Create associative array of transaction types and their new value. 25 + $changes = array(); 26 + $changes[$type_create] = null; // Value not needed here. 27 + 28 + // This could be a bit richer and more formal than it is. 29 + $changes[$type_update] = $diff->getPHID(); 30 + $changes[$type_title] = $this->generateTitle(); 31 + $changes[$type_summary] = $this->generateDescription(); 32 + $changes[$type_testplan] = $this->generateDescription(); 33 + 34 + // Create transactions. 27 35 $xactions = array(); 36 + foreach ($changes as $type => $new_value) { 37 + $xaction = new DifferentialTransaction(); 38 + $xaction->setTransactionType($type); 39 + if ($new_value !== null) { 40 + $xaction->setNewValue($new_value); 41 + } 28 42 29 - $xactions[] = id(new DifferentialTransaction()) 30 - ->setTransactionType($type_update) 31 - ->setNewValue($diff->getPHID()); 43 + $xactions[] = $xaction; 44 + } 32 45 33 46 id(new DifferentialTransactionEditor()) 34 47 ->setActor($author)