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

Differential - make DifferentialDiffEditor into a real transaction editor.

Summary: Ref T6237. This sets us up for some future work like T6152, T6200 and generally cleaning up this workflow a bit. Tried to do as little as possible so not exposing transaction view yet. (Though that timeline is going to be a little funky in the common case of just the lone create transaction.)

Test Plan: made a diff from web ui and it worked. made a herald rule to block certain diffs then tried to make such a diff and saw UI letting me know i was blocked

Reviewers: epriestley

Reviewed By: epriestley

Subscribers: Korvin, epriestley

Maniphest Tasks: T6237

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

+363 -130
+19
resources/sql/autopatches/20141118.diffxaction.sql
··· 1 + CREATE TABLE {$NAMESPACE}_differential.differential_difftransaction ( 2 + id INT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY, 3 + phid VARBINARY(64) NOT NULL, 4 + authorPHID VARBINARY(64) NOT NULL, 5 + objectPHID VARBINARY(64) NOT NULL, 6 + viewPolicy VARBINARY(64) NOT NULL, 7 + editPolicy VARBINARY(64) NOT NULL, 8 + commentPHID VARBINARY(64), 9 + commentVersion INT UNSIGNED NOT NULL, 10 + transactionType VARCHAR(32) COLLATE {$COLLATE_TEXT} NOT NULL, 11 + oldValue LONGTEXT COLLATE {$COLLATE_TEXT} NOT NULL, 12 + newValue LONGTEXT COLLATE {$COLLATE_TEXT} NOT NULL, 13 + contentSource LONGTEXT COLLATE {$COLLATE_TEXT} NOT NULL, 14 + metadata LONGTEXT COLLATE {$COLLATE_TEXT} NOT NULL, 15 + dateCreated INT UNSIGNED NOT NULL, 16 + dateModified INT UNSIGNED NOT NULL, 17 + UNIQUE KEY `key_phid` (`phid`), 18 + KEY `key_object` (`objectPHID`) 19 + ) ENGINE=InnoDB, COLLATE {$COLLATE_TEXT};
+3 -1
src/__phutil_library_map__.php
··· 325 325 'DifferentialDiffQuery' => 'applications/differential/query/DifferentialDiffQuery.php', 326 326 'DifferentialDiffTableOfContentsView' => 'applications/differential/view/DifferentialDiffTableOfContentsView.php', 327 327 'DifferentialDiffTestCase' => 'applications/differential/storage/__tests__/DifferentialDiffTestCase.php', 328 + 'DifferentialDiffTransaction' => 'applications/differential/storage/DifferentialDiffTransaction.php', 328 329 'DifferentialDiffViewController' => 'applications/differential/controller/DifferentialDiffViewController.php', 329 330 'DifferentialDoorkeeperRevisionFeedStoryPublisher' => 'applications/differential/doorkeeper/DifferentialDoorkeeperRevisionFeedStoryPublisher.php', 330 331 'DifferentialDraft' => 'applications/differential/storage/DifferentialDraft.php', ··· 3313 3314 ), 3314 3315 'DifferentialDiffCreateController' => 'DifferentialController', 3315 3316 'DifferentialDiffCreationRejectException' => 'Exception', 3316 - 'DifferentialDiffEditor' => 'PhabricatorEditor', 3317 + 'DifferentialDiffEditor' => 'PhabricatorApplicationTransactionEditor', 3317 3318 'DifferentialDiffPHIDType' => 'PhabricatorPHIDType', 3318 3319 'DifferentialDiffProperty' => 'DifferentialDAO', 3319 3320 'DifferentialDiffQuery' => 'PhabricatorCursorPagedPolicyAwareQuery', 3320 3321 'DifferentialDiffTableOfContentsView' => 'AphrontView', 3321 3322 'DifferentialDiffTestCase' => 'ArcanistPhutilTestCase', 3323 + 'DifferentialDiffTransaction' => 'PhabricatorApplicationTransaction', 3322 3324 'DifferentialDiffViewController' => 'DifferentialController', 3323 3325 'DifferentialDoorkeeperRevisionFeedStoryPublisher' => 'DoorkeeperFeedStoryPublisher', 3324 3326 'DifferentialDraft' => 'DifferentialDAO',
+42 -52
src/applications/differential/conduit/DifferentialCreateDiffConduitAPIMethod.php
··· 70 70 } 71 71 72 72 $diff = DifferentialDiff::newFromRawChanges($changes); 73 - $diff->setSourcePath($request->getValue('sourcePath')); 74 - $diff->setSourceMachine($request->getValue('sourceMachine')); 75 73 76 - $diff->setBranch($request->getValue('branch')); 77 - $diff->setCreationMethod($request->getValue('creationMethod')); 78 - $diff->setAuthorPHID($viewer->getPHID()); 79 - $diff->setBookmark($request->getValue('bookmark')); 80 - 81 - // TODO: Remove this eventually; for now continue writing the UUID. Note 82 - // that we'll overwrite it below if we identify a repository, and `arc` 83 - // no longer sends it. This stuff is retained for backward compatibility. 84 - $diff->setRepositoryUUID($request->getValue('repositoryUUID')); 74 + // TODO: Remove repository UUID eventually; for now continue writing 75 + // the UUID. Note that we'll overwrite it below if we identify a 76 + // repository, and `arc` no longer sends it. This stuff is retained for 77 + // backward compatibility. 85 78 79 + $repository_uuid = $request->getValue('repositoryUUID'); 86 80 $repository_phid = $request->getValue('repositoryPHID'); 87 81 if ($repository_phid) { 88 82 $repository = id(new PhabricatorRepositoryQuery()) ··· 90 84 ->withPHIDs(array($repository_phid)) 91 85 ->executeOne(); 92 86 if ($repository) { 93 - $diff->setRepositoryPHID($repository->getPHID()); 94 - $diff->setRepositoryUUID($repository->getUUID()); 87 + $repository_phid = $repository->getPHID(); 88 + $repository_uuid = $repository->getUUID(); 95 89 } 96 90 } 97 91 98 - $system = $request->getValue('sourceControlSystem'); 99 - $diff->setSourceControlSystem($system); 100 - $diff->setSourceControlPath($request->getValue('sourceControlPath')); 101 - $diff->setSourceControlBaseRevision( 102 - $request->getValue('sourceControlBaseRevision')); 103 - 104 92 $project_name = $request->getValue('arcanistProject'); 105 93 $project_phid = null; 106 94 if ($project_name) { ··· 116 104 $project_phid = $arcanist_project->getPHID(); 117 105 } 118 106 119 - $diff->setArcanistProjectPHID($project_phid); 120 - 121 107 switch ($request->getValue('lintStatus')) { 122 108 case 'skip': 123 - $diff->setLintStatus(DifferentialLintStatus::LINT_SKIP); 109 + $lint_status = DifferentialLintStatus::LINT_SKIP; 124 110 break; 125 111 case 'okay': 126 - $diff->setLintStatus(DifferentialLintStatus::LINT_OKAY); 112 + $lint_status = DifferentialLintStatus::LINT_OKAY; 127 113 break; 128 114 case 'warn': 129 - $diff->setLintStatus(DifferentialLintStatus::LINT_WARN); 115 + $lint_status = DifferentialLintStatus::LINT_WARN; 130 116 break; 131 117 case 'fail': 132 - $diff->setLintStatus(DifferentialLintStatus::LINT_FAIL); 118 + $lint_status = DifferentialLintStatus::LINT_FAIL; 133 119 break; 134 120 case 'postponed': 135 - $diff->setLintStatus(DifferentialLintStatus::LINT_POSTPONED); 121 + $lint_status = DifferentialLintStatus::LINT_POSTPONED; 136 122 break; 137 123 case 'none': 138 124 default: 139 - $diff->setLintStatus(DifferentialLintStatus::LINT_NONE); 125 + $lint_status = DifferentialLintStatus::LINT_NONE; 140 126 break; 141 127 } 142 128 143 129 switch ($request->getValue('unitStatus')) { 144 130 case 'skip': 145 - $diff->setUnitStatus(DifferentialUnitStatus::UNIT_SKIP); 131 + $unit_status = DifferentialUnitStatus::UNIT_SKIP; 146 132 break; 147 133 case 'okay': 148 - $diff->setUnitStatus(DifferentialUnitStatus::UNIT_OKAY); 134 + $unit_status = DifferentialUnitStatus::UNIT_OKAY; 149 135 break; 150 136 case 'warn': 151 - $diff->setUnitStatus(DifferentialUnitStatus::UNIT_WARN); 137 + $unit_status = DifferentialUnitStatus::UNIT_WARN; 152 138 break; 153 139 case 'fail': 154 - $diff->setUnitStatus(DifferentialUnitStatus::UNIT_FAIL); 140 + $unit_status = DifferentialUnitStatus::UNIT_FAIL; 155 141 break; 156 142 case 'postponed': 157 - $diff->setUnitStatus(DifferentialUnitStatus::UNIT_POSTPONED); 143 + $unit_status = DifferentialUnitStatus::UNIT_POSTPONED; 158 144 break; 159 145 case 'none': 160 146 default: 161 - $diff->setUnitStatus(DifferentialUnitStatus::UNIT_NONE); 147 + $unit_status = DifferentialUnitStatus::UNIT_NONE; 162 148 break; 163 149 } 164 150 151 + $diff_data_dict = array( 152 + 'sourcePath' => $request->getValue('sourcePath'), 153 + 'sourceMachine' => $request->getValue('sourceMachine'), 154 + 'branch' => $request->getValue('branch'), 155 + 'creationMethod' => $request->getValue('creationMethod'), 156 + 'authorPHID' => $viewer->getPHID(), 157 + 'bookmark' => $request->getValue('bookmark'), 158 + 'repositoryUUID' => $repository_uuid, 159 + 'repositoryPHID' => $repository_phid, 160 + 'sourceControlSystem' => $request->getValue('sourceControlSystem'), 161 + 'sourceControlPath' => $request->getValue('sourceControlPath'), 162 + 'sourceControlBaseRevision' => 163 + $request->getValue('sourceControlBaseRevision'), 164 + 'arcanistProjectPHID' => $project_phid, 165 + 'lintStatus' => $lint_status, 166 + 'unitStatus' => $unit_status,); 167 + 168 + $xactions = array(id(new DifferentialTransaction()) 169 + ->setTransactionType(DifferentialDiffTransaction::TYPE_DIFF_CREATE) 170 + ->setNewValue($diff_data_dict),); 171 + 165 172 id(new DifferentialDiffEditor()) 166 173 ->setActor($viewer) 167 - ->setContentSource( 168 - PhabricatorContentSource::newFromConduitRequest($request)) 169 - ->saveDiff($diff); 170 - 171 - // If we didn't get an explicit `repositoryPHID` (which means the client is 172 - // old, or couldn't figure out which repository the working copy belongs 173 - // to), apply heuristics to try to figure it out. 174 - 175 - if (!$repository_phid) { 176 - $repository = id(new DifferentialRepositoryLookup()) 177 - ->setDiff($diff) 178 - ->setViewer($viewer) 179 - ->lookupRepository(); 180 - if ($repository) { 181 - $diff->setRepositoryPHID($repository->getPHID()); 182 - $diff->setRepositoryUUID($repository->getUUID()); 183 - $diff->save(); 184 - } 185 - } 174 + ->setContentSourceFromConduitRequest($request) 175 + ->applyTransactions($diff, $xactions); 186 176 187 177 $path = '/differential/diff/'.$diff->getID().'/'; 188 178 $uri = PhabricatorEnv::getURI($path);
+11 -13
src/applications/differential/conduit/DifferentialCreateRawDiffConduitAPIMethod.php
··· 41 41 throw new Exception( 42 42 pht('No such repository "%s"!', $repository_phid)); 43 43 } 44 - } else { 45 - $repository = null; 46 44 } 47 45 48 46 $parser = new ArcanistDiffParser(); 49 47 $changes = $parser->parseDiff($raw_diff); 50 48 $diff = DifferentialDiff::newFromRawChanges($changes); 51 49 52 - $diff->setLintStatus(DifferentialLintStatus::LINT_SKIP); 53 - $diff->setUnitStatus(DifferentialUnitStatus::UNIT_SKIP); 54 - 55 - $diff->setAuthorPHID($viewer->getPHID()); 56 - $diff->setCreationMethod('web'); 50 + $diff_data_dict = array( 51 + 'creationMethod' => 'web', 52 + 'authorPHID' => $viewer->getPHID(), 53 + 'repositoryPHID' => $repository_phid, 54 + 'lintStatus' => DifferentialLintStatus::LINT_SKIP, 55 + 'unitStatus' => DifferentialUnitStatus::UNIT_SKIP,); 57 56 58 - if ($repository) { 59 - $diff->setRepositoryPHID($repository->getPHID()); 60 - } 57 + $xactions = array(id(new DifferentialTransaction()) 58 + ->setTransactionType(DifferentialDiffTransaction::TYPE_DIFF_CREATE) 59 + ->setNewValue($diff_data_dict),); 61 60 62 61 id(new DifferentialDiffEditor()) 63 62 ->setActor($viewer) 64 - ->setContentSource( 65 - PhabricatorContentSource::newFromConduitRequest($request)) 66 - ->saveDiff($diff); 63 + ->setContentSourceFromConduitRequest($request) 64 + ->applyTransactions($diff, $xactions); 67 65 68 66 return $this->buildDiffInfoDictionary($diff); 69 67 }
+16 -10
src/applications/differential/controller/DifferentialDiffCreateController.php
··· 6 6 7 7 $request = $this->getRequest(); 8 8 9 + $diff = null; 9 10 $errors = array(); 10 11 $e_diff = null; 11 12 $e_file = null; 13 + $validation_exception = null; 12 14 if ($request->isFormPost()) { 13 - $diff = null; 14 15 15 16 if ($request->getFileExists('diff-file')) { 16 17 $diff = PhabricatorFile::readUploadedFileData($_FILES['diff-file']); ··· 27 28 } 28 29 29 30 if (!$errors) { 30 - $call = new ConduitCall( 31 - 'differential.createrawdiff', 32 - array( 33 - 'diff' => $diff, 31 + try { 32 + $call = new ConduitCall( 33 + 'differential.createrawdiff', 34 + array( 35 + 'diff' => $diff, 34 36 )); 35 - $call->setUser($request->getUser()); 36 - $result = $call->execute(); 37 - 38 - $path = id(new PhutilURI($result['uri']))->getPath(); 39 - return id(new AphrontRedirectResponse())->setURI($path); 37 + $call->setUser($request->getUser()); 38 + $result = $call->execute(); 39 + $path = id(new PhutilURI($result['uri']))->getPath(); 40 + return id(new AphrontRedirectResponse())->setURI($path); 41 + } catch (PhabricatorApplicationTransactionValidationException $ex) { 42 + $validation_exception = $ex; 43 + } 40 44 } 41 45 } 42 46 ··· 69 73 id(new AphrontFormTextAreaControl()) 70 74 ->setLabel(pht('Raw Diff')) 71 75 ->setName('diff') 76 + ->setValue($diff) 72 77 ->setHeight(AphrontFormTextAreaControl::HEIGHT_VERY_TALL) 73 78 ->setError($e_diff)) 74 79 ->appendChild( ··· 83 88 84 89 $form_box = id(new PHUIObjectBoxView()) 85 90 ->setHeaderText(pht('Create New Diff')) 91 + ->setValidationException($validation_exception) 86 92 ->setForm($form) 87 93 ->setFormErrors($errors); 88 94
+208 -52
src/applications/differential/editor/DifferentialDiffEditor.php
··· 1 1 <?php 2 2 3 - final class DifferentialDiffEditor extends PhabricatorEditor { 3 + final class DifferentialDiffEditor 4 + extends PhabricatorApplicationTransactionEditor { 4 5 5 - private $contentSource; 6 + private $diffDataDict; 6 7 7 - public function setContentSource($content_source) { 8 - $this->contentSource = $content_source; 9 - return $this; 8 + public function getEditorApplicationClass() { 9 + return 'PhabricatorDifferentialApplication'; 10 10 } 11 11 12 - public function getContentSource() { 13 - return $this->contentSource; 12 + public function getEditorObjectsDescription() { 13 + return pht('Differential Diffs'); 14 14 } 15 15 16 - public function saveDiff(DifferentialDiff $diff) { 17 - $actor = $this->requireActor(); 16 + public function getTransactionTypes() { 17 + $types = parent::getTransactionTypes(); 18 18 19 - // Generate a PHID first, so the transcript will point at the object if 20 - // we deicde to preserve it. 21 - $phid = $diff->generatePHID(); 22 - $diff->setPHID($phid); 19 + $types[] = DifferentialDiffTransaction::TYPE_DIFF_CREATE; 23 20 24 - $adapter = id(new HeraldDifferentialDiffAdapter()) 25 - ->setDiff($diff); 21 + return $types; 22 + } 26 23 27 - $adapter->setContentSource($this->getContentSource()); 28 - $adapter->setIsNewObject(true); 24 + protected function getCustomTransactionOldValue( 25 + PhabricatorLiskDAO $object, 26 + PhabricatorApplicationTransaction $xaction) { 29 27 30 - $engine = new HeraldEngine(); 28 + switch ($xaction->getTransactionType()) { 29 + case DifferentialDiffTransaction::TYPE_DIFF_CREATE: 30 + return null; 31 + } 31 32 32 - $rules = $engine->loadRulesForAdapter($adapter); 33 - $rules = mpull($rules, null, 'getID'); 33 + return parent::getCustomTransactionOldValue($object, $xaction); 34 + } 34 35 35 - $effects = $engine->applyRules($rules, $adapter); 36 + protected function getCustomTransactionNewValue( 37 + PhabricatorLiskDAO $object, 38 + PhabricatorApplicationTransaction $xaction) { 36 39 37 - $blocking_effect = null; 38 - foreach ($effects as $effect) { 39 - if ($effect->getAction() == HeraldAdapter::ACTION_BLOCK) { 40 - $blocking_effect = $effect; 41 - break; 42 - } 40 + switch ($xaction->getTransactionType()) { 41 + case DifferentialDiffTransaction::TYPE_DIFF_CREATE: 42 + $this->diffDataDict = $xaction->getNewValue(); 43 + return true; 43 44 } 44 45 45 - if ($blocking_effect) { 46 - $rule = idx($rules, $effect->getRuleID()); 47 - if ($rule && strlen($rule->getName())) { 48 - $rule_name = $rule->getName(); 49 - } else { 50 - $rule_name = pht('Unnamed Herald Rule'); 51 - } 46 + return parent::getCustomTransactionNewValue($object, $xaction); 47 + } 52 48 53 - $message = $effect->getTarget(); 54 - if (!strlen($message)) { 55 - $message = pht('(None.)'); 49 + protected function applyCustomInternalTransaction( 50 + PhabricatorLiskDAO $object, 51 + PhabricatorApplicationTransaction $xaction) { 52 + 53 + switch ($xaction->getTransactionType()) { 54 + case DifferentialDiffTransaction::TYPE_DIFF_CREATE: 55 + $dict = $this->diffDataDict; 56 + $this->updateDiffFromDict($object, $dict); 57 + return; 58 + } 59 + 60 + return parent::applyCustomInternalTransaction($object, $xaction); 61 + } 62 + 63 + protected function applyCustomExternalTransaction( 64 + PhabricatorLiskDAO $object, 65 + PhabricatorApplicationTransaction $xaction) { 66 + 67 + switch ($xaction->getTransactionType()) { 68 + case DifferentialDiffTransaction::TYPE_DIFF_CREATE: 69 + return; 70 + } 71 + 72 + return parent::applyCustomExternalTransaction($object, $xaction); 73 + } 74 + 75 + protected function applyFinalEffects( 76 + PhabricatorLiskDAO $object, 77 + array $xactions) { 78 + 79 + // If we didn't get an explicit `repositoryPHID` (which means the client 80 + // is old, or couldn't figure out which repository the working copy 81 + // belongs to), apply heuristics to try to figure it out. 82 + 83 + if (!$object->getRepositoryPHID()) { 84 + $repository = id(new DifferentialRepositoryLookup()) 85 + ->setDiff($object) 86 + ->setViewer($this->getActor()) 87 + ->lookupRepository(); 88 + if ($repository) { 89 + $object->setRepositoryPHID($repository->getPHID()); 90 + $object->setRepositoryUUID($repository->getUUID()); 91 + $object->save(); 56 92 } 93 + } 57 94 58 - throw new DifferentialDiffCreationRejectException( 59 - pht( 60 - "Creation of this diff was rejected by Herald rule %s.\n". 61 - " Rule: %s\n". 62 - "Reason: %s", 63 - 'H'.$effect->getRuleID(), 64 - $rule_name, 65 - $message)); 95 + return $xactions; 96 + } 97 + 98 + /** 99 + * We run Herald as part of transaction validation because Herald can 100 + * block diff creation for Differential diffs. Its important to do this 101 + * separately so no Herald logs are saved; these logs could expose 102 + * information the Herald rules are inteneded to block. 103 + */ 104 + protected function validateTransaction( 105 + PhabricatorLiskDAO $object, 106 + $type, 107 + array $xactions) { 108 + 109 + $errors = parent::validateTransaction($object, $type, $xactions); 110 + 111 + foreach ($xactions as $xaction) { 112 + switch ($type) { 113 + case DifferentialDiffTransaction::TYPE_DIFF_CREATE: 114 + $diff = clone $object; 115 + $diff = $this->updateDiffFromDict($diff, $xaction->getNewValue()); 116 + 117 + $adapter = $this->buildHeraldAdapter($diff, $xactions); 118 + $adapter->setContentSource($this->getContentSource()); 119 + $adapter->setIsNewObject($this->getIsNewObject()); 120 + 121 + $engine = new HeraldEngine(); 122 + 123 + $rules = $engine->loadRulesForAdapter($adapter); 124 + $rules = mpull($rules, null, 'getID'); 125 + 126 + $effects = $engine->applyRules($rules, $adapter); 127 + 128 + $blocking_effect = null; 129 + foreach ($effects as $effect) { 130 + if ($effect->getAction() == HeraldAdapter::ACTION_BLOCK) { 131 + $blocking_effect = $effect; 132 + break; 133 + } 134 + } 135 + 136 + if ($blocking_effect) { 137 + $rule = idx($rules, $effect->getRuleID()); 138 + if ($rule && strlen($rule->getName())) { 139 + $rule_name = $rule->getName(); 140 + } else { 141 + $rule_name = pht('Unnamed Herald Rule'); 142 + } 143 + 144 + $message = $effect->getTarget(); 145 + if (!strlen($message)) { 146 + $message = pht('(None.)'); 147 + } 148 + 149 + $errors[] = new PhabricatorApplicationTransactionValidationError( 150 + $type, 151 + pht('Rejected by Herald'), 152 + pht( 153 + "Creation of this diff was rejected by Herald rule %s.\n". 154 + " Rule: %s\n". 155 + "Reason: %s", 156 + 'H'.$effect->getRuleID(), 157 + $rule_name, 158 + $message)); 159 + } 160 + break; 161 + } 66 162 } 67 163 68 - $diff->save(); 164 + return $errors; 165 + } 69 166 70 - // NOTE: We only save the transcript if we didn't block the diff. 71 - // Otherwise, we might save some of the diff's content in the transcript 72 - // table, which would defeat the purpose of allowing rules to block 73 - // storage of key material. 74 167 75 - $engine->applyEffects($effects, $adapter, $rules); 76 - $xscript = $engine->getTranscript(); 168 + protected function shouldPublishFeedStory( 169 + PhabricatorLiskDAO $object, 170 + array $xactions) { 171 + return false; 172 + } 77 173 174 + protected function shouldSendMail( 175 + PhabricatorLiskDAO $object, 176 + array $xactions) { 177 + return false; 78 178 } 79 179 180 + protected function supportsSearch() { 181 + return false; 182 + } 183 + 184 + /* -( Herald Integration )------------------------------------------------- */ 185 + 186 + /** 187 + * See @{method:validateTransaction}. The only Herald action is to block 188 + * the creation of Diffs. We thus have to be careful not to save any 189 + * data and do this validation very early. 190 + */ 191 + protected function shouldApplyHeraldRules( 192 + PhabricatorLiskDAO $object, 193 + array $xactions) { 194 + 195 + return false; 196 + } 197 + 198 + protected function buildHeraldAdapter( 199 + PhabricatorLiskDAO $object, 200 + array $xactions) { 201 + 202 + $adapter = id(new HeraldDifferentialDiffAdapter()) 203 + ->setDiff($object); 204 + 205 + return $adapter; 206 + } 207 + 208 + protected function didApplyHeraldRules( 209 + PhabricatorLiskDAO $object, 210 + HeraldAdapter $adapter, 211 + HeraldTranscript $transcript) { 212 + 213 + $xactions = array(); 214 + return $xactions; 215 + } 216 + 217 + private function updateDiffFromDict(DifferentialDiff $diff, $dict) { 218 + $diff 219 + ->setSourcePath(idx($dict, 'sourcePath')) 220 + ->setSourceMachine(idx($dict, 'sourceMachine')) 221 + ->setBranch(idx($dict, 'branch')) 222 + ->setCreationMethod(idx($dict, 'creationMethod')) 223 + ->setAuthorPHID(idx($dict, 'authorPHID', $this->getActor())) 224 + ->setBookmark(idx($dict, 'bookmark')) 225 + ->setRepositoryPHID(idx($dict, 'repositoryPHID')) 226 + ->setRepositoryUUID(idx($dict, 'repositoryUUID')) 227 + ->setSourceControlSystem(idx($dict, 'sourceControlSystem')) 228 + ->setSourceControlPath(idx($dict, 'sourceControlPath')) 229 + ->setSourceControlBaseRevision(idx($dict, 'sourceControlBaseRevision')) 230 + ->setLintStatus(idx($dict, 'lintStatus')) 231 + ->setUnitStatus(idx($dict, 'unitStatus')) 232 + ->setArcanistProjectPHID(idx($dict, 'arcanistProjectPHID')); 233 + 234 + return $diff; 235 + } 80 236 }
-2
src/applications/differential/editor/DifferentialTransactionEditor.php
··· 1523 1523 $adapter->setExplicitReviewers($reviewer_phids); 1524 1524 $adapter->setForbiddenCCs($unsubscribed_phids); 1525 1525 1526 - $adapter->setIsNewObject($this->getIsNewObject()); 1527 - 1528 1526 return $adapter; 1529 1527 } 1530 1528
+64
src/applications/differential/storage/DifferentialDiffTransaction.php
··· 1 + <?php 2 + 3 + final class DifferentialDiffTransaction 4 + extends PhabricatorApplicationTransaction { 5 + 6 + const TYPE_DIFF_CREATE = 'differential:diff:create'; 7 + 8 + public function getApplicationName() { 9 + return 'differential'; 10 + } 11 + 12 + public function getApplicationTransactionType() { 13 + return DifferentialDiffPHIDType::TYPECONST; 14 + } 15 + 16 + public function shouldHideForMail(array $xactions) { 17 + return true; 18 + } 19 + 20 + public function getActionName() { 21 + switch ($this->getTransactionType()) { 22 + case self::TYPE_DIFF_CREATE; 23 + return pht('Created'); 24 + } 25 + 26 + return parent::getActionName(); 27 + } 28 + 29 + public function getTitle() { 30 + $author_phid = $this->getAuthorPHID(); 31 + $author_handle = $this->renderHandleLink($author_phid); 32 + 33 + $old = $this->getOldValue(); 34 + $new = $this->getNewValue(); 35 + 36 + switch ($this->getTransactionType()) { 37 + case self::TYPE_DIFF_CREATE; 38 + return pht( 39 + '%s created this diff.', 40 + $author_handle); 41 + } 42 + 43 + return parent::getTitle(); 44 + } 45 + 46 + public function getIcon() { 47 + switch ($this->getTransactionType()) { 48 + case self::TYPE_DIFF_CREATE: 49 + return 'fa-refresh'; 50 + } 51 + 52 + return parent::getIcon(); 53 + } 54 + 55 + public function getColor() { 56 + switch ($this->getTransactionType()) { 57 + case self::TYPE_DIFF_CREATE: 58 + return PhabricatorTransactions::COLOR_SKY; 59 + } 60 + 61 + return parent::getColor(); 62 + } 63 + 64 + }