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

Use DifferentialRevisionEditor in lipsum

Summary: Ref T2222.

Test Plan: Generated revisions with `bin/lipsum`.

Reviewers: btrahan

Reviewed By: btrahan

CC: aran

Maniphest Tasks: T2222

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

+71 -45
+16
src/applications/differential/editor/DifferentialTransactionEditor.php
··· 896 896 return $phids; 897 897 } 898 898 899 + protected function getMailAction( 900 + PhabricatorLiskDAO $object, 901 + array $xactions) { 902 + $action = parent::getMailAction($object, $xactions); 903 + 904 + $strongest = $this->getStrongestAction($object, $xactions); 905 + switch ($strongest->getTransactionType()) { 906 + case DifferentialTransaction::TYPE_UPDATE: 907 + $count = new PhutilNumber($object->getLineCount()); 908 + $action = pht('%s, %s line(s)', $action, $count); 909 + break; 910 + } 911 + 912 + return $action; 913 + } 914 + 899 915 protected function getMailSubjectPrefix() { 900 916 return PhabricatorEnv::getEnvConfig('metamta.differential.subject-prefix'); 901 917 }
+21 -27
src/applications/differential/lipsum/PhabricatorDifferentialRevisionTestDataGenerator.php
··· 6 6 public function generate() { 7 7 $author = $this->loadPhabrictorUser(); 8 8 $authorPHID = $author->getPHID(); 9 + 9 10 $revision = DifferentialRevision::initializeNewRevision($author); 11 + $revision->attachReviewerStatus(array()); 12 + $revision->attachActiveDiff(null); 13 + 14 + // This could be a bit richer and more formal than it is. 10 15 $revision->setTitle($this->generateTitle()); 11 16 $revision->setSummary($this->generateDescription()); 12 17 $revision->setTestPlan($this->generateDescription()); 13 - $revision->loadRelationships(); 14 - $aux_fields = $this->loadAuxiliaryFields($author, $revision); 18 + 15 19 $diff = $this->generateDiff($author); 16 - // Add Diff 17 - $editor = new DifferentialRevisionEditor($revision); 18 - $editor->setActor($author); 19 - $editor->addDiff($diff, $this->generateDescription()); 20 - $editor->setAuxiliaryFields($aux_fields); 21 - $editor->save(); 22 20 23 - // TODO: After T2222, it would be nice to revisit this and expand the 24 - // functionality. 21 + $xactions = array(); 25 22 26 - return $revision->save(); 23 + $xactions[] = id(new DifferentialTransaction()) 24 + ->setTransactionType(DifferentialTransaction::TYPE_UPDATE) 25 + ->setNewValue($diff->getPHID()); 26 + 27 + $content_source = PhabricatorContentSource::newForSource( 28 + PhabricatorContentSource::SOURCE_LIPSUM, 29 + array()); 30 + 31 + id(new DifferentialTransactionEditor()) 32 + ->setActor($author) 33 + ->setContentSource($content_source) 34 + ->applyTransactions($revision, $xactions); 35 + 36 + return $revision; 27 37 } 28 38 29 39 public function getCCPHIDs() { ··· 90 100 } 91 101 } 92 102 return implode($newcode2, "\n"); 93 - } 94 - 95 - private function loadAuxiliaryFields($user, DifferentialRevision $revision) { 96 - $aux_fields = DifferentialFieldSelector::newSelector() 97 - ->getFieldSpecifications(); 98 - foreach ($aux_fields as $key => $aux_field) { 99 - $aux_field->setRevision($revision); 100 - if (!$aux_field->shouldAppearOnEdit()) { 101 - unset($aux_fields[$key]); 102 - } else { 103 - $aux_field->setUser($user); 104 - } 105 - } 106 - return DifferentialAuxiliaryField::loadFromStorage( 107 - $revision, 108 - $aux_fields); 109 103 } 110 104 111 105 }
+6 -1
src/applications/differential/storage/DifferentialTransaction.php
··· 105 105 case self::TYPE_INLINE: 106 106 return pht('Commented On'); 107 107 case self::TYPE_UPDATE: 108 - return pht('Updated'); 108 + $old = $this->getOldValue(); 109 + if ($old === null) { 110 + return pht('Request'); 111 + } else { 112 + return pht('Updated'); 113 + } 109 114 case self::TYPE_ACTION: 110 115 $map = array( 111 116 DifferentialAction::ACTION_ACCEPT => pht('Accepted'),
+11 -15
src/applications/lipsum/management/PhabricatorLipsumGenerateWorkflow.php
··· 6 6 protected function didConstruct() { 7 7 $this 8 8 ->setName('generate') 9 - ->setExamples('**generate** __key__') 9 + ->setExamples('**generate**') 10 10 ->setSynopsis('Generate some lipsum.') 11 11 ->setArguments( 12 12 array( ··· 62 62 while (true) { 63 63 $type = $supported_types[array_rand($supported_types)]; 64 64 $admin = $this->getViewer(); 65 - try { 66 - $taskgen = newv($type, array()); 67 - $object = $taskgen->generate(); 68 - $handle = id(new PhabricatorHandleQuery()) 69 - ->setViewer($admin) 70 - ->withPHIDs(array($object->getPHID())) 71 - ->executeOne(); 72 - echo "Generated ".$handle->getTypeName().": ". 73 - $handle->getFullName()."\n"; 74 - } catch (PhutilMissingSymbolException $ex) { 75 - throw new PhutilArgumentUsageException( 76 - "Cannot generate content of type ".$type. 77 - " because the class does not exist."); 78 - } 65 + 66 + $taskgen = newv($type, array()); 67 + $object = $taskgen->generate(); 68 + $handle = id(new PhabricatorHandleQuery()) 69 + ->setViewer($admin) 70 + ->withPHIDs(array($object->getPHID())) 71 + ->executeOne(); 72 + echo "Generated ".$handle->getTypeName().": ". 73 + $handle->getFullName()."\n"; 74 + 79 75 usleep(200000); 80 76 } 81 77 }
+2
src/applications/metamta/contentsource/PhabricatorContentSource.php
··· 13 13 const SOURCE_HERALD = 'herald'; 14 14 const SOURCE_LEGACY = 'legacy'; 15 15 const SOURCE_DAEMON = 'daemon'; 16 + const SOURCE_LIPSUM = 'lipsum'; 16 17 17 18 private $source; 18 19 private $params = array(); ··· 74 75 self::SOURCE_LEGACY => pht('Legacy'), 75 76 self::SOURCE_HERALD => pht('Herald'), 76 77 self::SOURCE_DAEMON => pht('Daemons'), 78 + self::SOURCE_LIPSUM => pht('Lipsum'), 77 79 self::SOURCE_UNKNOWN => pht('Old World'), 78 80 ); 79 81 }
+10 -2
src/applications/transactions/editor/PhabricatorApplicationTransactionEditor.php
··· 1649 1649 $body = $this->buildMailBody($object, $xactions); 1650 1650 1651 1651 $mail_tags = $this->getMailTags($object, $xactions); 1652 - 1653 - $action = $this->getStrongestAction($object, $xactions)->getActionName(); 1652 + $action = $this->getMailAction($object, $xactions); 1654 1653 1655 1654 $template 1656 1655 ->setFrom($this->requireActor()->getPHID()) ··· 1743 1742 } 1744 1743 1745 1744 return array_mergev($tags); 1745 + } 1746 + 1747 + /** 1748 + * @task mail 1749 + */ 1750 + protected function getMailAction( 1751 + PhabricatorLiskDAO $object, 1752 + array $xactions) { 1753 + return $this->getStrongestAction($object, $xactions)->getActionName(); 1746 1754 } 1747 1755 1748 1756
+5
src/infrastructure/internationalization/translation/PhabricatorBaseEnglishTranslation.php
··· 851 851 '%d older changes are hidden.', 852 852 ), 853 853 854 + '%s, %d line(s)' => array( 855 + '%s, %d line', 856 + '%s, %d lines', 857 + ), 858 + 854 859 ); 855 860 } 856 861