repo
stringlengths
7
63
file_url
stringlengths
81
284
file_path
stringlengths
5
200
content
stringlengths
0
32.8k
language
stringclasses
1 value
license
stringclasses
7 values
commit_sha
stringlengths
40
40
retrieved_at
stringdate
2026-01-04 15:02:33
2026-01-05 05:24:06
truncated
bool
2 classes
phacility/phabricator
https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/differential/field/DifferentialConflictsCommitMessageField.php
src/applications/differential/field/DifferentialConflictsCommitMessageField.php
<?php final class DifferentialConflictsCommitMessageField extends DifferentialCommitMessageField { const FIELDKEY = 'conflicts'; public function getFieldName() { return pht('Conflicts'); } public function getFieldOrder() { return 900000; } public function isFieldEditable() { return false; } public function isTemplateField() { return false; } }
php
Apache-2.0
5720a38cfe95b00ca4be5016dd0d2f3195f4fa04
2026-01-04T15:03:23.651835Z
false
phacility/phabricator
https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/differential/field/DifferentialRevisionIDCommitMessageField.php
src/applications/differential/field/DifferentialRevisionIDCommitMessageField.php
<?php final class DifferentialRevisionIDCommitMessageField extends DifferentialCommitMessageField { const FIELDKEY = 'revisionID'; public function getFieldName() { return pht('Differential Revision'); } public function getFieldOrder() { return 200000; } public function isTemplateField() { return false; } public function parseFieldValue($value) { // If the complete commit message we are parsing has unrecognized custom // fields at the end, they can end up parsed into the field value for this // field. For example, if the message looks like this: // Differential Revision: xyz // Some-Other-Field: abc // ...we will receive "xyz\nSome-Other-Field: abc" as the field value for // this field. Ideally, the install would define these fields so they can // parse formally, but we can reasonably assume that only the first line // of any value we encounter actually contains a revision identifier, so // start by throwing away any other lines. $value = trim($value); $value = phutil_split_lines($value, false); $value = head($value); $value = trim($value); // If the value is just "D123" or similar, parse the ID from it directly. $matches = null; if (preg_match('/^[dD]([1-9]\d*)\z/', $value, $matches)) { return (int)$matches[1]; } // Otherwise, try to extract a URI value. return self::parseRevisionIDFromURI($value); } private static function parseRevisionIDFromURI($uri_string) { $uri = new PhutilURI($uri_string); $path = $uri->getPath(); if (PhabricatorEnv::isSelfURI($uri_string)) { $matches = null; if (preg_match('#^/D(\d+)$#', $path, $matches)) { return (int)$matches[1]; } } return null; } public function readFieldValueFromObject(DifferentialRevision $revision) { return $revision->getID(); } public function readFieldValueFromConduit($value) { if (is_int($value)) { $value = (string)$value; } return $this->readStringFieldValueFromConduit($value); } public function renderFieldValue($value) { if ($value === null || !strlen($value)) { return null; } return PhabricatorEnv::getProductionURI('/D'.$value); } public function getFieldTransactions($value) { return array(); } }
php
Apache-2.0
5720a38cfe95b00ca4be5016dd0d2f3195f4fa04
2026-01-04T15:03:23.651835Z
false
phacility/phabricator
https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/differential/field/DifferentialSubscribersCommitMessageField.php
src/applications/differential/field/DifferentialSubscribersCommitMessageField.php
<?php final class DifferentialSubscribersCommitMessageField extends DifferentialCommitMessageField { const FIELDKEY = 'ccPHIDs'; public function getFieldName() { return pht('Subscribers'); } public function getFieldOrder() { return 6000; } public function getFieldAliases() { return array( 'CC', 'CCs', 'Subscriber', ); } public function parseFieldValue($value) { return $this->parseObjectList( $value, array( PhabricatorPeopleUserPHIDType::TYPECONST, PhabricatorProjectProjectPHIDType::TYPECONST, PhabricatorOwnersPackagePHIDType::TYPECONST, )); } public function readFieldValueFromObject(DifferentialRevision $revision) { if (!$revision->getPHID()) { return array(); } return PhabricatorSubscribersQuery::loadSubscribersForPHID( $revision->getPHID()); } public function readFieldValueFromConduit($value) { return $this->readStringListFieldValueFromConduit($value); } public function renderFieldValue($value) { return $this->renderHandleList($value); } public function getFieldTransactions($value) { return array( array( 'type' => PhabricatorSubscriptionsEditEngineExtension::EDITKEY_SET, 'value' => $value, ), ); } }
php
Apache-2.0
5720a38cfe95b00ca4be5016dd0d2f3195f4fa04
2026-01-04T15:03:23.651835Z
false
phacility/phabricator
https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/differential/field/DifferentialTitleCommitMessageField.php
src/applications/differential/field/DifferentialTitleCommitMessageField.php
<?php final class DifferentialTitleCommitMessageField extends DifferentialCommitMessageField { const FIELDKEY = 'title'; public function getFieldName() { return pht('Title'); } public function getFieldOrder() { return 1000; } public static function getDefaultTitle() { return pht('<<Replace this line with your revision title>'); } public function parseFieldValue($value) { if ($value === self::getDefaultTitle()) { $this->raiseParseException( pht( 'Replace the default title line with a human-readable revision '. 'title which describes the changes you are making.')); } return parent::parseFieldValue($value); } public function validateFieldValue($value) { if (!strlen($value)) { $this->raiseValidationException( pht( 'You must provide a revision title in the first line '. 'of your commit message.')); } } public function readFieldValueFromObject(DifferentialRevision $revision) { $value = $revision->getTitle(); if (!strlen($value)) { return self::getDefaultTitle(); } return $value; } public function getFieldTransactions($value) { return array( array( 'type' => DifferentialRevisionTitleTransaction::EDITKEY, 'value' => $value, ), ); } }
php
Apache-2.0
5720a38cfe95b00ca4be5016dd0d2f3195f4fa04
2026-01-04T15:03:23.651835Z
false
phacility/phabricator
https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/differential/field/DifferentialRevertPlanCommitMessageField.php
src/applications/differential/field/DifferentialRevertPlanCommitMessageField.php
<?php final class DifferentialRevertPlanCommitMessageField extends DifferentialCommitMessageCustomField { const FIELDKEY = 'revertPlan'; public function getFieldName() { return pht('Revert Plan'); } public function getCustomFieldKey() { return 'phabricator:revert-plan'; } }
php
Apache-2.0
5720a38cfe95b00ca4be5016dd0d2f3195f4fa04
2026-01-04T15:03:23.651835Z
false
phacility/phabricator
https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/differential/field/DifferentialSummaryCommitMessageField.php
src/applications/differential/field/DifferentialSummaryCommitMessageField.php
<?php final class DifferentialSummaryCommitMessageField extends DifferentialCommitMessageField { const FIELDKEY = 'summary'; public function getFieldName() { return pht('Summary'); } public function getFieldOrder() { return 2000; } public function readFieldValueFromObject(DifferentialRevision $revision) { return $revision->getSummary(); } public function getFieldTransactions($value) { return array( array( 'type' => DifferentialRevisionSummaryTransaction::EDITKEY, 'value' => $value, ), ); } }
php
Apache-2.0
5720a38cfe95b00ca4be5016dd0d2f3195f4fa04
2026-01-04T15:03:23.651835Z
false
phacility/phabricator
https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/differential/field/DifferentialJIRAIssuesCommitMessageField.php
src/applications/differential/field/DifferentialJIRAIssuesCommitMessageField.php
<?php final class DifferentialJIRAIssuesCommitMessageField extends DifferentialCommitMessageCustomField { const FIELDKEY = 'jira.issues'; public function getFieldName() { return pht('JIRA Issues'); } public function getFieldAliases() { return array( 'JIRA', 'JIRA Issue', ); } public function getCustomFieldKey() { return 'phabricator:jira-issues'; } public function parseFieldValue($value) { return preg_split('/[\s,]+/', $value, $limit = -1, PREG_SPLIT_NO_EMPTY); } protected function readFieldValueFromCustomFieldStorage($value) { return $this->readJSONFieldValueFromCustomFieldStorage($value, array()); } public function readFieldValueFromConduit($value) { return $this->readStringListFieldValueFromConduit($value); } public function renderFieldValue($value) { if (!$value) { return null; } return implode(', ', $value); } }
php
Apache-2.0
5720a38cfe95b00ca4be5016dd0d2f3195f4fa04
2026-01-04T15:03:23.651835Z
false
phacility/phabricator
https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/differential/field/DifferentialAuditorsCommitMessageField.php
src/applications/differential/field/DifferentialAuditorsCommitMessageField.php
<?php final class DifferentialAuditorsCommitMessageField extends DifferentialCommitMessageCustomField { const FIELDKEY = 'phabricator:auditors'; public function getFieldName() { return pht('Auditors'); } public function getFieldAliases() { return array( 'Auditor', ); } public function parseFieldValue($value) { return $this->parseObjectList( $value, array( PhabricatorPeopleUserPHIDType::TYPECONST, PhabricatorProjectProjectPHIDType::TYPECONST, PhabricatorOwnersPackagePHIDType::TYPECONST, )); } public function getCustomFieldKey() { return 'phabricator:auditors'; } public function isFieldEditable() { return true; } public function isTemplateField() { return false; } public function readFieldValueFromConduit($value) { return $this->readStringListFieldValueFromConduit($value); } public function renderFieldValue($value) { return $this->renderHandleList($value); } protected function readFieldValueFromCustomFieldStorage($value) { return $this->readJSONFieldValueFromCustomFieldStorage($value, array()); } }
php
Apache-2.0
5720a38cfe95b00ca4be5016dd0d2f3195f4fa04
2026-01-04T15:03:23.651835Z
false
phacility/phabricator
https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/differential/field/DifferentialTasksCommitMessageField.php
src/applications/differential/field/DifferentialTasksCommitMessageField.php
<?php final class DifferentialTasksCommitMessageField extends DifferentialCommitMessageField { const FIELDKEY = 'maniphestTaskPHIDs'; public function getFieldName() { return pht('Maniphest Tasks'); } public function getFieldOrder() { return 8000; } public function getFieldAliases() { return array( 'Task', 'Tasks', 'Maniphest Task', ); } public function isTemplateField() { return false; } public function parseFieldValue($value) { return $this->parseObjectList( $value, array( ManiphestTaskPHIDType::TYPECONST, )); } public function readFieldValueFromObject(DifferentialRevision $revision) { if (!$revision->getPHID()) { return array(); } $projects = PhabricatorEdgeQuery::loadDestinationPHIDs( $revision->getPHID(), DifferentialRevisionHasTaskEdgeType::EDGECONST); $projects = array_reverse($projects); return $projects; } public function readFieldValueFromConduit($value) { return $this->readStringListFieldValueFromConduit($value); } public function renderFieldValue($value) { return $this->renderHandleList($value); } public function getFieldTransactions($value) { return array( array( 'type' => 'tasks.set', 'value' => $value, ), ); } }
php
Apache-2.0
5720a38cfe95b00ca4be5016dd0d2f3195f4fa04
2026-01-04T15:03:23.651835Z
false
phacility/phabricator
https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/differential/field/DifferentialGitSVNIDCommitMessageField.php
src/applications/differential/field/DifferentialGitSVNIDCommitMessageField.php
<?php final class DifferentialGitSVNIDCommitMessageField extends DifferentialCommitMessageField { const FIELDKEY = 'gitSVNID'; public function getFieldName() { return pht('git-svn-id'); } public function getFieldOrder() { return 900001; } public function isFieldEditable() { return false; } public function isTemplateField() { return false; } }
php
Apache-2.0
5720a38cfe95b00ca4be5016dd0d2f3195f4fa04
2026-01-04T15:03:23.651835Z
false
phacility/phabricator
https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/differential/field/DifferentialReviewedByCommitMessageField.php
src/applications/differential/field/DifferentialReviewedByCommitMessageField.php
<?php final class DifferentialReviewedByCommitMessageField extends DifferentialCommitMessageField { const FIELDKEY = 'reviewedByPHIDs'; public function getFieldName() { return pht('Reviewed By'); } public function getFieldOrder() { return 5000; } public function parseFieldValue($value) { return $this->parseObjectList( $value, array( PhabricatorPeopleUserPHIDType::TYPECONST, PhabricatorProjectProjectPHIDType::TYPECONST, ), $allow_partial = true); } public function isFieldEditable() { return false; } public function isTemplateField() { return false; } public function readFieldValueFromObject(DifferentialRevision $revision) { if (!$revision->getPHID()) { return array(); } $phids = array(); foreach ($revision->getReviewers() as $reviewer) { switch ($reviewer->getReviewerStatus()) { case DifferentialReviewerStatus::STATUS_ACCEPTED: $phids[] = $reviewer->getReviewerPHID(); break; } } return $phids; } public function readFieldValueFromConduit($value) { return $this->readStringListFieldValueFromConduit($value); } public function renderFieldValue($value) { return $this->renderHandleList($value); } }
php
Apache-2.0
5720a38cfe95b00ca4be5016dd0d2f3195f4fa04
2026-01-04T15:03:23.651835Z
false
phacility/phabricator
https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/differential/field/DifferentialTestPlanCommitMessageField.php
src/applications/differential/field/DifferentialTestPlanCommitMessageField.php
<?php final class DifferentialTestPlanCommitMessageField extends DifferentialCommitMessageField { const FIELDKEY = 'testPlan'; public function getFieldName() { return pht('Test Plan'); } public function getFieldOrder() { return 3000; } public function getFieldAliases() { return array( 'Testplan', 'Tested', 'Tests', ); } public function isFieldEnabled() { return $this->isCustomFieldEnabled('differential:test-plan'); } public function validateFieldValue($value) { $is_required = PhabricatorEnv::getEnvConfig( 'differential.require-test-plan-field'); if ($is_required && !strlen($value)) { $this->raiseValidationException( pht( 'You must provide a test plan. Describe the actions you performed '. 'to verify the behavior of this change.')); } } public function readFieldValueFromObject(DifferentialRevision $revision) { return $revision->getTestPlan(); } public function getFieldTransactions($value) { return array( array( 'type' => DifferentialRevisionTestPlanTransaction::EDITKEY, 'value' => $value, ), ); } }
php
Apache-2.0
5720a38cfe95b00ca4be5016dd0d2f3195f4fa04
2026-01-04T15:03:23.651835Z
false
phacility/phabricator
https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/differential/field/DifferentialCommitMessageField.php
src/applications/differential/field/DifferentialCommitMessageField.php
<?php abstract class DifferentialCommitMessageField extends Phobject { private $viewer; private $customFieldStorage; final public function setViewer(PhabricatorUser $viewer) { $this->viewer = $viewer; return $this; } final public function getViewer() { return $this->viewer; } final public function setCustomFieldStorage(array $custom_field_storage) { $this->customFieldStorage = $custom_field_storage; return $this; } final public function getCustomFieldStorage() { return $this->customFieldStorage; } abstract public function getFieldName(); abstract public function getFieldOrder(); public function isFieldEnabled() { return true; } public function getFieldAliases() { return array(); } public function validateFieldValue($value) { return; } public function parseFieldValue($value) { return $value; } public function isFieldEditable() { return true; } public function isTemplateField() { return true; } public function readFieldValueFromConduit($value) { return $this->readStringFieldValueFromConduit($value); } public function readFieldValueFromObject(DifferentialRevision $revision) { return null; } public function renderFieldValue($value) { if ($value === null || !strlen($value)) { return null; } return $value; } public function getFieldTransactions($value) { if (!$this->isFieldEditable()) { return array(); } throw new PhutilMethodNotImplementedException(); } final public function getCommitMessageFieldKey() { return $this->getPhobjectClassConstant('FIELDKEY', 64); } final public static function newEnabledFields(PhabricatorUser $viewer) { $fields = self::getAllFields(); $results = array(); foreach ($fields as $key => $field) { $field = clone $field; $field->setViewer($viewer); if ($field->isFieldEnabled()) { $results[$key] = $field; } } return $results; } final public static function getAllFields() { return id(new PhutilClassMapQuery()) ->setAncestorClass(__CLASS__) ->setUniqueMethod('getCommitMessageFieldKey') ->setSortMethod('getFieldOrder') ->execute(); } protected function raiseParseException($message) { throw new DifferentialFieldParseException($message); } protected function raiseValidationException($message) { throw new DifferentialFieldValidationException($message); } protected function parseObjectList( $value, array $types, $allow_partial = false, array $suffixes = array()) { return id(new PhabricatorObjectListQuery()) ->setViewer($this->getViewer()) ->setAllowedTypes($types) ->setObjectList($value) ->setAllowPartialResults($allow_partial) ->setSuffixes($suffixes) ->execute(); } protected function renderHandleList(array $phids, array $suffixes = array()) { if (!$phids) { return null; } $handles = $this->getViewer()->loadHandles($phids); $out = array(); foreach ($handles as $handle) { $phid = $handle->getPHID(); if ($handle->getPolicyFiltered()) { $token = $phid; } else if ($handle->isComplete()) { $token = $handle->getCommandLineObjectName(); } $suffix = idx($suffixes, $phid); $token = $token.$suffix; $out[] = $token; } return implode(', ', $out); } protected function readStringFieldValueFromConduit($value) { if ($value === null) { return $value; } if (!is_string($value)) { throw new Exception( pht( 'Field "%s" expects a string value, but received a value of type '. '"%s".', $this->getCommitMessageFieldKey(), gettype($value))); } return $value; } protected function readStringListFieldValueFromConduit($value) { if (!is_array($value)) { throw new Exception( pht( 'Field "%s" expects a list of strings, but received a value of type '. '"%s".', $this->getCommitMessageFieldKey(), gettype($value))); } return $value; } protected function isCustomFieldEnabled($key) { $field_list = PhabricatorCustomField::getObjectFields( new DifferentialRevision(), DifferentialCustomField::ROLE_DEFAULT); $fields = $field_list->getFields(); return isset($fields[$key]); } }
php
Apache-2.0
5720a38cfe95b00ca4be5016dd0d2f3195f4fa04
2026-01-04T15:03:23.651835Z
false
phacility/phabricator
https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/differential/field/DifferentialCommitMessageCustomField.php
src/applications/differential/field/DifferentialCommitMessageCustomField.php
<?php abstract class DifferentialCommitMessageCustomField extends DifferentialCommitMessageField { abstract public function getCustomFieldKey(); public function getFieldOrder() { $custom_key = $this->getCustomFieldKey(); return 100000 + $this->getCustomFieldOrder($custom_key); } public function isFieldEnabled() { $custom_key = $this->getCustomFieldKey(); return $this->isCustomFieldEnabled($custom_key); } public function readFieldValueFromObject(DifferentialRevision $revision) { $custom_key = $this->getCustomFieldKey(); $value = $this->readCustomFieldValue($revision, $custom_key); return $value; } protected function readFieldValueFromCustomFieldStorage($value) { return $value; } protected function readJSONFieldValueFromCustomFieldStorage( $value, $default) { try { return phutil_json_decode($value); } catch (PhutilJSONParserException $ex) { return $default; } } protected function readCustomFieldValue( DifferentialRevision $revision, $key) { $value = idx($this->getCustomFieldStorage(), $key); return $this->readFieldValueFromCustomFieldStorage($value); } protected function getCustomFieldOrder($key) { $field_list = PhabricatorCustomField::getObjectFields( new DifferentialRevision(), PhabricatorCustomField::ROLE_DEFAULT); $fields = $field_list->getFields(); $idx = 0; foreach ($fields as $field_key => $value) { if ($key === $field_key) { return $idx; } $idx++; } return $idx; } public function getFieldTransactions($value) { return array( array( 'type' => $this->getCommitMessageFieldKey(), 'value' => $value, ), ); } }
php
Apache-2.0
5720a38cfe95b00ca4be5016dd0d2f3195f4fa04
2026-01-04T15:03:23.651835Z
false
phacility/phabricator
https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/differential/field/DifferentialTagsCommitMessageField.php
src/applications/differential/field/DifferentialTagsCommitMessageField.php
<?php final class DifferentialTagsCommitMessageField extends DifferentialCommitMessageField { const FIELDKEY = 'phabricator:projects'; public function getFieldName() { return pht('Tags'); } public function getFieldOrder() { return 7000; } public function getFieldAliases() { return array( 'Tag', 'Project', 'Projects', ); } public function isTemplateField() { return false; } public function parseFieldValue($value) { return $this->parseObjectList( $value, array( PhabricatorProjectProjectPHIDType::TYPECONST, )); } public function readFieldValueFromObject(DifferentialRevision $revision) { if (!$revision->getPHID()) { return array(); } $projects = PhabricatorEdgeQuery::loadDestinationPHIDs( $revision->getPHID(), PhabricatorProjectObjectHasProjectEdgeType::EDGECONST); $projects = array_reverse($projects); return $projects; } public function readFieldValueFromConduit($value) { return $this->readStringListFieldValueFromConduit($value); } public function renderFieldValue($value) { return $this->renderHandleList($value); } public function getFieldTransactions($value) { return array( array( 'type' => PhabricatorProjectsEditEngineExtension::EDITKEY_SET, 'value' => $value, ), ); } }
php
Apache-2.0
5720a38cfe95b00ca4be5016dd0d2f3195f4fa04
2026-01-04T15:03:23.651835Z
false
phacility/phabricator
https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/differential/field/DifferentialReviewersCommitMessageField.php
src/applications/differential/field/DifferentialReviewersCommitMessageField.php
<?php final class DifferentialReviewersCommitMessageField extends DifferentialCommitMessageField { const FIELDKEY = 'reviewerPHIDs'; public function getFieldName() { return pht('Reviewers'); } public function getFieldOrder() { return 4000; } public function getFieldAliases() { return array( 'Reviewer', ); } public function parseFieldValue($value) { $results = $this->parseObjectList( $value, array( PhabricatorPeopleUserPHIDType::TYPECONST, PhabricatorProjectProjectPHIDType::TYPECONST, PhabricatorOwnersPackagePHIDType::TYPECONST, ), false, array('!')); return $this->flattenReviewers($results); } public function readFieldValueFromConduit($value) { return $this->readStringListFieldValueFromConduit($value); } public function readFieldValueFromObject(DifferentialRevision $revision) { if (!$revision->getPHID()) { return array(); } $status_blocking = DifferentialReviewerStatus::STATUS_BLOCKING; $results = array(); foreach ($revision->getReviewers() as $reviewer) { if ($reviewer->getReviewerStatus() == $status_blocking) { $suffixes = array('!' => '!'); } else { $suffixes = array(); } $results[] = array( 'phid' => $reviewer->getReviewerPHID(), 'suffixes' => $suffixes, ); } return $this->flattenReviewers($results); } public function renderFieldValue($value) { $value = $this->inflateReviewers($value); $phid_list = array(); $suffix_map = array(); foreach ($value as $reviewer) { $phid = $reviewer['phid']; $phid_list[] = $phid; if (isset($reviewer['suffixes']['!'])) { $suffix_map[$phid] = '!'; } } return $this->renderHandleList($phid_list, $suffix_map); } public function getFieldTransactions($value) { $value = $this->inflateReviewers($value); $reviewer_list = array(); foreach ($value as $reviewer) { $phid = $reviewer['phid']; if (isset($reviewer['suffixes']['!'])) { $reviewer_list[] = 'blocking('.$phid.')'; } else { $reviewer_list[] = $phid; } } $xaction_key = DifferentialRevisionReviewersTransaction::EDITKEY; $xaction_type = "{$xaction_key}.set"; return array( array( 'type' => $xaction_type, 'value' => $reviewer_list, ), ); } private function flattenReviewers(array $values) { // NOTE: For now, `arc` relies on this field returning only scalars, so we // need to reduce the results into scalars. See T10981. $result = array(); foreach ($values as $value) { $result[] = $value['phid'].implode('', array_keys($value['suffixes'])); } return $result; } private function inflateReviewers(array $values) { $result = array(); foreach ($values as $value) { if (substr($value, -1) == '!') { $value = substr($value, 0, -1); $suffixes = array('!' => '!'); } else { $suffixes = array(); } $result[] = array( 'phid' => $value, 'suffixes' => $suffixes, ); } return $result; } }
php
Apache-2.0
5720a38cfe95b00ca4be5016dd0d2f3195f4fa04
2026-01-04T15:03:23.651835Z
false
phacility/phabricator
https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/differential/field/DifferentialBlameRevisionCommitMessageField.php
src/applications/differential/field/DifferentialBlameRevisionCommitMessageField.php
<?php final class DifferentialBlameRevisionCommitMessageField extends DifferentialCommitMessageCustomField { const FIELDKEY = 'blameRevision'; public function getFieldName() { return pht('Blame Revision'); } public function getFieldAliases() { return array( 'Blame Rev', ); } public function getCustomFieldKey() { return 'phabricator:blame-revision'; } }
php
Apache-2.0
5720a38cfe95b00ca4be5016dd0d2f3195f4fa04
2026-01-04T15:03:23.651835Z
false
phacility/phabricator
https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/differential/field/__tests__/DifferentialCommitMessageFieldTestCase.php
src/applications/differential/field/__tests__/DifferentialCommitMessageFieldTestCase.php
<?php final class DifferentialCommitMessageFieldTestCase extends PhabricatorTestCase { public function testRevisionCommitMessageFieldParsing() { $base_uri = 'https://www.example.com/'; $tests = array( 'D123' => 123, 'd123' => 123, " \n d123 \n " => 123, "D123\nSome-Custom-Field: The End" => 123, "{$base_uri}D123" => 123, "{$base_uri}D123\nSome-Custom-Field: The End" => 123, 'https://www.other.com/D123' => null, ); $env = PhabricatorEnv::beginScopedEnv(); $env->overrideEnvConfig('phabricator.base-uri', $base_uri); foreach ($tests as $input => $expect) { $actual = id(new DifferentialRevisionIDCommitMessageField()) ->parseFieldValue($input); $this->assertEqual($expect, $actual, pht('Parse of: %s', $input)); } unset($env); } }
php
Apache-2.0
5720a38cfe95b00ca4be5016dd0d2f3195f4fa04
2026-01-04T15:03:23.651835Z
false
phacility/phabricator
https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/differential/edge/DifferentialReviewerForRevisionEdgeType.php
src/applications/differential/edge/DifferentialReviewerForRevisionEdgeType.php
<?php final class DifferentialReviewerForRevisionEdgeType extends PhabricatorEdgeType { const EDGECONST = 36; public function getInverseEdgeConstant() { return DifferentialRevisionHasReviewerEdgeType::EDGECONST; } public function shouldWriteInverseTransactions() { return true; } }
php
Apache-2.0
5720a38cfe95b00ca4be5016dd0d2f3195f4fa04
2026-01-04T15:03:23.651835Z
false
phacility/phabricator
https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/differential/edge/DifferentialRevisionHasCommitEdgeType.php
src/applications/differential/edge/DifferentialRevisionHasCommitEdgeType.php
<?php final class DifferentialRevisionHasCommitEdgeType extends PhabricatorEdgeType { const EDGECONST = 31; public function getInverseEdgeConstant() { return DiffusionCommitHasRevisionEdgeType::EDGECONST; } public function shouldWriteInverseTransactions() { return true; } public function getConduitKey() { return 'revision.commit'; } public function getConduitName() { return pht('Revision Has Commit'); } public function getConduitDescription() { return pht( 'The source revision is associated with the destination commit.'); } public function getTransactionAddString( $actor, $add_count, $add_edges) { return pht( '%s added %s commit(s): %s.', $actor, $add_count, $add_edges); } public function getTransactionRemoveString( $actor, $rem_count, $rem_edges) { return pht( '%s removed %s commit(s): %s.', $actor, $rem_count, $rem_edges); } public function getTransactionEditString( $actor, $total_count, $add_count, $add_edges, $rem_count, $rem_edges) { return pht( '%s edited commit(s), added %s: %s; removed %s: %s.', $actor, $add_count, $add_edges, $rem_count, $rem_edges); } public function getFeedAddString( $actor, $object, $add_count, $add_edges) { return pht( '%s added %s commit(s) for %s: %s.', $actor, $add_count, $object, $add_edges); } public function getFeedRemoveString( $actor, $object, $rem_count, $rem_edges) { return pht( '%s removed %s commit(s) for %s: %s.', $actor, $rem_count, $object, $rem_edges); } public function getFeedEditString( $actor, $object, $total_count, $add_count, $add_edges, $rem_count, $rem_edges) { return pht( '%s edited commit(s) for %s, added %s: %s; removed %s: %s.', $actor, $object, $add_count, $add_edges, $rem_count, $rem_edges); } }
php
Apache-2.0
5720a38cfe95b00ca4be5016dd0d2f3195f4fa04
2026-01-04T15:03:23.651835Z
false
phacility/phabricator
https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/differential/edge/DifferentialRevisionHasTaskEdgeType.php
src/applications/differential/edge/DifferentialRevisionHasTaskEdgeType.php
<?php final class DifferentialRevisionHasTaskEdgeType extends PhabricatorEdgeType { const EDGECONST = 12; public function getInverseEdgeConstant() { return ManiphestTaskHasRevisionEdgeType::EDGECONST; } public function shouldWriteInverseTransactions() { return true; } public function getConduitKey() { return 'revision.task'; } public function getConduitName() { return pht('Revision Has Task'); } public function getConduitDescription() { return pht('The source revision is associated with the destination task.'); } public function getTransactionAddString( $actor, $add_count, $add_edges) { return pht( '%s added %s task(s): %s.', $actor, $add_count, $add_edges); } public function getTransactionRemoveString( $actor, $rem_count, $rem_edges) { return pht( '%s removed %s task(s): %s.', $actor, $rem_count, $rem_edges); } public function getTransactionEditString( $actor, $total_count, $add_count, $add_edges, $rem_count, $rem_edges) { return pht( '%s edited %s task(s), added %s: %s; removed %s: %s.', $actor, $total_count, $add_count, $add_edges, $rem_count, $rem_edges); } public function getFeedAddString( $actor, $object, $add_count, $add_edges) { return pht( '%s added %s task(s) to %s: %s.', $actor, $add_count, $object, $add_edges); } public function getFeedRemoveString( $actor, $object, $rem_count, $rem_edges) { return pht( '%s removed %s task(s) from %s: %s.', $actor, $rem_count, $object, $rem_edges); } public function getFeedEditString( $actor, $object, $total_count, $add_count, $add_edges, $rem_count, $rem_edges) { return pht( '%s edited %s task(s) for %s, added %s: %s; removed %s: %s.', $actor, $total_count, $object, $add_count, $add_edges, $rem_count, $rem_edges); } }
php
Apache-2.0
5720a38cfe95b00ca4be5016dd0d2f3195f4fa04
2026-01-04T15:03:23.651835Z
false
phacility/phabricator
https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/differential/edge/DifferentialRevisionDependsOnRevisionEdgeType.php
src/applications/differential/edge/DifferentialRevisionDependsOnRevisionEdgeType.php
<?php final class DifferentialRevisionDependsOnRevisionEdgeType extends PhabricatorEdgeType { const EDGECONST = 5; public function getInverseEdgeConstant() { return DifferentialRevisionDependedOnByRevisionEdgeType::EDGECONST; } public function shouldWriteInverseTransactions() { return true; } public function shouldPreventCycles() { return true; } public function getConduitKey() { return 'revision.parent'; } public function getConduitName() { return pht('Revision Has Parent'); } public function getConduitDescription() { return pht( 'The source revision depends on changes in the destination revision.'); } public function getTransactionAddString( $actor, $add_count, $add_edges) { return pht( '%s added %s parent revision(s): %s.', $actor, $add_count, $add_edges); } public function getTransactionRemoveString( $actor, $rem_count, $rem_edges) { return pht( '%s removed %s parent revision(s): %s.', $actor, $rem_count, $rem_edges); } public function getTransactionEditString( $actor, $total_count, $add_count, $add_edges, $rem_count, $rem_edges) { return pht( '%s edited parent revision(s), added %s: %s; removed %s: %s.', $actor, $add_count, $add_edges, $rem_count, $rem_edges); } public function getFeedAddString( $actor, $object, $add_count, $add_edges) { return pht( '%s added %s parent revision(s) for %s: %s.', $actor, $add_count, $object, $add_edges); } public function getFeedRemoveString( $actor, $object, $rem_count, $rem_edges) { return pht( '%s removed %s parent revision(s) for %s: %s.', $actor, $rem_count, $object, $rem_edges); } public function getFeedEditString( $actor, $object, $total_count, $add_count, $add_edges, $rem_count, $rem_edges) { return pht( '%s edited parent revision(s) for %s, added %s: %s; removed %s: %s.', $actor, $object, $add_count, $add_edges, $rem_count, $rem_edges); } }
php
Apache-2.0
5720a38cfe95b00ca4be5016dd0d2f3195f4fa04
2026-01-04T15:03:23.651835Z
false
phacility/phabricator
https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/differential/edge/DifferentialRevisionHasReviewerEdgeType.php
src/applications/differential/edge/DifferentialRevisionHasReviewerEdgeType.php
<?php final class DifferentialRevisionHasReviewerEdgeType extends PhabricatorEdgeType { const EDGECONST = 35; public function getInverseEdgeConstant() { return DifferentialReviewerForRevisionEdgeType::EDGECONST; } public function getTransactionAddString( $actor, $add_count, $add_edges) { return pht( '%s added %s reviewer(s): %s.', $actor, $add_count, $add_edges); } public function getTransactionRemoveString( $actor, $rem_count, $rem_edges) { return pht( '%s removed %s reviewer(s): %s.', $actor, $rem_count, $rem_edges); } public function getTransactionEditString( $actor, $total_count, $add_count, $add_edges, $rem_count, $rem_edges) { return pht( '%s edited %s reviewer(s), added %s: %s; removed %s: %s.', $actor, $total_count, $add_count, $add_edges, $rem_count, $rem_edges); } public function getFeedAddString( $actor, $object, $add_count, $add_edges) { return pht( '%s added %s reviewer(s) for %s: %s.', $actor, $add_count, $object, $add_edges); } public function getFeedRemoveString( $actor, $object, $rem_count, $rem_edges) { return pht( '%s removed %s reviewer(s) for %s: %s.', $actor, $rem_count, $object, $rem_edges); } public function getFeedEditString( $actor, $object, $total_count, $add_count, $add_edges, $rem_count, $rem_edges) { return pht( '%s edited %s reviewer(s) for %s, added %s: %s; removed %s: %s.', $actor, $total_count, $object, $add_count, $add_edges, $rem_count, $rem_edges); } }
php
Apache-2.0
5720a38cfe95b00ca4be5016dd0d2f3195f4fa04
2026-01-04T15:03:23.651835Z
false
phacility/phabricator
https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/differential/edge/DifferentialRevisionDependedOnByRevisionEdgeType.php
src/applications/differential/edge/DifferentialRevisionDependedOnByRevisionEdgeType.php
<?php final class DifferentialRevisionDependedOnByRevisionEdgeType extends PhabricatorEdgeType { const EDGECONST = 6; public function getInverseEdgeConstant() { return DifferentialRevisionDependsOnRevisionEdgeType::EDGECONST; } public function shouldWriteInverseTransactions() { return true; } public function getConduitKey() { return 'revision.child'; } public function getConduitName() { return pht('Revision Has Child'); } public function getConduitDescription() { return pht( 'The source revision makes changes required by the destination '. 'revision.'); } public function getTransactionAddString( $actor, $add_count, $add_edges) { return pht( '%s added %s child revision(s): %s.', $actor, $add_count, $add_edges); } public function getTransactionRemoveString( $actor, $rem_count, $rem_edges) { return pht( '%s removed %s child revision(s): %s.', $actor, $rem_count, $rem_edges); } public function getTransactionEditString( $actor, $total_count, $add_count, $add_edges, $rem_count, $rem_edges) { return pht( '%s edited child revision(s), added %s: %s; removed %s: %s.', $actor, $add_count, $add_edges, $rem_count, $rem_edges); } public function getFeedAddString( $actor, $object, $add_count, $add_edges) { return pht( '%s added %s child revision(s) for %s: %s.', $actor, $add_count, $object, $add_edges); } public function getFeedRemoveString( $actor, $object, $rem_count, $rem_edges) { return pht( '%s removed %s child revision(s) for %s: %s.', $actor, $rem_count, $object, $rem_edges); } public function getFeedEditString( $actor, $object, $total_count, $add_count, $add_edges, $rem_count, $rem_edges) { return pht( '%s edited child revision(s) for %s, added %s: %s; removed %s: %s.', $actor, $object, $add_count, $add_edges, $rem_count, $rem_edges); } }
php
Apache-2.0
5720a38cfe95b00ca4be5016dd0d2f3195f4fa04
2026-01-04T15:03:23.651835Z
false
phacility/phabricator
https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/differential/phid/DifferentialChangesetPHIDType.php
src/applications/differential/phid/DifferentialChangesetPHIDType.php
<?php final class DifferentialChangesetPHIDType extends PhabricatorPHIDType { const TYPECONST = 'DCNG'; public function getTypeName() { return pht('Differential Changeset'); } public function newObject() { return new DifferentialChangeset(); } public function getPHIDTypeApplicationClass() { return 'PhabricatorDifferentialApplication'; } protected function buildQueryForObjects( PhabricatorObjectQuery $query, array $phids) { return id(new DifferentialChangesetQuery()) ->withPHIDs($phids); } public function loadHandles( PhabricatorHandleQuery $query, array $handles, array $objects) { foreach ($handles as $phid => $handle) { $changeset = $objects[$phid]; $id = $changeset->getID(); $handle->setName(pht('Changeset %d', $id)); } } }
php
Apache-2.0
5720a38cfe95b00ca4be5016dd0d2f3195f4fa04
2026-01-04T15:03:23.651835Z
false
phacility/phabricator
https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/differential/phid/DifferentialDiffPHIDType.php
src/applications/differential/phid/DifferentialDiffPHIDType.php
<?php final class DifferentialDiffPHIDType extends PhabricatorPHIDType { const TYPECONST = 'DIFF'; public function getTypeName() { return pht('Differential Diff'); } public function newObject() { return new DifferentialDiff(); } public function getPHIDTypeApplicationClass() { return 'PhabricatorDifferentialApplication'; } protected function buildQueryForObjects( PhabricatorObjectQuery $query, array $phids) { return id(new DifferentialDiffQuery()) ->withPHIDs($phids); } public function loadHandles( PhabricatorHandleQuery $query, array $handles, array $objects) { foreach ($handles as $phid => $handle) { $diff = $objects[$phid]; $id = $diff->getID(); $handle->setName(pht('Diff %d', $id)); $handle->setURI("/differential/diff/{$id}/"); } } }
php
Apache-2.0
5720a38cfe95b00ca4be5016dd0d2f3195f4fa04
2026-01-04T15:03:23.651835Z
false
phacility/phabricator
https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/differential/phid/DifferentialRevisionPHIDType.php
src/applications/differential/phid/DifferentialRevisionPHIDType.php
<?php final class DifferentialRevisionPHIDType extends PhabricatorPHIDType { const TYPECONST = 'DREV'; public function getTypeName() { return pht('Differential Revision'); } public function newObject() { return new DifferentialRevision(); } public function getPHIDTypeApplicationClass() { return 'PhabricatorDifferentialApplication'; } protected function buildQueryForObjects( PhabricatorObjectQuery $query, array $phids) { return id(new DifferentialRevisionQuery()) ->withPHIDs($phids); } public function loadHandles( PhabricatorHandleQuery $query, array $handles, array $objects) { foreach ($handles as $phid => $handle) { $revision = $objects[$phid]; $title = $revision->getTitle(); $monogram = $revision->getMonogram(); $uri = $revision->getURI(); $handle ->setName($monogram) ->setURI($uri) ->setFullName("{$monogram}: {$title}"); if ($revision->isClosed()) { $handle->setStatus(PhabricatorObjectHandle::STATUS_CLOSED); } } } public function canLoadNamedObject($name) { return preg_match('/^D[1-9]\d*$/i', $name); } public function loadNamedObjects( PhabricatorObjectQuery $query, array $names) { $id_map = array(); foreach ($names as $name) { $id = (int)substr($name, 1); $id_map[$id][] = $name; } $objects = id(new DifferentialRevisionQuery()) ->setViewer($query->getViewer()) ->withIDs(array_keys($id_map)) ->execute(); $results = array(); foreach ($objects as $id => $object) { foreach (idx($id_map, $id, array()) as $name) { $results[$name] = $object; } } return $results; } }
php
Apache-2.0
5720a38cfe95b00ca4be5016dd0d2f3195f4fa04
2026-01-04T15:03:23.651835Z
false
phacility/phabricator
https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/differential/herald/HeraldDifferentialAdapter.php
src/applications/differential/herald/HeraldDifferentialAdapter.php
<?php abstract class HeraldDifferentialAdapter extends HeraldAdapter { private $repository = false; private $diff; abstract protected function loadChangesets(); abstract protected function loadChangesetsWithHunks(); public function getDiff() { return $this->diff; } public function setDiff(DifferentialDiff $diff) { $this->diff = $diff; return $this; } public function loadRepository() { if ($this->repository === false) { $repository_phid = $this->getObject()->getRepositoryPHID(); if ($repository_phid) { $repository = id(new PhabricatorRepositoryQuery()) ->setViewer(PhabricatorUser::getOmnipotentUser()) ->withPHIDs(array($repository_phid)) ->executeOne(); } else { $repository = null; } $this->repository = $repository; } return $this->repository; } public function loadAffectedPaths() { $changesets = $this->loadChangesets(); $paths = array(); foreach ($changesets as $changeset) { $paths[] = $this->getAbsoluteRepositoryPathForChangeset($changeset); } return $paths; } protected function getAbsoluteRepositoryPathForChangeset( DifferentialChangeset $changeset) { $repository = $this->loadRepository(); if (!$repository) { return '/'.ltrim($changeset->getFilename(), '/'); } $diff = $this->getDiff(); return $changeset->getAbsoluteRepositoryPath($repository, $diff); } public function loadContentDictionary() { $add_lines = DifferentialHunk::FLAG_LINES_ADDED; $rem_lines = DifferentialHunk::FLAG_LINES_REMOVED; $mask = ($add_lines | $rem_lines); return $this->loadContentWithMask($mask); } public function loadAddedContentDictionary() { return $this->loadContentWithMask(DifferentialHunk::FLAG_LINES_ADDED); } public function loadRemovedContentDictionary() { return $this->loadContentWithMask(DifferentialHunk::FLAG_LINES_REMOVED); } protected function loadContentWithMask($mask) { $changesets = $this->loadChangesetsWithHunks(); $dict = array(); foreach ($changesets as $changeset) { $content = array(); foreach ($changeset->getHunks() as $hunk) { $content[] = $hunk->getContentWithMask($mask); } $path = $this->getAbsoluteRepositoryPathForChangeset($changeset); $dict[$path] = implode("\n", $content); } return $dict; } }
php
Apache-2.0
5720a38cfe95b00ca4be5016dd0d2f3195f4fa04
2026-01-04T15:03:23.651835Z
false
phacility/phabricator
https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/differential/herald/DifferentialDiffRepositoryHeraldField.php
src/applications/differential/herald/DifferentialDiffRepositoryHeraldField.php
<?php final class DifferentialDiffRepositoryHeraldField extends DifferentialDiffHeraldField { const FIELDCONST = 'differential.diff.repository'; public function getHeraldFieldName() { return pht('Repository'); } public function getHeraldFieldValue($object) { $repository = $this->getAdapter()->loadRepository(); if (!$repository) { return null; } return $repository->getPHID(); } protected function getHeraldFieldStandardType() { return self::STANDARD_PHID_NULLABLE; } protected function getDatasource() { return new DiffusionRepositoryDatasource(); } }
php
Apache-2.0
5720a38cfe95b00ca4be5016dd0d2f3195f4fa04
2026-01-04T15:03:23.651835Z
false
phacility/phabricator
https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/differential/herald/DifferentialRevisionContentAddedHeraldField.php
src/applications/differential/herald/DifferentialRevisionContentAddedHeraldField.php
<?php final class DifferentialRevisionContentAddedHeraldField extends DifferentialRevisionHeraldField { const FIELDCONST = 'differential.revision.diff.new'; public function getHeraldFieldName() { return pht('Added file content'); } public function getFieldGroupKey() { return DifferentialChangeHeraldFieldGroup::FIELDGROUPKEY; } public function getHeraldFieldValue($object) { return $this->getAdapter()->loadAddedContentDictionary(); } protected function getHeraldFieldStandardType() { return self::STANDARD_TEXT_MAP; } }
php
Apache-2.0
5720a38cfe95b00ca4be5016dd0d2f3195f4fa04
2026-01-04T15:03:23.651835Z
false
phacility/phabricator
https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/differential/herald/DifferentialRevisionJIRAIssueURIsHeraldField.php
src/applications/differential/herald/DifferentialRevisionJIRAIssueURIsHeraldField.php
<?php final class DifferentialRevisionJIRAIssueURIsHeraldField extends DifferentialRevisionHeraldField { const FIELDCONST = 'differential.revision.jira.uris'; public function getHeraldFieldName() { return pht('JIRA Issue URIs'); } public function supportsObject($object) { $provider = PhabricatorJIRAAuthProvider::getJIRAProvider(); if (!$provider) { return false; } return parent::supportsObject($object); } public function getHeraldFieldValue($object) { $adapter = $this->getAdapter(); $viewer = $adapter->getViewer(); $jira_phids = PhabricatorEdgeQuery::loadDestinationPHIDs( $object->getPHID(), PhabricatorJiraIssueHasObjectEdgeType::EDGECONST); if (!$jira_phids) { return array(); } $xobjs = id(new DoorkeeperExternalObjectQuery()) ->setViewer($viewer) ->withPHIDs($jira_phids) ->execute(); return mpull($xobjs, 'getObjectURI'); } protected function getHeraldFieldStandardType() { return self::STANDARD_TEXT_LIST; } }
php
Apache-2.0
5720a38cfe95b00ca4be5016dd0d2f3195f4fa04
2026-01-04T15:03:23.651835Z
false
phacility/phabricator
https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/differential/herald/DifferentialRevisionPackageHeraldField.php
src/applications/differential/herald/DifferentialRevisionPackageHeraldField.php
<?php final class DifferentialRevisionPackageHeraldField extends DifferentialRevisionHeraldField { const FIELDCONST = 'differential.revision.package'; public function getHeraldFieldName() { return pht('Affected packages'); } public function getFieldGroupKey() { return HeraldRelatedFieldGroup::FIELDGROUPKEY; } public function getHeraldFieldValue($object) { $packages = $this->getAdapter()->loadAffectedPackages(); return mpull($packages, 'getPHID'); } protected function getHeraldFieldStandardType() { return self::STANDARD_PHID_LIST; } protected function getDatasource() { return new PhabricatorOwnersPackageDatasource(); } }
php
Apache-2.0
5720a38cfe95b00ca4be5016dd0d2f3195f4fa04
2026-01-04T15:03:23.651835Z
false
phacility/phabricator
https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/differential/herald/DifferentialReviewersAddBlockingSelfHeraldAction.php
src/applications/differential/herald/DifferentialReviewersAddBlockingSelfHeraldAction.php
<?php final class DifferentialReviewersAddBlockingSelfHeraldAction extends DifferentialReviewersHeraldAction { const ACTIONCONST = 'differential.reviewers.self.blocking'; public function getHeraldActionName() { return pht('Add me as a blocking reviewer'); } public function supportsRuleType($rule_type) { return ($rule_type == HeraldRuleTypeConfig::RULE_TYPE_PERSONAL); } public function applyEffect($object, HeraldEffect $effect) { $phid = $effect->getRule()->getAuthorPHID(); return $this->applyReviewers(array($phid), $is_blocking = true); } public function getHeraldActionStandardType() { return self::STANDARD_NONE; } public function renderActionDescription($value) { return pht('Add rule author as blocking reviewer.'); } }
php
Apache-2.0
5720a38cfe95b00ca4be5016dd0d2f3195f4fa04
2026-01-04T15:03:23.651835Z
false
phacility/phabricator
https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/differential/herald/DifferentialDiffContentHeraldField.php
src/applications/differential/herald/DifferentialDiffContentHeraldField.php
<?php final class DifferentialDiffContentHeraldField extends DifferentialDiffHeraldField { const FIELDCONST = 'differential.diff.content'; public function getHeraldFieldName() { return pht('Changed file content'); } public function getFieldGroupKey() { return DifferentialChangeHeraldFieldGroup::FIELDGROUPKEY; } public function getHeraldFieldValue($object) { return $this->getAdapter()->loadContentDictionary(); } protected function getHeraldFieldStandardType() { return self::STANDARD_TEXT_MAP; } }
php
Apache-2.0
5720a38cfe95b00ca4be5016dd0d2f3195f4fa04
2026-01-04T15:03:23.651835Z
false
phacility/phabricator
https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/differential/herald/DifferentialDiffContentAddedHeraldField.php
src/applications/differential/herald/DifferentialDiffContentAddedHeraldField.php
<?php final class DifferentialDiffContentAddedHeraldField extends DifferentialDiffHeraldField { const FIELDCONST = 'differential.diff.new'; public function getHeraldFieldName() { return pht('Added file content'); } public function getFieldGroupKey() { return DifferentialChangeHeraldFieldGroup::FIELDGROUPKEY; } public function getHeraldFieldValue($object) { return $this->getAdapter()->loadAddedContentDictionary(); } protected function getHeraldFieldStandardType() { return self::STANDARD_TEXT_MAP; } }
php
Apache-2.0
5720a38cfe95b00ca4be5016dd0d2f3195f4fa04
2026-01-04T15:03:23.651835Z
false
phacility/phabricator
https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/differential/herald/DifferentialDiffHeraldFieldGroup.php
src/applications/differential/herald/DifferentialDiffHeraldFieldGroup.php
<?php final class DifferentialDiffHeraldFieldGroup extends HeraldFieldGroup { const FIELDGROUPKEY = 'differential.diff'; public function getGroupLabel() { return pht('Diff Fields'); } protected function getGroupOrder() { return 1000; } }
php
Apache-2.0
5720a38cfe95b00ca4be5016dd0d2f3195f4fa04
2026-01-04T15:03:23.651835Z
false
phacility/phabricator
https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/differential/herald/HeraldDifferentialRevisionAdapter.php
src/applications/differential/herald/HeraldDifferentialRevisionAdapter.php
<?php final class HeraldDifferentialRevisionAdapter extends HeraldDifferentialAdapter implements HarbormasterBuildableAdapterInterface { protected $revision; protected $affectedPackages; protected $changesets; private $haveHunks; private $buildRequests = array(); public function getAdapterApplicationClass() { return 'PhabricatorDifferentialApplication'; } protected function newObject() { return new DifferentialRevision(); } public function isTestAdapterForObject($object) { return ($object instanceof DifferentialRevision); } public function getAdapterTestDescription() { return pht( 'Test rules which run when a revision is created or updated.'); } public function newTestAdapter(PhabricatorUser $viewer, $object) { return self::newLegacyAdapter( $object, $object->loadActiveDiff()); } protected function initializeNewAdapter() { $this->revision = $this->newObject(); } public function getObject() { return $this->revision; } public function getAdapterContentType() { return 'differential'; } public function getAdapterContentName() { return pht('Differential Revisions'); } public function getAdapterContentDescription() { return pht( "React to revisions being created or updated.\n". "Revision rules can send email, flag revisions, add reviewers, ". "and run build plans."); } public function supportsRuleType($rule_type) { switch ($rule_type) { case HeraldRuleTypeConfig::RULE_TYPE_GLOBAL: case HeraldRuleTypeConfig::RULE_TYPE_PERSONAL: return true; case HeraldRuleTypeConfig::RULE_TYPE_OBJECT: default: return false; } } public static function newLegacyAdapter( DifferentialRevision $revision, DifferentialDiff $diff) { $object = new HeraldDifferentialRevisionAdapter(); // Reload the revision to pick up relationship information. $revision = id(new DifferentialRevisionQuery()) ->withIDs(array($revision->getID())) ->setViewer(PhabricatorUser::getOmnipotentUser()) ->needReviewers(true) ->executeOne(); $object->revision = $revision; $object->setDiff($diff); return $object; } public function getHeraldName() { return $this->revision->getTitle(); } protected function loadChangesets() { if ($this->changesets === null) { $this->changesets = $this->getDiff()->loadChangesets(); } return $this->changesets; } protected function loadChangesetsWithHunks() { $changesets = $this->loadChangesets(); if ($changesets && !$this->haveHunks) { $this->haveHunks = true; id(new DifferentialHunkQuery()) ->setViewer(PhabricatorUser::getOmnipotentUser()) ->withChangesets($changesets) ->needAttachToChangesets(true) ->execute(); } return $changesets; } public function loadAffectedPackages() { if ($this->affectedPackages === null) { $this->affectedPackages = array(); $repository = $this->loadRepository(); if ($repository) { $packages = PhabricatorOwnersPackage::loadAffectedPackagesForChangesets( $repository, $this->getDiff(), $this->loadChangesets()); $this->affectedPackages = $packages; } } return $this->affectedPackages; } public function loadReviewers() { return $this->getObject()->getReviewerPHIDs(); } /* -( HarbormasterBuildableAdapterInterface )------------------------------ */ public function getHarbormasterBuildablePHID() { return $this->getDiff()->getPHID(); } public function getHarbormasterContainerPHID() { return $this->getObject()->getPHID(); } public function getQueuedHarbormasterBuildRequests() { return $this->buildRequests; } public function queueHarbormasterBuildRequest( HarbormasterBuildRequest $request) { $this->buildRequests[] = $request; } }
php
Apache-2.0
5720a38cfe95b00ca4be5016dd0d2f3195f4fa04
2026-01-04T15:03:23.651835Z
false
phacility/phabricator
https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/differential/herald/DifferentialReviewersHeraldAction.php
src/applications/differential/herald/DifferentialReviewersHeraldAction.php
<?php abstract class DifferentialReviewersHeraldAction extends HeraldAction { const DO_AUTHORS = 'do.authors'; const DO_ADD_REVIEWERS = 'do.add-reviewers'; const DO_ADD_BLOCKING_REVIEWERS = 'do.add-blocking-reviewers'; public function getActionGroupKey() { return HeraldApplicationActionGroup::ACTIONGROUPKEY; } public function supportsObject($object) { return ($object instanceof DifferentialRevision); } protected function applyReviewers(array $phids, $is_blocking) { $adapter = $this->getAdapter(); $object = $adapter->getObject(); $phids = array_fuse($phids); // Don't try to add revision authors as reviewers. $authors = array(); foreach ($phids as $phid) { if ($phid == $object->getAuthorPHID()) { $authors[] = $phid; unset($phids[$phid]); } } if ($authors) { $this->logEffect(self::DO_AUTHORS, $authors); if (!$phids) { return; } } $reviewers = $object->getReviewers(); if ($is_blocking) { $new_status = DifferentialReviewerStatus::STATUS_BLOCKING; } else { $new_status = DifferentialReviewerStatus::STATUS_ADDED; } $new_strength = DifferentialReviewerStatus::getStatusStrength( $new_status); $current = array(); foreach ($phids as $phid) { if (!isset($reviewers[$phid])) { continue; } // If we're applying a stronger status (usually, upgrading a reviewer // into a blocking reviewer), skip this check so we apply the change. $old_strength = DifferentialReviewerStatus::getStatusStrength( $reviewers[$phid]->getReviewerStatus()); if ($old_strength <= $new_strength) { continue; } $current[] = $phid; } $allowed_types = array( PhabricatorPeopleUserPHIDType::TYPECONST, PhabricatorProjectProjectPHIDType::TYPECONST, PhabricatorOwnersPackagePHIDType::TYPECONST, ); $targets = $this->loadStandardTargets($phids, $allowed_types, $current); if (!$targets) { return; } $phids = array_fuse(array_keys($targets)); $value = array(); foreach ($phids as $phid) { if ($is_blocking) { $value[] = 'blocking('.$phid.')'; } else { $value[] = $phid; } } $reviewers_type = DifferentialRevisionReviewersTransaction::TRANSACTIONTYPE; $xaction = $adapter->newTransaction() ->setTransactionType($reviewers_type) ->setNewValue( array( '+' => $value, )); $adapter->queueTransaction($xaction); if ($is_blocking) { $this->logEffect(self::DO_ADD_BLOCKING_REVIEWERS, $phids); } else { $this->logEffect(self::DO_ADD_REVIEWERS, $phids); } } protected function getActionEffectMap() { return array( self::DO_AUTHORS => array( 'icon' => 'fa-user', 'color' => 'grey', 'name' => pht('Revision Author'), ), self::DO_ADD_REVIEWERS => array( 'icon' => 'fa-user', 'color' => 'green', 'name' => pht('Added Reviewers'), ), self::DO_ADD_BLOCKING_REVIEWERS => array( 'icon' => 'fa-user', 'color' => 'green', 'name' => pht('Added Blocking Reviewers'), ), ); } protected function renderActionEffectDescription($type, $data) { switch ($type) { case self::DO_AUTHORS: return pht( 'Declined to add revision author as reviewer: %s.', $this->renderHandleList($data)); case self::DO_ADD_REVIEWERS: return pht( 'Added %s reviewer(s): %s.', phutil_count($data), $this->renderHandleList($data)); case self::DO_ADD_BLOCKING_REVIEWERS: return pht( 'Added %s blocking reviewer(s): %s.', phutil_count($data), $this->renderHandleList($data)); } } }
php
Apache-2.0
5720a38cfe95b00ca4be5016dd0d2f3195f4fa04
2026-01-04T15:03:23.651835Z
false
phacility/phabricator
https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/differential/herald/DifferentialRevisionStatusHeraldField.php
src/applications/differential/herald/DifferentialRevisionStatusHeraldField.php
<?php final class DifferentialRevisionStatusHeraldField extends DifferentialRevisionHeraldField { const FIELDCONST = 'revision.status'; public function getHeraldFieldName() { return pht('Revision status'); } public function getHeraldFieldValue($object) { return $object->getStatus(); } protected function getHeraldFieldStandardType() { return self::STANDARD_PHID; } protected function getDatasource() { return new DifferentialRevisionStatusDatasource(); } protected function getDatasourceValueMap() { $map = DifferentialRevisionStatus::getAll(); return mpull($map, 'getDisplayName', 'getKey'); } }
php
Apache-2.0
5720a38cfe95b00ca4be5016dd0d2f3195f4fa04
2026-01-04T15:03:23.651835Z
false
phacility/phabricator
https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/differential/herald/DifferentialRevisionPackageOwnerHeraldField.php
src/applications/differential/herald/DifferentialRevisionPackageOwnerHeraldField.php
<?php final class DifferentialRevisionPackageOwnerHeraldField extends DifferentialRevisionHeraldField { const FIELDCONST = 'differential.revision.package.owners'; public function getHeraldFieldName() { return pht('Affected package owners'); } public function getFieldGroupKey() { return HeraldRelatedFieldGroup::FIELDGROUPKEY; } public function getHeraldFieldValue($object) { $packages = $this->getAdapter()->loadAffectedPackages(); if (!$packages) { return array(); } $owners = PhabricatorOwnersOwner::loadAllForPackages($packages); return mpull($owners, 'getUserPHID'); } protected function getHeraldFieldStandardType() { return self::STANDARD_PHID_LIST; } protected function getDatasource() { return new PhabricatorProjectOrUserDatasource(); } }
php
Apache-2.0
5720a38cfe95b00ca4be5016dd0d2f3195f4fa04
2026-01-04T15:03:23.651835Z
false
phacility/phabricator
https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/differential/herald/DifferentialDiffHeraldField.php
src/applications/differential/herald/DifferentialDiffHeraldField.php
<?php abstract class DifferentialDiffHeraldField extends HeraldField { public function supportsObject($object) { return ($object instanceof DifferentialDiff); } public function getFieldGroupKey() { return DifferentialDiffHeraldFieldGroup::FIELDGROUPKEY; } }
php
Apache-2.0
5720a38cfe95b00ca4be5016dd0d2f3195f4fa04
2026-01-04T15:03:23.651835Z
false
phacility/phabricator
https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/differential/herald/DifferentialRevisionTitleHeraldField.php
src/applications/differential/herald/DifferentialRevisionTitleHeraldField.php
<?php final class DifferentialRevisionTitleHeraldField extends DifferentialRevisionHeraldField { const FIELDCONST = 'differential.revision.title'; public function getHeraldFieldName() { return pht('Revision title'); } public function getHeraldFieldValue($object) { return $object->getTitle(); } protected function getHeraldFieldStandardType() { return self::STANDARD_TEXT; } }
php
Apache-2.0
5720a38cfe95b00ca4be5016dd0d2f3195f4fa04
2026-01-04T15:03:23.651835Z
false
phacility/phabricator
https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/differential/herald/DifferentialBlockHeraldAction.php
src/applications/differential/herald/DifferentialBlockHeraldAction.php
<?php final class DifferentialBlockHeraldAction extends HeraldAction { const ACTIONCONST = 'differential.block'; const DO_BLOCK = 'do.block'; public function getHeraldActionName() { return pht('Block diff with message'); } public function getActionGroupKey() { return HeraldApplicationActionGroup::ACTIONGROUPKEY; } public function supportsObject($object) { return ($object instanceof DifferentialDiff); } public function supportsRuleType($rule_type) { return ($rule_type != HeraldRuleTypeConfig::RULE_TYPE_PERSONAL); } public function applyEffect($object, HeraldEffect $effect) { // This rule intentionally has no direct effect: the caller handles it // after executing Herald. $this->logEffect(self::DO_BLOCK); } public function getHeraldActionStandardType() { return self::STANDARD_TEXT; } public function renderActionDescription($value) { return pht('Block diff with message: %s', $value); } protected function getActionEffectMap() { return array( self::DO_BLOCK => array( 'icon' => 'fa-stop', 'color' => 'red', 'name' => pht('Blocked Diff'), ), ); } protected function renderActionEffectDescription($type, $data) { switch ($type) { case self::DO_BLOCK: return pht('Blocked diff.'); } } }
php
Apache-2.0
5720a38cfe95b00ca4be5016dd0d2f3195f4fa04
2026-01-04T15:03:23.651835Z
false
phacility/phabricator
https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/differential/herald/DifferentialRevisionSummaryHeraldField.php
src/applications/differential/herald/DifferentialRevisionSummaryHeraldField.php
<?php final class DifferentialRevisionSummaryHeraldField extends DifferentialRevisionHeraldField { const FIELDCONST = 'differential.revision.summary'; public function getHeraldFieldName() { return pht('Revision summary'); } public function getHeraldFieldValue($object) { return $object->getSummary(); } protected function getHeraldFieldStandardType() { return self::STANDARD_TEXT; } }
php
Apache-2.0
5720a38cfe95b00ca4be5016dd0d2f3195f4fa04
2026-01-04T15:03:23.651835Z
false
phacility/phabricator
https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/differential/herald/DifferentialDiffAffectedFilesHeraldField.php
src/applications/differential/herald/DifferentialDiffAffectedFilesHeraldField.php
<?php final class DifferentialDiffAffectedFilesHeraldField extends DifferentialDiffHeraldField { const FIELDCONST = 'differential.diff.affected'; public function getHeraldFieldName() { return pht('Affected files'); } public function getFieldGroupKey() { return DifferentialChangeHeraldFieldGroup::FIELDGROUPKEY; } public function getHeraldFieldValue($object) { return $this->getAdapter()->loadAffectedPaths(); } protected function getHeraldFieldStandardType() { return self::STANDARD_TEXT_LIST; } }
php
Apache-2.0
5720a38cfe95b00ca4be5016dd0d2f3195f4fa04
2026-01-04T15:03:23.651835Z
false
phacility/phabricator
https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/differential/herald/DifferentialRevisionRepositoryHeraldField.php
src/applications/differential/herald/DifferentialRevisionRepositoryHeraldField.php
<?php final class DifferentialRevisionRepositoryHeraldField extends DifferentialRevisionHeraldField { const FIELDCONST = 'differential.revision.repository'; public function getHeraldFieldName() { return pht('Repository'); } public function getHeraldFieldValue($object) { $repository = $this->getAdapter()->loadRepository(); if (!$repository) { return null; } return $repository->getPHID(); } protected function getHeraldFieldStandardType() { return self::STANDARD_PHID_NULLABLE; } protected function getDatasource() { return new DiffusionRepositoryDatasource(); } }
php
Apache-2.0
5720a38cfe95b00ca4be5016dd0d2f3195f4fa04
2026-01-04T15:03:23.651835Z
false
phacility/phabricator
https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/differential/herald/DifferentialRevisionRepositoryProjectsHeraldField.php
src/applications/differential/herald/DifferentialRevisionRepositoryProjectsHeraldField.php
<?php final class DifferentialRevisionRepositoryProjectsHeraldField extends DifferentialRevisionHeraldField { const FIELDCONST = 'differential.revision.repository.projects'; public function getHeraldFieldName() { return pht('Repository projects'); } public function getHeraldFieldValue($object) { $repository = $this->getAdapter()->loadRepository(); if (!$repository) { return array(); } return PhabricatorEdgeQuery::loadDestinationPHIDs( $repository->getPHID(), PhabricatorProjectObjectHasProjectEdgeType::EDGECONST); } protected function getHeraldFieldStandardType() { return self::STANDARD_PHID_LIST; } protected function getDatasource() { return new PhabricatorProjectDatasource(); } }
php
Apache-2.0
5720a38cfe95b00ca4be5016dd0d2f3195f4fa04
2026-01-04T15:03:23.651835Z
false
phacility/phabricator
https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/differential/herald/DifferentialHeraldStateReasons.php
src/applications/differential/herald/DifferentialHeraldStateReasons.php
<?php final class DifferentialHeraldStateReasons extends HeraldStateReasons { const REASON_DRAFT = 'differential.draft'; const REASON_UNCHANGED = 'differential.unchanged'; const REASON_LANDED = 'differential.landed'; public function explainReason($reason) { $reasons = array( self::REASON_DRAFT => pht( 'This revision is still an unsubmitted draft, so mail will not '. 'be sent yet.'), self::REASON_UNCHANGED => pht( 'The update which triggered Herald did not update the diff for '. 'this revision, so builds will not run.'), self::REASON_LANDED => pht( 'The update which triggered Herald was an automatic update in '. 'response to discovering a commit, so builds will not run.'), ); return idx($reasons, $reason); } }
php
Apache-2.0
5720a38cfe95b00ca4be5016dd0d2f3195f4fa04
2026-01-04T15:03:23.651835Z
false
phacility/phabricator
https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/differential/herald/DifferentialRevisionContentHeraldField.php
src/applications/differential/herald/DifferentialRevisionContentHeraldField.php
<?php final class DifferentialRevisionContentHeraldField extends DifferentialRevisionHeraldField { const FIELDCONST = 'differential.revision.diff.content'; public function getHeraldFieldName() { return pht('Changed file content'); } public function getFieldGroupKey() { return DifferentialChangeHeraldFieldGroup::FIELDGROUPKEY; } public function getHeraldFieldValue($object) { return $this->getAdapter()->loadContentDictionary(); } protected function getHeraldFieldStandardType() { return self::STANDARD_TEXT_MAP; } }
php
Apache-2.0
5720a38cfe95b00ca4be5016dd0d2f3195f4fa04
2026-01-04T15:03:23.651835Z
false
phacility/phabricator
https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/differential/herald/DifferentialRevisionAuthorPackagesHeraldField.php
src/applications/differential/herald/DifferentialRevisionAuthorPackagesHeraldField.php
<?php final class DifferentialRevisionAuthorPackagesHeraldField extends DifferentialRevisionHeraldField { const FIELDCONST = 'differential.revision.author.packages'; public function getHeraldFieldName() { return pht("Author's packages"); } public function getHeraldFieldValue($object) { $adapter = $this->getAdapter(); $viewer = $adapter->getViewer(); $packages = id(new PhabricatorOwnersPackageQuery()) ->setViewer($viewer) ->withAuthorityPHIDs(array($object->getAuthorPHID())) ->execute(); return mpull($packages, 'getPHID'); } protected function getHeraldFieldStandardType() { return self::STANDARD_PHID_LIST; } protected function getDatasource() { return new PhabricatorOwnersPackageDatasource(); } }
php
Apache-2.0
5720a38cfe95b00ca4be5016dd0d2f3195f4fa04
2026-01-04T15:03:23.651835Z
false
phacility/phabricator
https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/differential/herald/HeraldDifferentialDiffAdapter.php
src/applications/differential/herald/HeraldDifferentialDiffAdapter.php
<?php final class HeraldDifferentialDiffAdapter extends HeraldDifferentialAdapter { public function getAdapterApplicationClass() { return 'PhabricatorDifferentialApplication'; } protected function initializeNewAdapter() { $this->setDiff(new DifferentialDiff()); } public function isSingleEventAdapter() { return true; } protected function loadChangesets() { return $this->loadChangesetsWithHunks(); } protected function loadChangesetsWithHunks() { return $this->getDiff()->getChangesets(); } public function getObject() { return $this->getDiff(); } public function getAdapterContentType() { return 'differential.diff'; } public function getAdapterContentName() { return pht('Differential Diffs'); } public function getAdapterContentDescription() { return pht( "React to new diffs being uploaded, before writes occur.\n". "These rules can reject diffs before they are written to permanent ". "storage, to prevent users from accidentally uploading private keys or ". "other sensitive information."); } public function supportsRuleType($rule_type) { switch ($rule_type) { case HeraldRuleTypeConfig::RULE_TYPE_GLOBAL: return true; case HeraldRuleTypeConfig::RULE_TYPE_OBJECT: case HeraldRuleTypeConfig::RULE_TYPE_PERSONAL: default: return false; } } public function getHeraldName() { return pht('New Diff'); } public function supportsWebhooks() { return false; } }
php
Apache-2.0
5720a38cfe95b00ca4be5016dd0d2f3195f4fa04
2026-01-04T15:03:23.651835Z
false
phacility/phabricator
https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/differential/herald/DifferentialDiffAuthorProjectsHeraldField.php
src/applications/differential/herald/DifferentialDiffAuthorProjectsHeraldField.php
<?php final class DifferentialDiffAuthorProjectsHeraldField extends DifferentialDiffHeraldField { const FIELDCONST = 'differential.diff.author.projects'; public function getHeraldFieldName() { return pht("Author's projects"); } public function getHeraldFieldValue($object) { $viewer = PhabricatorUser::getOmnipotentUser(); $projects = id(new PhabricatorProjectQuery()) ->setViewer($viewer) ->withMemberPHIDs(array($object->getAuthorPHID())) ->execute(); return mpull($projects, 'getPHID'); } protected function getHeraldFieldStandardType() { return self::STANDARD_PHID_LIST; } protected function getDatasource() { return new PhabricatorProjectDatasource(); } }
php
Apache-2.0
5720a38cfe95b00ca4be5016dd0d2f3195f4fa04
2026-01-04T15:03:23.651835Z
false
phacility/phabricator
https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/differential/herald/DifferentialReviewersAddReviewersHeraldAction.php
src/applications/differential/herald/DifferentialReviewersAddReviewersHeraldAction.php
<?php final class DifferentialReviewersAddReviewersHeraldAction extends DifferentialReviewersHeraldAction { const ACTIONCONST = 'differential.reviewers.add'; public function getHeraldActionName() { return pht('Add reviewers'); } public function supportsRuleType($rule_type) { return ($rule_type != HeraldRuleTypeConfig::RULE_TYPE_PERSONAL); } public function applyEffect($object, HeraldEffect $effect) { return $this->applyReviewers($effect->getTarget(), $is_blocking = false); } public function getHeraldActionStandardType() { return self::STANDARD_PHID_LIST; } protected function getDatasource() { return new DiffusionAuditorDatasource(); } public function renderActionDescription($value) { return pht('Add reviewers: %s.', $this->renderHandleList($value)); } public function getPHIDsAffectedByAction(HeraldActionRecord $record) { return $record->getTarget(); } }
php
Apache-2.0
5720a38cfe95b00ca4be5016dd0d2f3195f4fa04
2026-01-04T15:03:23.651835Z
false
phacility/phabricator
https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/differential/herald/DifferentialRevisionTestPlanHeraldField.php
src/applications/differential/herald/DifferentialRevisionTestPlanHeraldField.php
<?php final class DifferentialRevisionTestPlanHeraldField extends DifferentialRevisionHeraldField { const FIELDCONST = 'differential.revision.test-plan'; public function getHeraldFieldName() { return pht('Revision test plan'); } public function getHeraldFieldValue($object) { return $object->getTestPlan(); } protected function getHeraldFieldStandardType() { return self::STANDARD_TEXT; } }
php
Apache-2.0
5720a38cfe95b00ca4be5016dd0d2f3195f4fa04
2026-01-04T15:03:23.651835Z
false
phacility/phabricator
https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/differential/herald/DifferentialRevisionAuthorHeraldField.php
src/applications/differential/herald/DifferentialRevisionAuthorHeraldField.php
<?php final class DifferentialRevisionAuthorHeraldField extends DifferentialRevisionHeraldField { const FIELDCONST = 'differential.revision.author'; public function getHeraldFieldName() { return pht('Author'); } public function getHeraldFieldValue($object) { return $object->getAuthorPHID(); } protected function getHeraldFieldStandardType() { return self::STANDARD_PHID; } protected function getDatasource() { return new PhabricatorPeopleDatasource(); } }
php
Apache-2.0
5720a38cfe95b00ca4be5016dd0d2f3195f4fa04
2026-01-04T15:03:23.651835Z
false
phacility/phabricator
https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/differential/herald/DifferentialRevisionHeraldField.php
src/applications/differential/herald/DifferentialRevisionHeraldField.php
<?php abstract class DifferentialRevisionHeraldField extends HeraldField { public function supportsObject($object) { return ($object instanceof DifferentialRevision); } public function getFieldGroupKey() { return DifferentialRevisionHeraldFieldGroup::FIELDGROUPKEY; } }
php
Apache-2.0
5720a38cfe95b00ca4be5016dd0d2f3195f4fa04
2026-01-04T15:03:23.651835Z
false
phacility/phabricator
https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/differential/herald/DifferentialRevisionHeraldFieldGroup.php
src/applications/differential/herald/DifferentialRevisionHeraldFieldGroup.php
<?php final class DifferentialRevisionHeraldFieldGroup extends HeraldFieldGroup { const FIELDGROUPKEY = 'differential.revision'; public function getGroupLabel() { return pht('Revision Fields'); } protected function getGroupOrder() { return 1000; } }
php
Apache-2.0
5720a38cfe95b00ca4be5016dd0d2f3195f4fa04
2026-01-04T15:03:23.651835Z
false
phacility/phabricator
https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/differential/herald/DifferentialRevisionAffectedFilesHeraldField.php
src/applications/differential/herald/DifferentialRevisionAffectedFilesHeraldField.php
<?php final class DifferentialRevisionAffectedFilesHeraldField extends DifferentialRevisionHeraldField { const FIELDCONST = 'differential.revision.diff.affected'; public function getHeraldFieldName() { return pht('Affected files'); } public function getFieldGroupKey() { return DifferentialChangeHeraldFieldGroup::FIELDGROUPKEY; } public function getHeraldFieldValue($object) { return $this->getAdapter()->loadAffectedPaths(); } protected function getHeraldFieldStandardType() { return self::STANDARD_TEXT_LIST; } }
php
Apache-2.0
5720a38cfe95b00ca4be5016dd0d2f3195f4fa04
2026-01-04T15:03:23.651835Z
false
phacility/phabricator
https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/differential/herald/DifferentialDiffContentRemovedHeraldField.php
src/applications/differential/herald/DifferentialDiffContentRemovedHeraldField.php
<?php final class DifferentialDiffContentRemovedHeraldField extends DifferentialDiffHeraldField { const FIELDCONST = 'differential.diff.old'; public function getHeraldFieldName() { return pht('Removed file content'); } public function getFieldGroupKey() { return DifferentialChangeHeraldFieldGroup::FIELDGROUPKEY; } public function getHeraldFieldValue($object) { return $this->getAdapter()->loadRemovedContentDictionary(); } protected function getHeraldFieldStandardType() { return self::STANDARD_TEXT_MAP; } }
php
Apache-2.0
5720a38cfe95b00ca4be5016dd0d2f3195f4fa04
2026-01-04T15:03:23.651835Z
false
phacility/phabricator
https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/differential/herald/DifferentialRevisionAuthorProjectsHeraldField.php
src/applications/differential/herald/DifferentialRevisionAuthorProjectsHeraldField.php
<?php final class DifferentialRevisionAuthorProjectsHeraldField extends DifferentialRevisionHeraldField { const FIELDCONST = 'differential.revision.author.projects'; public function getHeraldFieldName() { return pht("Author's projects"); } public function getHeraldFieldValue($object) { $viewer = PhabricatorUser::getOmnipotentUser(); $projects = id(new PhabricatorProjectQuery()) ->setViewer($viewer) ->withMemberPHIDs(array($object->getAuthorPHID())) ->execute(); return mpull($projects, 'getPHID'); } protected function getHeraldFieldStandardType() { return self::STANDARD_PHID_LIST; } protected function getDatasource() { return new PhabricatorProjectDatasource(); } }
php
Apache-2.0
5720a38cfe95b00ca4be5016dd0d2f3195f4fa04
2026-01-04T15:03:23.651835Z
false
phacility/phabricator
https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/differential/herald/DifferentialReviewersAddSelfHeraldAction.php
src/applications/differential/herald/DifferentialReviewersAddSelfHeraldAction.php
<?php final class DifferentialReviewersAddSelfHeraldAction extends DifferentialReviewersHeraldAction { const ACTIONCONST = 'differential.reviewers.self.add'; public function getHeraldActionName() { return pht('Add me as a reviewer'); } public function supportsRuleType($rule_type) { return ($rule_type == HeraldRuleTypeConfig::RULE_TYPE_PERSONAL); } public function applyEffect($object, HeraldEffect $effect) { $phid = $effect->getRule()->getAuthorPHID(); return $this->applyReviewers(array($phid), $is_blocking = false); } public function getHeraldActionStandardType() { return self::STANDARD_NONE; } public function renderActionDescription($value) { return pht('Add rule author as reviewer.'); } }
php
Apache-2.0
5720a38cfe95b00ca4be5016dd0d2f3195f4fa04
2026-01-04T15:03:23.651835Z
false
phacility/phabricator
https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/differential/herald/DifferentialReviewersAddBlockingReviewersHeraldAction.php
src/applications/differential/herald/DifferentialReviewersAddBlockingReviewersHeraldAction.php
<?php final class DifferentialReviewersAddBlockingReviewersHeraldAction extends DifferentialReviewersHeraldAction { const ACTIONCONST = 'differential.reviewers.blocking'; public function getHeraldActionName() { return pht('Add blocking reviewers'); } public function supportsRuleType($rule_type) { return ($rule_type != HeraldRuleTypeConfig::RULE_TYPE_PERSONAL); } public function applyEffect($object, HeraldEffect $effect) { return $this->applyReviewers($effect->getTarget(), $is_blocking = true); } public function getHeraldActionStandardType() { return self::STANDARD_PHID_LIST; } protected function getDatasource() { return new DiffusionAuditorDatasource(); } public function renderActionDescription($value) { return pht('Add blocking reviewers: %s.', $this->renderHandleList($value)); } public function getPHIDsAffectedByAction(HeraldActionRecord $record) { return $record->getTarget(); } }
php
Apache-2.0
5720a38cfe95b00ca4be5016dd0d2f3195f4fa04
2026-01-04T15:03:23.651835Z
false
phacility/phabricator
https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/differential/herald/DifferentialDiffRepositoryProjectsHeraldField.php
src/applications/differential/herald/DifferentialDiffRepositoryProjectsHeraldField.php
<?php final class DifferentialDiffRepositoryProjectsHeraldField extends DifferentialDiffHeraldField { const FIELDCONST = 'differential.diff.repository.projects'; public function getHeraldFieldName() { return pht('Repository projects'); } public function getHeraldFieldValue($object) { $repository = $this->getAdapter()->loadRepository(); if (!$repository) { return array(); } return PhabricatorEdgeQuery::loadDestinationPHIDs( $repository->getPHID(), PhabricatorProjectObjectHasProjectEdgeType::EDGECONST); } protected function getHeraldFieldStandardType() { return self::STANDARD_PHID_LIST; } protected function getDatasource() { return new PhabricatorProjectDatasource(); } }
php
Apache-2.0
5720a38cfe95b00ca4be5016dd0d2f3195f4fa04
2026-01-04T15:03:23.651835Z
false
phacility/phabricator
https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/differential/herald/DifferentialDiffAuthorHeraldField.php
src/applications/differential/herald/DifferentialDiffAuthorHeraldField.php
<?php final class DifferentialDiffAuthorHeraldField extends DifferentialDiffHeraldField { const FIELDCONST = 'differential.diff.author'; public function getHeraldFieldName() { return pht('Author'); } public function getHeraldFieldValue($object) { return $object->getAuthorPHID(); } protected function getHeraldFieldStandardType() { return self::STANDARD_PHID; } protected function getDatasource() { return new PhabricatorPeopleDatasource(); } }
php
Apache-2.0
5720a38cfe95b00ca4be5016dd0d2f3195f4fa04
2026-01-04T15:03:23.651835Z
false
phacility/phabricator
https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/differential/herald/DifferentialRevisionContentRemovedHeraldField.php
src/applications/differential/herald/DifferentialRevisionContentRemovedHeraldField.php
<?php final class DifferentialRevisionContentRemovedHeraldField extends DifferentialRevisionHeraldField { const FIELDCONST = 'differential.revision.diff.old'; public function getHeraldFieldName() { return pht('Removed file content'); } public function getFieldGroupKey() { return DifferentialChangeHeraldFieldGroup::FIELDGROUPKEY; } public function getHeraldFieldValue($object) { return $this->getAdapter()->loadRemovedContentDictionary(); } protected function getHeraldFieldStandardType() { return self::STANDARD_TEXT_MAP; } }
php
Apache-2.0
5720a38cfe95b00ca4be5016dd0d2f3195f4fa04
2026-01-04T15:03:23.651835Z
false
phacility/phabricator
https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/differential/herald/DifferentialRevisionReviewersHeraldField.php
src/applications/differential/herald/DifferentialRevisionReviewersHeraldField.php
<?php final class DifferentialRevisionReviewersHeraldField extends DifferentialRevisionHeraldField { const FIELDCONST = 'differential.revision.reviewers'; public function getHeraldFieldName() { return pht('Reviewers'); } public function getHeraldFieldValue($object) { return $this->getAdapter()->loadReviewers(); } protected function getHeraldFieldStandardType() { return self::STANDARD_PHID_LIST; } protected function getDatasource() { return new PhabricatorProjectOrUserDatasource(); } }
php
Apache-2.0
5720a38cfe95b00ca4be5016dd0d2f3195f4fa04
2026-01-04T15:03:23.651835Z
false
phacility/phabricator
https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/differential/herald/DifferentialChangeHeraldFieldGroup.php
src/applications/differential/herald/DifferentialChangeHeraldFieldGroup.php
<?php final class DifferentialChangeHeraldFieldGroup extends HeraldFieldGroup { const FIELDGROUPKEY = 'differential.change'; public function getGroupLabel() { return pht('Change Details'); } protected function getGroupOrder() { return 1500; } }
php
Apache-2.0
5720a38cfe95b00ca4be5016dd0d2f3195f4fa04
2026-01-04T15:03:23.651835Z
false
phacility/phabricator
https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/differential/render/DifferentialChangesetTestRenderer.php
src/applications/differential/render/DifferentialChangesetTestRenderer.php
<?php abstract class DifferentialChangesetTestRenderer extends DifferentialChangesetRenderer { protected function renderChangeTypeHeader($force) { $changeset = $this->getChangeset(); $old = nonempty($changeset->getOldFile(), '-'); $current = nonempty($changeset->getFilename(), '-'); $away = nonempty(implode(', ', $changeset->getAwayPaths()), '-'); $ctype = $changeset->getChangeType(); $ftype = $changeset->getFileType(); $force = ($force ? '(forced)' : '(unforced)'); return "CTYPE {$ctype} {$ftype} {$force}\n". "{$old}\n". "{$current}\n". "{$away}\n"; } protected function renderUndershieldHeader() { return null; } public function renderShield($message, $force = 'default') { return "SHIELD ({$force}) {$message}\n"; } protected function renderPropertyChangeHeader() { $changeset = $this->getChangeset(); list($old, $new) = $this->getChangesetProperties($changeset); foreach (array_keys($old) as $key) { if ($old[$key] === idx($new, $key)) { unset($old[$key]); unset($new[$key]); } } if (!$old && !$new) { return null; } $props = ''; foreach ($old as $key => $value) { $props .= "P - {$key} {$value}~\n"; } foreach ($new as $key => $value) { $props .= "P + {$key} {$value}~\n"; } return "PROPERTIES\n".$props; } public function renderTextChange( $range_start, $range_len, $rows) { $out = array(); $any_old = false; $any_new = false; $primitives = $this->buildPrimitives($range_start, $range_len); foreach ($primitives as $p) { $type = $p['type']; switch ($type) { case 'old': case 'new': if ($type == 'old') { $any_old = true; } if ($type == 'new') { $any_new = true; } $num = nonempty($p['line'], '-'); $render = (string)$p['render']; $htype = nonempty($p['htype'], '.'); // TODO: This should probably happen earlier, whenever we deal with // \r and \t normalization? $render = str_replace( array( "\r", "\n", ), array( '\\r', '\\n', ), $render); $render = str_replace( array( '<span class="bright">', '</span>', '<span class="depth-out">', '<span class="depth-in">', ), array( '{(', ')}', '{<', '{>', ), $render); $render = html_entity_decode($render, ENT_QUOTES); $t = ($type == 'old') ? 'O' : 'N'; $out[] = "{$t} {$num} {$htype} {$render}~"; break; case 'no-context': $out[] = 'X <MISSING-CONTEXT>'; break; default: $out[] = $type; break; } } if (!$any_old) { $out[] = 'O X <EMPTY>'; } if (!$any_new) { $out[] = 'N X <EMPTY>'; } $out = implode("\n", $out)."\n"; return phutil_safe_html($out); } }
php
Apache-2.0
5720a38cfe95b00ca4be5016dd0d2f3195f4fa04
2026-01-04T15:03:23.651835Z
false
phacility/phabricator
https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/differential/render/DifferentialChangesetOneUpRenderer.php
src/applications/differential/render/DifferentialChangesetOneUpRenderer.php
<?php final class DifferentialChangesetOneUpRenderer extends DifferentialChangesetHTMLRenderer { private $simpleMode; public function setSimpleMode($simple_mode) { $this->simpleMode = $simple_mode; return $this; } public function getSimpleMode() { return $this->simpleMode; } public function isOneUpRenderer() { return true; } protected function getRendererTableClass() { return 'diff-1up'; } public function getRendererKey() { return '1up'; } protected function renderColgroup() { return phutil_tag('colgroup', array(), array( phutil_tag('col', array('class' => 'num')), phutil_tag('col', array('class' => 'num')), phutil_tag('col', array('class' => 'copy')), phutil_tag('col', array('class' => 'unified')), )); } public function renderTextChange( $range_start, $range_len, $rows) { $primitives = $this->buildPrimitives($range_start, $range_len); return $this->renderPrimitives($primitives, $rows); } protected function renderPrimitives(array $primitives, $rows) { list($left_prefix, $right_prefix) = $this->getLineIDPrefixes(); $is_simple = $this->getSimpleMode(); $no_copy = phutil_tag('td', array('class' => 'copy')); $no_coverage = null; $column_width = 4; $aural_minus = javelin_tag( 'span', array( 'aural' => true, 'data-aural' => true, ), '- '); $aural_plus = javelin_tag( 'span', array( 'aural' => true, 'data-aural' => true, ), '+ '); $out = array(); foreach ($primitives as $k => $p) { $type = $p['type']; switch ($type) { case 'old': case 'new': case 'old-file': case 'new-file': $is_old = ($type == 'old' || $type == 'old-file'); $cells = array(); if ($is_old) { if ($p['htype']) { if ($p['htype'] === '\\') { $class = 'comment'; } else if (empty($p['oline'])) { $class = 'left old old-full'; } else { $class = 'left old'; } $aural = $aural_minus; } else { $class = 'left'; $aural = null; } if ($type == 'old-file') { $class = "{$class} differential-old-image"; } if ($left_prefix) { $left_id = $left_prefix.$p['line']; } else { $left_id = null; } $line = $p['line']; $cells[] = phutil_tag( 'td', array( 'id' => $left_id, 'class' => $class.' n', 'data-n' => $line, )); $render = $p['render']; if ($aural !== null) { $render = array($aural, $render); } $cells[] = phutil_tag( 'td', array( 'class' => $class.' n', )); $cells[] = $no_copy; $cells[] = phutil_tag('td', array('class' => $class), $render); $cells[] = $no_coverage; } else { if ($p['htype']) { if ($p['htype'] === '\\') { $class = 'comment'; } else if (empty($p['oline'])) { $class = 'right new new-full'; } else { $class = 'right new'; } $cells[] = phutil_tag( 'td', array( 'class' => $class.' n', )); $aural = $aural_plus; } else { $class = 'right'; if ($left_prefix) { $left_id = $left_prefix.$p['oline']; } else { $left_id = null; } $oline = $p['oline']; $cells[] = phutil_tag( 'td', array( 'id' => $left_id, 'class' => 'n', 'data-n' => $oline, )); $aural = null; } if ($type == 'new-file') { $class = "{$class} differential-new-image"; } if ($right_prefix) { $right_id = $right_prefix.$p['line']; } else { $right_id = null; } $line = $p['line']; $cells[] = phutil_tag( 'td', array( 'id' => $right_id, 'class' => $class.' n', 'data-n' => $line, )); $render = $p['render']; if ($aural !== null) { $render = array($aural, $render); } $cells[] = $no_copy; $cells[] = phutil_tag( 'td', array( 'class' => $class, 'data-copy-mode' => 'copy-unified', ), $render); $cells[] = $no_coverage; } // In simple mode, only render the text. This is used to render // "Edit Suggestions" in inline comments. if ($is_simple) { $cells = array($cells[3]); } $out[] = phutil_tag('tr', array(), $cells); break; case 'inline': $inline = $this->buildInlineComment( $p['comment'], $p['right']); $out[] = $this->getRowScaffoldForInline($inline); break; case 'no-context': $out[] = phutil_tag( 'tr', array(), phutil_tag( 'td', array( 'class' => 'show-more', 'colspan' => $column_width, ), pht('Context not available.'))); break; case 'context': $top = $p['top']; $len = $p['len']; $links = $this->renderShowContextLinks($top, $len, $rows); $out[] = javelin_tag( 'tr', array( 'sigil' => 'context-target', ), phutil_tag( 'td', array( 'class' => 'show-more', 'colspan' => $column_width, ), $links)); break; default: $out[] = hsprintf('<tr><th /><th /><td>%s</td></tr>', $type); break; } } $result = null; if ($out) { if ($is_simple) { $result = $this->newSimpleTable($out); } else { $result = $this->wrapChangeInTable(phutil_implode_html('', $out)); } } return $result; } public function renderDocumentEngineBlocks( PhabricatorDocumentEngineBlocks $block_list, $old_changeset_key, $new_changeset_key) { $engine = $this->getDocumentEngine(); $layout = $block_list->newTwoUpLayout(); $old_comments = $this->getOldComments(); $new_comments = $this->getNewComments(); $unchanged = array(); foreach ($layout as $key => $row) { list($old, $new) = $row; if (!$old) { continue; } if (!$new) { continue; } if ($old->getDifferenceType() !== null) { continue; } if ($new->getDifferenceType() !== null) { continue; } $unchanged[$key] = true; } $rows = array(); $count = count($layout); for ($ii = 0; $ii < $count;) { $start = $ii; for ($jj = $ii; $jj < $count; $jj++) { list($old, $new) = $layout[$jj]; if (empty($unchanged[$jj])) { break; } $rows[] = array( 'type' => 'unchanged', 'layoutKey' => $jj, ); } $ii = $jj; for ($jj = $ii; $jj < $count; $jj++) { list($old, $new) = $layout[$jj]; if (!empty($unchanged[$jj])) { break; } $rows[] = array( 'type' => 'old', 'layoutKey' => $jj, ); } for ($jj = $ii; $jj < $count; $jj++) { list($old, $new) = $layout[$jj]; if (!empty($unchanged[$jj])) { break; } $rows[] = array( 'type' => 'new', 'layoutKey' => $jj, ); } $ii = $jj; // We always expect to consume at least one row when iterating through // the loop and make progress. If we don't, bail out to avoid spinning // to death. if ($ii === $start) { throw new Exception( pht( 'Failed to make progress during 1up diff layout.')); } } $old_ref = null; $new_ref = null; $refs = $block_list->getDocumentRefs(); if ($refs) { list($old_ref, $new_ref) = $refs; } $view = array(); foreach ($rows as $row) { $row_type = $row['type']; $layout_key = $row['layoutKey']; $row_layout = $layout[$layout_key]; list($old, $new) = $row_layout; if ($old) { $old_key = $old->getBlockKey(); } else { $old_key = null; } if ($new) { $new_key = $new->getBlockKey(); } else { $new_key = null; } $cells = array(); $cell_classes = array(); if ($row_type === 'unchanged') { $cell_content = $engine->newBlockContentView( $old_ref, $old); } else if ($old && $new) { $block_diff = $engine->newBlockDiffViews( $old_ref, $old, $new_ref, $new); // TODO: We're currently double-rendering this: once when building // the old row, and once when building the new one. In both cases, // we throw away the other half of the output. We could cache this // to improve performance. if ($row_type === 'old') { $cell_content = $block_diff->getOldContent(); $cell_classes = $block_diff->getOldClasses(); } else { $cell_content = $block_diff->getNewContent(); $cell_classes = $block_diff->getNewClasses(); } } else if ($row_type === 'old') { if (!$old_ref || !$old) { continue; } $cell_content = $engine->newBlockContentView( $old_ref, $old); $cell_classes[] = 'old'; $cell_classes[] = 'old-full'; $new_key = null; } else if ($row_type === 'new') { if (!$new_ref || !$new) { continue; } $cell_content = $engine->newBlockContentView( $new_ref, $new); $cell_classes[] = 'new'; $cell_classes[] = 'new-full'; $old_key = null; } if ($old_key === null) { $old_id = null; } else { $old_id = "C{$old_changeset_key}OL{$old_key}"; } if ($new_key === null) { $new_id = null; } else { $new_id = "C{$new_changeset_key}NL{$new_key}"; } $cells[] = phutil_tag( 'td', array( 'id' => $old_id, 'data-n' => $old_key, 'class' => 'n', )); $cells[] = phutil_tag( 'td', array( 'id' => $new_id, 'data-n' => $new_key, 'class' => 'n', )); $cells[] = phutil_tag( 'td', array( 'class' => 'copy', )); $cell_classes[] = 'diff-flush'; $cell_classes = implode(' ', $cell_classes); $cells[] = phutil_tag( 'td', array( 'class' => $cell_classes, 'data-copy-mode' => 'copy-unified', ), $cell_content); $view[] = phutil_tag( 'tr', array(), $cells); if ($old_key !== null) { $old_inlines = idx($old_comments, $old_key, array()); foreach ($old_inlines as $inline) { $inline = $this->buildInlineComment( $inline, $on_right = false); $view[] = $this->getRowScaffoldForInline($inline); } } if ($new_key !== null) { $new_inlines = idx($new_comments, $new_key, array()); foreach ($new_inlines as $inline) { $inline = $this->buildInlineComment( $inline, $on_right = true); $view[] = $this->getRowScaffoldForInline($inline); } } } $output = $this->wrapChangeInTable($view); return $this->renderChangesetTable($output); } public function getRowScaffoldForInline(PHUIDiffInlineCommentView $view) { return id(new PHUIDiffOneUpInlineCommentRowScaffold()) ->addInlineView($view); } private function newSimpleTable($content) { return phutil_tag( 'table', array( 'class' => 'diff-1up-simple-table', ), $content); } }
php
Apache-2.0
5720a38cfe95b00ca4be5016dd0d2f3195f4fa04
2026-01-04T15:03:23.651835Z
false
phacility/phabricator
https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/differential/render/DifferentialChangesetTwoUpRenderer.php
src/applications/differential/render/DifferentialChangesetTwoUpRenderer.php
<?php final class DifferentialChangesetTwoUpRenderer extends DifferentialChangesetHTMLRenderer { private $newOffsetMap; public function isOneUpRenderer() { return false; } protected function getRendererTableClass() { return 'diff-2up'; } public function getRendererKey() { return '2up'; } protected function renderColgroup() { return phutil_tag('colgroup', array(), array( phutil_tag('col', array('class' => 'num')), phutil_tag('col', array('class' => 'left')), phutil_tag('col', array('class' => 'num')), phutil_tag('col', array('class' => 'copy')), phutil_tag('col', array('class' => 'right')), phutil_tag('col', array('class' => 'cov')), )); } public function renderTextChange( $range_start, $range_len, $rows) { $hunk_starts = $this->getHunkStartLines(); $context_not_available = null; if ($hunk_starts) { $context_not_available = javelin_tag( 'tr', array( 'sigil' => 'context-target', ), phutil_tag( 'td', array( 'colspan' => 6, 'class' => 'show-more', ), pht('Context not available.'))); } $html = array(); $old_lines = $this->getOldLines(); $new_lines = $this->getNewLines(); $gaps = $this->getGaps(); $reference = $this->getRenderingReference(); list($left_prefix, $right_prefix) = $this->getLineIDPrefixes(); $changeset = $this->getChangeset(); $copy_lines = idx($changeset->getMetadata(), 'copy:lines', array()); $highlight_old = $this->getHighlightOld(); $highlight_new = $this->getHighlightNew(); $old_render = $this->getOldRender(); $new_render = $this->getNewRender(); $original_left = $this->getOriginalOld(); $original_right = $this->getOriginalNew(); $mask = $this->getMask(); $scope_engine = $this->getScopeEngine(); $offset_map = null; $depth_only = $this->getDepthOnlyLines(); for ($ii = $range_start; $ii < $range_start + $range_len; $ii++) { if (empty($mask[$ii])) { // If we aren't going to show this line, we've just entered a gap. // Pop information about the next gap off the $gaps stack and render // an appropriate "Show more context" element. This branch eventually // increments $ii by the entire size of the gap and then continues // the loop. $gap = array_pop($gaps); $top = $gap[0]; $len = $gap[1]; $contents = $this->renderShowContextLinks($top, $len, $rows); $is_last_block = false; if ($ii + $len >= $rows) { $is_last_block = true; } $context_text = null; $context_line = null; if (!$is_last_block && $scope_engine) { $target_line = $new_lines[$ii + $len]['line']; $context_line = $scope_engine->getScopeStart($target_line); if ($context_line !== null) { // The scope engine returns a line number in the file. We need // to map that back to a display offset in the diff. if (!$offset_map) { $offset_map = $this->getNewLineToOffsetMap(); } $offset = $offset_map[$context_line]; $context_text = $new_render[$offset]; } } $container = javelin_tag( 'tr', array( 'sigil' => 'context-target', ), array( phutil_tag( 'td', array( 'class' => 'show-context-line n left-context', )), phutil_tag( 'td', array( 'class' => 'show-more', ), $contents), phutil_tag( 'td', array( 'class' => 'show-context-line n', 'data-n' => $context_line, )), phutil_tag( 'td', array( 'colspan' => 3, 'class' => 'show-context', ), // TODO: [HTML] Escaping model here isn't ideal. phutil_safe_html($context_text)), )); $html[] = $container; $ii += ($len - 1); continue; } $o_num = null; $o_classes = ''; $o_text = null; if (isset($old_lines[$ii])) { $o_num = $old_lines[$ii]['line']; $o_text = isset($old_render[$ii]) ? $old_render[$ii] : null; if ($old_lines[$ii]['type']) { if ($old_lines[$ii]['type'] == '\\') { $o_text = $old_lines[$ii]['text']; $o_class = 'comment'; } else if ($original_left && !isset($highlight_old[$o_num])) { $o_class = 'old-rebase'; } else if (empty($new_lines[$ii])) { $o_class = 'old old-full'; } else { if (isset($depth_only[$ii])) { if ($depth_only[$ii] == '>') { // When a line has depth-only change, we only highlight the // left side of the diff if the depth is decreasing. When the // depth is increasing, the ">>" marker on the right hand side // of the diff generally provides enough visibility on its own. $o_class = ''; } else { $o_class = 'old'; } } else { $o_class = 'old'; } } $o_classes = $o_class; } } $n_copy = hsprintf('<td class="copy" />'); $n_cov = null; $n_colspan = 2; $n_classes = ''; $n_num = null; $n_text = null; if (isset($new_lines[$ii])) { $n_num = $new_lines[$ii]['line']; $n_text = isset($new_render[$ii]) ? $new_render[$ii] : null; $coverage = $this->getCodeCoverage(); if ($coverage !== null) { if (empty($coverage[$n_num - 1])) { $cov_class = 'N'; } else { $cov_class = $coverage[$n_num - 1]; } $cov_class = 'cov-'.$cov_class; $n_cov = phutil_tag('td', array('class' => "cov {$cov_class}")); $n_colspan--; } if ($new_lines[$ii]['type']) { if ($new_lines[$ii]['type'] == '\\') { $n_text = $new_lines[$ii]['text']; $n_class = 'comment'; } else if ($original_right && !isset($highlight_new[$n_num])) { $n_class = 'new-rebase'; } else if (empty($old_lines[$ii])) { $n_class = 'new new-full'; } else { // When a line has a depth-only change, never highlight it on // the right side. The ">>" marker generally provides enough // visibility on its own for indent depth increases, and the left // side is still highlighted for indent depth decreases. if (isset($depth_only[$ii])) { $n_class = ''; } else { $n_class = 'new'; } } $n_classes = $n_class; $not_copied = // If this line only changed depth, copy markers are pointless. (!isset($copy_lines[$n_num])) || (isset($depth_only[$ii])) || ($new_lines[$ii]['type'] == '\\'); if ($not_copied) { $n_copy = phutil_tag('td', array('class' => 'copy')); } else { list($orig_file, $orig_line, $orig_type) = $copy_lines[$n_num]; $title = ($orig_type == '-' ? 'Moved' : 'Copied').' from '; if ($orig_file == '') { $title .= "line {$orig_line}"; } else { $title .= basename($orig_file). ":{$orig_line} in dir ". dirname('/'.$orig_file); } $class = ($orig_type == '-' ? 'new-move' : 'new-copy'); $n_copy = javelin_tag( 'td', array( 'meta' => array( 'msg' => $title, ), 'class' => 'copy '.$class, )); } } } if (isset($hunk_starts[$o_num])) { $html[] = $context_not_available; } if ($o_num && $left_prefix) { $o_id = $left_prefix.$o_num; } else { $o_id = null; } if ($n_num && $right_prefix) { $n_id = $right_prefix.$n_num; } else { $n_id = null; } $old_comments = $this->getOldComments(); $new_comments = $this->getNewComments(); $scaffolds = array(); if ($o_num && isset($old_comments[$o_num])) { foreach ($old_comments[$o_num] as $comment) { $inline = $this->buildInlineComment( $comment, $on_right = false); $scaffold = $this->getRowScaffoldForInline($inline); if ($n_num && isset($new_comments[$n_num])) { foreach ($new_comments[$n_num] as $key => $new_comment) { if ($comment->isCompatible($new_comment)) { $companion = $this->buildInlineComment( $new_comment, $on_right = true); $scaffold->addInlineView($companion); unset($new_comments[$n_num][$key]); break; } } } $scaffolds[] = $scaffold; } } if ($n_num && isset($new_comments[$n_num])) { foreach ($new_comments[$n_num] as $comment) { $inline = $this->buildInlineComment( $comment, $on_right = true); $scaffolds[] = $this->getRowScaffoldForInline($inline); } } $old_number = phutil_tag( 'td', array( 'id' => $o_id, 'class' => $o_classes.' n', 'data-n' => $o_num, )); $new_number = phutil_tag( 'td', array( 'id' => $n_id, 'class' => $n_classes.' n', 'data-n' => $n_num, )); $html[] = phutil_tag('tr', array(), array( $old_number, phutil_tag( 'td', array( 'class' => $o_classes, 'data-copy-mode' => 'copy-l', ), $o_text), $new_number, $n_copy, phutil_tag( 'td', array( 'class' => $n_classes, 'colspan' => $n_colspan, 'data-copy-mode' => 'copy-r', ), $n_text), $n_cov, )); if ($context_not_available && ($ii == $rows - 1)) { $html[] = $context_not_available; } foreach ($scaffolds as $scaffold) { $html[] = $scaffold; } } return $this->wrapChangeInTable(phutil_implode_html('', $html)); } public function renderDocumentEngineBlocks( PhabricatorDocumentEngineBlocks $block_list, $old_changeset_key, $new_changeset_key) { $engine = $this->getDocumentEngine(); $old_ref = null; $new_ref = null; $refs = $block_list->getDocumentRefs(); if ($refs) { list($old_ref, $new_ref) = $refs; } $old_comments = $this->getOldComments(); $new_comments = $this->getNewComments(); $rows = array(); $gap = array(); $in_gap = false; // NOTE: The generated layout is affected by range constraints, and may // represent only a slice of the document. $layout = $block_list->newTwoUpLayout(); $available_count = $block_list->getLayoutAvailableRowCount(); foreach ($layout as $idx => $row) { list($old, $new) = $row; if ($old) { $old_key = $old->getBlockKey(); $is_visible = $old->getIsVisible(); } else { $old_key = null; } if ($new) { $new_key = $new->getBlockKey(); $is_visible = $new->getIsVisible(); } else { $new_key = null; } if (!$is_visible) { if (!$in_gap) { $in_gap = true; } $gap[$idx] = $row; continue; } if ($in_gap) { $in_gap = false; $rows[] = $this->renderDocumentEngineGap( $gap, $available_count); $gap = array(); } if ($old) { $is_rem = ($old->getDifferenceType() === '-'); } else { $is_rem = false; } if ($new) { $is_add = ($new->getDifferenceType() === '+'); } else { $is_add = false; } if ($is_rem && $is_add) { $block_diff = $engine->newBlockDiffViews( $old_ref, $old, $new_ref, $new); $old_content = $block_diff->getOldContent(); $new_content = $block_diff->getNewContent(); $old_classes = $block_diff->getOldClasses(); $new_classes = $block_diff->getNewClasses(); } else { $old_classes = array(); $new_classes = array(); if ($old) { $old_content = $engine->newBlockContentView( $old_ref, $old); if ($is_rem) { $old_classes[] = 'old'; $old_classes[] = 'old-full'; } } else { $old_content = null; } if ($new) { $new_content = $engine->newBlockContentView( $new_ref, $new); if ($is_add) { $new_classes[] = 'new'; $new_classes[] = 'new-full'; } } else { $new_content = null; } } $old_classes[] = 'diff-flush'; $old_classes = implode(' ', $old_classes); $new_classes[] = 'diff-flush'; $new_classes = implode(' ', $new_classes); $old_inline_rows = array(); if ($old_key !== null) { $old_inlines = idx($old_comments, $old_key, array()); foreach ($old_inlines as $inline) { $inline = $this->buildInlineComment( $inline, $on_right = false); $old_inline_rows[] = $this->getRowScaffoldForInline($inline); } } $new_inline_rows = array(); if ($new_key !== null) { $new_inlines = idx($new_comments, $new_key, array()); foreach ($new_inlines as $inline) { $inline = $this->buildInlineComment( $inline, $on_right = true); $new_inline_rows[] = $this->getRowScaffoldForInline($inline); } } if ($old_content === null) { $old_id = null; } else { $old_id = "C{$old_changeset_key}OL{$old_key}"; } $old_line_cell = phutil_tag( 'td', array( 'id' => $old_id, 'data-n' => $old_key, 'class' => 'n', )); $old_content_cell = phutil_tag( 'td', array( 'class' => $old_classes, 'data-copy-mode' => 'copy-l', ), $old_content); if ($new_content === null) { $new_id = null; } else { $new_id = "C{$new_changeset_key}NL{$new_key}"; } $new_line_cell = phutil_tag( 'td', array( 'id' => $new_id, 'data-n' => $new_key, 'class' => 'n', )); $copy_gutter = phutil_tag( 'td', array( 'class' => 'copy', )); $new_content_cell = phutil_tag( 'td', array( 'class' => $new_classes, 'colspan' => '2', 'data-copy-mode' => 'copy-r', ), $new_content); $row_view = phutil_tag( 'tr', array(), array( $old_line_cell, $old_content_cell, $new_line_cell, $copy_gutter, $new_content_cell, )); $rows[] = array( $row_view, $old_inline_rows, $new_inline_rows, ); } if ($in_gap) { $rows[] = $this->renderDocumentEngineGap( $gap, $available_count); } $output = $this->wrapChangeInTable($rows); return $this->renderChangesetTable($output); } public function getRowScaffoldForInline(PHUIDiffInlineCommentView $view) { return id(new PHUIDiffTwoUpInlineCommentRowScaffold()) ->addInlineView($view); } private function getNewLineToOffsetMap() { if ($this->newOffsetMap === null) { $new = $this->getNewLines(); $map = array(); foreach ($new as $offset => $new_line) { if ($new_line === null) { continue; } if ($new_line['line'] === null) { continue; } $map[$new_line['line']] = $offset; } $this->newOffsetMap = $map; } return $this->newOffsetMap; } protected function getTableSigils() { return array( 'intercept-copy', ); } private function renderDocumentEngineGap(array $gap, $available_count) { $content = $this->renderShowContextLinks( head_key($gap), count($gap), $available_count, $is_blocks = true); return javelin_tag( 'tr', array( 'sigil' => 'context-target', ), phutil_tag( 'td', array( 'colspan' => 6, 'class' => 'show-more', ), $content)); } }
php
Apache-2.0
5720a38cfe95b00ca4be5016dd0d2f3195f4fa04
2026-01-04T15:03:23.651835Z
false
phacility/phabricator
https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/differential/render/DifferentialChangesetOneUpTestRenderer.php
src/applications/differential/render/DifferentialChangesetOneUpTestRenderer.php
<?php final class DifferentialChangesetOneUpTestRenderer extends DifferentialChangesetTestRenderer { public function isOneUpRenderer() { return true; } public function getRendererKey() { return '1up-test'; } }
php
Apache-2.0
5720a38cfe95b00ca4be5016dd0d2f3195f4fa04
2026-01-04T15:03:23.651835Z
false
phacility/phabricator
https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/differential/render/DifferentialRawDiffRenderer.php
src/applications/differential/render/DifferentialRawDiffRenderer.php
<?php final class DifferentialRawDiffRenderer extends Phobject { private $changesets; private $format = 'unified'; private $viewer; private $byteLimit; public function setFormat($format) { $this->format = $format; return $this; } public function getFormat() { return $this->format; } public function setChangesets(array $changesets) { assert_instances_of($changesets, 'DifferentialChangeset'); $this->changesets = $changesets; return $this; } public function getChangesets() { return $this->changesets; } public function setViewer(PhabricatorUser $viewer) { $this->viewer = $viewer; return $this; } public function getViewer() { return $this->viewer; } public function setByteLimit($byte_limit) { $this->byteLimit = $byte_limit; return $this; } public function getByteLimit() { return $this->byteLimit; } public function buildPatch() { $diff = new DifferentialDiff(); $diff->attachChangesets($this->getChangesets()); $raw_changes = $diff->buildChangesList(); $changes = array(); foreach ($raw_changes as $changedict) { $changes[] = ArcanistDiffChange::newFromDictionary($changedict); } $viewer = $this->getViewer(); $loader = id(new PhabricatorFileBundleLoader()) ->setViewer($viewer); $bundle = ArcanistBundle::newFromChanges($changes); $bundle->setLoadFileDataCallback(array($loader, 'loadFileData')); $byte_limit = $this->getByteLimit(); if ($byte_limit) { $bundle->setByteLimit($byte_limit); } $format = $this->getFormat(); switch ($format) { case 'git': return $bundle->toGitPatch(); case 'unified': default: return $bundle->toUnifiedDiff(); } } }
php
Apache-2.0
5720a38cfe95b00ca4be5016dd0d2f3195f4fa04
2026-01-04T15:03:23.651835Z
false
phacility/phabricator
https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/differential/render/DifferentialChangesetTwoUpTestRenderer.php
src/applications/differential/render/DifferentialChangesetTwoUpTestRenderer.php
<?php final class DifferentialChangesetTwoUpTestRenderer extends DifferentialChangesetTestRenderer { public function isOneUpRenderer() { return false; } public function getRendererKey() { return '2up-test'; } }
php
Apache-2.0
5720a38cfe95b00ca4be5016dd0d2f3195f4fa04
2026-01-04T15:03:23.651835Z
false
phacility/phabricator
https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/differential/render/DifferentialChangesetOneUpMailRenderer.php
src/applications/differential/render/DifferentialChangesetOneUpMailRenderer.php
<?php final class DifferentialChangesetOneUpMailRenderer extends DifferentialChangesetRenderer { public function isOneUpRenderer() { return true; } protected function getRendererTableClass() { return 'diff-1up-mail'; } public function getRendererKey() { return '1up-mail'; } protected function renderChangeTypeHeader($force) { return null; } protected function renderUndershieldHeader() { return null; } public function renderShield($message, $force = 'default') { return null; } protected function renderPropertyChangeHeader() { return null; } public function renderTextChange( $range_start, $range_len, $rows) { $primitives = $this->buildPrimitives($range_start, $range_len); return $this->renderPrimitives($primitives, $rows); } protected function renderPrimitives(array $primitives, $rows) { $out = array(); $viewer = $this->getUser(); $old_bright = $viewer->getCSSValue('old-bright'); $new_bright = $viewer->getCSSValue('new-bright'); $context_style = array( 'background: #F7F7F7;', 'color: #74777D;', 'border-style: dashed;', 'border-color: #C7CCD9;', 'border-width: 1px 0;', ); $context_style = implode(' ', $context_style); foreach ($primitives as $k => $p) { $type = $p['type']; switch ($type) { case 'old': case 'new': case 'old-file': case 'new-file': $is_old = ($type == 'old' || $type == 'old-file'); if ($is_old) { if ($p['htype']) { $style = "background: {$old_bright};"; } else { $style = null; } } else { if ($p['htype']) { $style = "background: {$new_bright};"; } else { $style = null; } } $out[] = array( 'style' => $style, 'render' => $p['render'], 'text' => (string)$p['render'], ); break; case 'context': // NOTE: These are being included with no text so they get stripped // in the header and footer. $out[] = array( 'style' => $context_style, 'render' => '...', 'text' => '', ); break; default: break; } } // Remove all leading and trailing empty lines, since these just look kind // of weird in mail. foreach ($out as $key => $line) { if (!strlen(trim($line['text']))) { unset($out[$key]); } else { break; } } $keys = array_reverse(array_keys($out)); foreach ($keys as $key) { $line = $out[$key]; if (!strlen(trim($line['text']))) { unset($out[$key]); } else { break; } } // If the user has commented on an empty line in the middle of a bunch of // other empty lines, emit an explicit marker instead of just rendering // nothing. if (!$out) { $out[] = array( 'style' => 'color: #888888;', 'render' => pht('(Empty.)'), ); } $render = array(); foreach ($out as $line) { $style = $line['style']; $style = "padding: 0 8px; margin: 0 4px; {$style}"; $render[] = phutil_tag( 'div', array( 'style' => $style, ), $line['render']); } $style_map = id(new PhabricatorDefaultSyntaxStyle()) ->getRemarkupStyleMap(); $styled_body = id(new PhutilPygmentizeParser()) ->setMap($style_map) ->parse((string)hsprintf('%s', $render)); return phutil_safe_html($styled_body); } }
php
Apache-2.0
5720a38cfe95b00ca4be5016dd0d2f3195f4fa04
2026-01-04T15:03:23.651835Z
false
phacility/phabricator
https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/differential/render/DifferentialChangesetRenderer.php
src/applications/differential/render/DifferentialChangesetRenderer.php
<?php abstract class DifferentialChangesetRenderer extends Phobject { private $user; private $changeset; private $renderingReference; private $renderPropertyChangeHeader; private $isTopLevel; private $isUndershield; private $hunkStartLines; private $oldLines; private $newLines; private $oldComments; private $newComments; private $oldChangesetID; private $newChangesetID; private $oldAttachesToNewFile; private $newAttachesToNewFile; private $highlightOld = array(); private $highlightNew = array(); private $codeCoverage; private $handles; private $markupEngine; private $oldRender; private $newRender; private $originalOld; private $originalNew; private $gaps; private $mask; private $originalCharacterEncoding; private $showEditAndReplyLinks; private $canMarkDone; private $objectOwnerPHID; private $highlightingDisabled; private $scopeEngine = false; private $depthOnlyLines; private $documentEngine; private $documentEngineBlocks; private $oldFile = false; private $newFile = false; abstract public function getRendererKey(); public function setShowEditAndReplyLinks($bool) { $this->showEditAndReplyLinks = $bool; return $this; } public function getShowEditAndReplyLinks() { return $this->showEditAndReplyLinks; } public function setHighlightingDisabled($highlighting_disabled) { $this->highlightingDisabled = $highlighting_disabled; return $this; } public function getHighlightingDisabled() { return $this->highlightingDisabled; } public function setOriginalCharacterEncoding($original_character_encoding) { $this->originalCharacterEncoding = $original_character_encoding; return $this; } public function getOriginalCharacterEncoding() { return $this->originalCharacterEncoding; } public function setIsUndershield($is_undershield) { $this->isUndershield = $is_undershield; return $this; } public function getIsUndershield() { return $this->isUndershield; } public function setMask($mask) { $this->mask = $mask; return $this; } protected function getMask() { return $this->mask; } public function setGaps($gaps) { $this->gaps = $gaps; return $this; } protected function getGaps() { return $this->gaps; } public function setDepthOnlyLines(array $lines) { $this->depthOnlyLines = $lines; return $this; } public function getDepthOnlyLines() { return $this->depthOnlyLines; } public function attachOldFile(PhabricatorFile $old = null) { $this->oldFile = $old; return $this; } public function getOldFile() { if ($this->oldFile === false) { throw new PhabricatorDataNotAttachedException($this); } return $this->oldFile; } public function hasOldFile() { return (bool)$this->oldFile; } public function attachNewFile(PhabricatorFile $new = null) { $this->newFile = $new; return $this; } public function getNewFile() { if ($this->newFile === false) { throw new PhabricatorDataNotAttachedException($this); } return $this->newFile; } public function hasNewFile() { return (bool)$this->newFile; } public function setOriginalNew($original_new) { $this->originalNew = $original_new; return $this; } protected function getOriginalNew() { return $this->originalNew; } public function setOriginalOld($original_old) { $this->originalOld = $original_old; return $this; } protected function getOriginalOld() { return $this->originalOld; } public function setNewRender($new_render) { $this->newRender = $new_render; return $this; } protected function getNewRender() { return $this->newRender; } public function setOldRender($old_render) { $this->oldRender = $old_render; return $this; } protected function getOldRender() { return $this->oldRender; } public function setMarkupEngine(PhabricatorMarkupEngine $markup_engine) { $this->markupEngine = $markup_engine; return $this; } public function getMarkupEngine() { return $this->markupEngine; } public function setHandles(array $handles) { assert_instances_of($handles, 'PhabricatorObjectHandle'); $this->handles = $handles; return $this; } protected function getHandles() { return $this->handles; } public function setCodeCoverage($code_coverage) { $this->codeCoverage = $code_coverage; return $this; } protected function getCodeCoverage() { return $this->codeCoverage; } public function setHighlightNew($highlight_new) { $this->highlightNew = $highlight_new; return $this; } protected function getHighlightNew() { return $this->highlightNew; } public function setHighlightOld($highlight_old) { $this->highlightOld = $highlight_old; return $this; } protected function getHighlightOld() { return $this->highlightOld; } public function setNewAttachesToNewFile($attaches) { $this->newAttachesToNewFile = $attaches; return $this; } protected function getNewAttachesToNewFile() { return $this->newAttachesToNewFile; } public function setOldAttachesToNewFile($attaches) { $this->oldAttachesToNewFile = $attaches; return $this; } protected function getOldAttachesToNewFile() { return $this->oldAttachesToNewFile; } public function setNewChangesetID($new_changeset_id) { $this->newChangesetID = $new_changeset_id; return $this; } protected function getNewChangesetID() { return $this->newChangesetID; } public function setOldChangesetID($old_changeset_id) { $this->oldChangesetID = $old_changeset_id; return $this; } protected function getOldChangesetID() { return $this->oldChangesetID; } public function setDocumentEngine(PhabricatorDocumentEngine $engine) { $this->documentEngine = $engine; return $this; } public function getDocumentEngine() { return $this->documentEngine; } public function setDocumentEngineBlocks( PhabricatorDocumentEngineBlocks $blocks) { $this->documentEngineBlocks = $blocks; return $this; } public function getDocumentEngineBlocks() { return $this->documentEngineBlocks; } public function setNewComments(array $new_comments) { foreach ($new_comments as $line_number => $comments) { assert_instances_of($comments, 'PhabricatorInlineComment'); } $this->newComments = $new_comments; return $this; } protected function getNewComments() { return $this->newComments; } public function setOldComments(array $old_comments) { foreach ($old_comments as $line_number => $comments) { assert_instances_of($comments, 'PhabricatorInlineComment'); } $this->oldComments = $old_comments; return $this; } protected function getOldComments() { return $this->oldComments; } public function setNewLines(array $new_lines) { $this->newLines = $new_lines; return $this; } protected function getNewLines() { return $this->newLines; } public function setOldLines(array $old_lines) { $this->oldLines = $old_lines; return $this; } protected function getOldLines() { return $this->oldLines; } public function setHunkStartLines(array $hunk_start_lines) { $this->hunkStartLines = $hunk_start_lines; return $this; } protected function getHunkStartLines() { return $this->hunkStartLines; } public function setUser(PhabricatorUser $user) { $this->user = $user; return $this; } protected function getUser() { return $this->user; } public function setChangeset(DifferentialChangeset $changeset) { $this->changeset = $changeset; return $this; } protected function getChangeset() { return $this->changeset; } public function setRenderingReference($rendering_reference) { $this->renderingReference = $rendering_reference; return $this; } protected function getRenderingReference() { return $this->renderingReference; } public function setRenderPropertyChangeHeader($should_render) { $this->renderPropertyChangeHeader = $should_render; return $this; } private function shouldRenderPropertyChangeHeader() { return $this->renderPropertyChangeHeader; } public function setIsTopLevel($is) { $this->isTopLevel = $is; return $this; } private function getIsTopLevel() { return $this->isTopLevel; } public function setCanMarkDone($can_mark_done) { $this->canMarkDone = $can_mark_done; return $this; } public function getCanMarkDone() { return $this->canMarkDone; } public function setObjectOwnerPHID($phid) { $this->objectOwnerPHID = $phid; return $this; } public function getObjectOwnerPHID() { return $this->objectOwnerPHID; } final public function renderChangesetTable($content) { $props = null; if ($this->shouldRenderPropertyChangeHeader()) { $props = $this->renderPropertyChangeHeader(); } $notice = null; if ($this->getIsTopLevel()) { $force = (!$content && !$props); // If we have DocumentEngine messages about the blocks, assume they // explain why there's no content. $blocks = $this->getDocumentEngineBlocks(); if ($blocks) { if ($blocks->getMessages()) { $force = false; } } $notice = $this->renderChangeTypeHeader($force); } $undershield = null; if ($this->getIsUndershield()) { $undershield = $this->renderUndershieldHeader(); } $result = array( $notice, $props, $undershield, $content, ); return hsprintf('%s', $result); } abstract public function isOneUpRenderer(); abstract public function renderTextChange( $range_start, $range_len, $rows); public function renderDocumentEngineBlocks( PhabricatorDocumentEngineBlocks $blocks, $old_changeset_key, $new_changeset_key) { return null; } abstract protected function renderChangeTypeHeader($force); abstract protected function renderUndershieldHeader(); protected function didRenderChangesetTableContents($contents) { return $contents; } /** * Render a "shield" over the diff, with a message like "This file is * generated and does not need to be reviewed." or "This file was completely * deleted." This UI element hides unimportant text so the reviewer doesn't * need to scroll past it. * * The shield includes a link to view the underlying content. This link * may force certain rendering modes when the link is clicked: * * - `"default"`: Render the diff normally, as though it was not * shielded. This is the default and appropriate if the underlying * diff is a normal change, but was hidden for reasons of not being * important (e.g., generated code). * - `"text"`: Force the text to be shown. This is probably only relevant * when a file is not changed. * - `"none"`: Don't show the link (e.g., text not available). * * @param string Message explaining why the diff is hidden. * @param string|null Force mode, see above. * @return string Shield markup. */ abstract public function renderShield($message, $force = 'default'); abstract protected function renderPropertyChangeHeader(); protected function buildPrimitives($range_start, $range_len) { $primitives = array(); $hunk_starts = $this->getHunkStartLines(); $mask = $this->getMask(); $gaps = $this->getGaps(); $old = $this->getOldLines(); $new = $this->getNewLines(); $old_render = $this->getOldRender(); $new_render = $this->getNewRender(); $old_comments = $this->getOldComments(); $new_comments = $this->getNewComments(); $size = count($old); for ($ii = $range_start; $ii < $range_start + $range_len; $ii++) { if (empty($mask[$ii])) { list($top, $len) = array_pop($gaps); $primitives[] = array( 'type' => 'context', 'top' => $top, 'len' => $len, ); $ii += ($len - 1); continue; } $ospec = array( 'type' => 'old', 'htype' => null, 'cursor' => $ii, 'line' => null, 'oline' => null, 'render' => null, ); $nspec = array( 'type' => 'new', 'htype' => null, 'cursor' => $ii, 'line' => null, 'oline' => null, 'render' => null, 'copy' => null, 'coverage' => null, ); if (isset($old[$ii])) { $ospec['line'] = (int)$old[$ii]['line']; $nspec['oline'] = (int)$old[$ii]['line']; $ospec['htype'] = $old[$ii]['type']; if (isset($old_render[$ii])) { $ospec['render'] = $old_render[$ii]; } else if ($ospec['htype'] === '\\') { $ospec['render'] = $old[$ii]['text']; } } if (isset($new[$ii])) { $nspec['line'] = (int)$new[$ii]['line']; $ospec['oline'] = (int)$new[$ii]['line']; $nspec['htype'] = $new[$ii]['type']; if (isset($new_render[$ii])) { $nspec['render'] = $new_render[$ii]; } else if ($nspec['htype'] === '\\') { $nspec['render'] = $new[$ii]['text']; } } if (isset($hunk_starts[$ospec['line']])) { $primitives[] = array( 'type' => 'no-context', ); } $primitives[] = $ospec; $primitives[] = $nspec; if ($ospec['line'] !== null && isset($old_comments[$ospec['line']])) { foreach ($old_comments[$ospec['line']] as $comment) { $primitives[] = array( 'type' => 'inline', 'comment' => $comment, 'right' => false, ); } } if ($nspec['line'] !== null && isset($new_comments[$nspec['line']])) { foreach ($new_comments[$nspec['line']] as $comment) { $primitives[] = array( 'type' => 'inline', 'comment' => $comment, 'right' => true, ); } } if ($hunk_starts && ($ii == $size - 1)) { $primitives[] = array( 'type' => 'no-context', ); } } if ($this->isOneUpRenderer()) { $primitives = $this->processPrimitivesForOneUp($primitives); } return $primitives; } private function processPrimitivesForOneUp(array $primitives) { // Primitives come out of buildPrimitives() in two-up format, because it // is the most general, flexible format. To put them into one-up format, // we need to filter and reorder them. In particular: // // - We discard unchanged lines in the old file; in one-up format, we // render them only once. // - We group contiguous blocks of old-modified and new-modified lines, so // they render in "block of old, block of new" order instead of // alternating old and new lines. $out = array(); $old_buf = array(); $new_buf = array(); foreach ($primitives as $primitive) { $type = $primitive['type']; if ($type == 'old') { if (!$primitive['htype']) { // This is a line which appears in both the old file and the new // file, or the spacer corresponding to a line added in the new file. // Ignore it when rendering a one-up diff. continue; } $old_buf[] = $primitive; } else if ($type == 'new') { if ($primitive['line'] === null) { // This is an empty spacer corresponding to a line removed from the // old file. Ignore it when rendering a one-up diff. continue; } if (!$primitive['htype']) { // If this line is the same in both versions of the file, put it in // the old line buffer. This makes sure inlines on old, unchanged // lines end up in the right place. // First, we need to flush the line buffers if they're not empty. if ($old_buf) { $out[] = $old_buf; $old_buf = array(); } if ($new_buf) { $out[] = $new_buf; $new_buf = array(); } $old_buf[] = $primitive; } else { $new_buf[] = $primitive; } } else if ($type == 'context' || $type == 'no-context') { $out[] = $old_buf; $out[] = $new_buf; $old_buf = array(); $new_buf = array(); $out[] = array($primitive); } else if ($type == 'inline') { // If this inline is on the left side, put it after the old lines. if (!$primitive['right']) { $out[] = $old_buf; $out[] = array($primitive); $old_buf = array(); } else { $out[] = $old_buf; $out[] = $new_buf; $out[] = array($primitive); $old_buf = array(); $new_buf = array(); } } else { throw new Exception(pht("Unknown primitive type '%s'!", $primitive)); } } $out[] = $old_buf; $out[] = $new_buf; $out = array_mergev($out); return $out; } protected function getChangesetProperties($changeset) { $old = $changeset->getOldProperties(); $new = $changeset->getNewProperties(); // If a property has been changed, but is not present on one side of the // change and has an uninteresting default value on the other, remove it. // This most commonly happens when a change adds or removes a file: the // side of the change with the file has a "100644" filemode in Git. $defaults = array( 'unix:filemode' => '100644', ); foreach ($defaults as $default_key => $default_value) { $old_value = idx($old, $default_key, $default_value); $new_value = idx($new, $default_key, $default_value); $old_default = ($old_value === $default_value); $new_default = ($new_value === $default_value); if ($old_default && $new_default) { unset($old[$default_key]); unset($new[$default_key]); } } $metadata = $changeset->getMetadata(); if ($this->hasOldFile()) { $file = $this->getOldFile(); if ($file->getImageWidth()) { $dimensions = $file->getImageWidth().'x'.$file->getImageHeight(); $old['file:dimensions'] = $dimensions; } $old['file:mimetype'] = $file->getMimeType(); $old['file:size'] = phutil_format_bytes($file->getByteSize()); } else { $old['file:mimetype'] = idx($metadata, 'old:file:mime-type'); $size = idx($metadata, 'old:file:size'); if ($size !== null) { $old['file:size'] = phutil_format_bytes($size); } } if ($this->hasNewFile()) { $file = $this->getNewFile(); if ($file->getImageWidth()) { $dimensions = $file->getImageWidth().'x'.$file->getImageHeight(); $new['file:dimensions'] = $dimensions; } $new['file:mimetype'] = $file->getMimeType(); $new['file:size'] = phutil_format_bytes($file->getByteSize()); } else { $new['file:mimetype'] = idx($metadata, 'new:file:mime-type'); $size = idx($metadata, 'new:file:size'); if ($size !== null) { $new['file:size'] = phutil_format_bytes($size); } } return array($old, $new); } public function renderUndoTemplates() { $views = array( 'l' => id(new PHUIDiffInlineCommentUndoView())->setIsOnRight(false), 'r' => id(new PHUIDiffInlineCommentUndoView())->setIsOnRight(true), ); foreach ($views as $key => $view) { $scaffold = $this->getRowScaffoldForInline($view); $scaffold->setIsUndoTemplate(true); $views[$key] = id(new PHUIDiffInlineCommentTableScaffold()) ->addRowScaffold($scaffold); } return $views; } final protected function getScopeEngine() { if ($this->scopeEngine === false) { $hunk_starts = $this->getHunkStartLines(); // If this change is missing context, don't try to identify scopes, since // we won't really be able to get anywhere. $has_multiple_hunks = (count($hunk_starts) > 1); $has_offset_hunks = false; if ($hunk_starts) { $has_offset_hunks = (head_key($hunk_starts) != 1); } $missing_context = ($has_multiple_hunks || $has_offset_hunks); if ($missing_context) { $scope_engine = null; } else { $line_map = $this->getNewLineTextMap(); $scope_engine = id(new PhabricatorDiffScopeEngine()) ->setLineTextMap($line_map); } $this->scopeEngine = $scope_engine; } return $this->scopeEngine; } private function getNewLineTextMap() { $new = $this->getNewLines(); $text_map = array(); foreach ($new as $new_line) { if (!isset($new_line['line'])) { continue; } $text_map[$new_line['line']] = $new_line['text']; } return $text_map; } }
php
Apache-2.0
5720a38cfe95b00ca4be5016dd0d2f3195f4fa04
2026-01-04T15:03:23.651835Z
false
phacility/phabricator
https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/differential/render/DifferentialChangesetHTMLRenderer.php
src/applications/differential/render/DifferentialChangesetHTMLRenderer.php
<?php abstract class DifferentialChangesetHTMLRenderer extends DifferentialChangesetRenderer { public static function getHTMLRendererByKey($key) { switch ($key) { case '1up': return new DifferentialChangesetOneUpRenderer(); case '2up': default: return new DifferentialChangesetTwoUpRenderer(); } throw new Exception(pht('Unknown HTML renderer "%s"!', $key)); } abstract protected function getRendererTableClass(); abstract public function getRowScaffoldForInline( PHUIDiffInlineCommentView $view); protected function renderChangeTypeHeader($force) { $changeset = $this->getChangeset(); $change = $changeset->getChangeType(); $file = $changeset->getFileType(); $messages = array(); switch ($change) { case DifferentialChangeType::TYPE_ADD: switch ($file) { case DifferentialChangeType::FILE_TEXT: $messages[] = pht('This file was added.'); break; case DifferentialChangeType::FILE_IMAGE: $messages[] = pht('This image was added.'); break; case DifferentialChangeType::FILE_DIRECTORY: $messages[] = pht('This directory was added.'); break; case DifferentialChangeType::FILE_BINARY: $messages[] = pht('This binary file was added.'); break; case DifferentialChangeType::FILE_SYMLINK: $messages[] = pht('This symlink was added.'); break; case DifferentialChangeType::FILE_SUBMODULE: $messages[] = pht('This submodule was added.'); break; } break; case DifferentialChangeType::TYPE_DELETE: switch ($file) { case DifferentialChangeType::FILE_TEXT: $messages[] = pht('This file was deleted.'); break; case DifferentialChangeType::FILE_IMAGE: $messages[] = pht('This image was deleted.'); break; case DifferentialChangeType::FILE_DIRECTORY: $messages[] = pht('This directory was deleted.'); break; case DifferentialChangeType::FILE_BINARY: $messages[] = pht('This binary file was deleted.'); break; case DifferentialChangeType::FILE_SYMLINK: $messages[] = pht('This symlink was deleted.'); break; case DifferentialChangeType::FILE_SUBMODULE: $messages[] = pht('This submodule was deleted.'); break; } break; case DifferentialChangeType::TYPE_MOVE_HERE: $from = phutil_tag('strong', array(), $changeset->getOldFile()); switch ($file) { case DifferentialChangeType::FILE_TEXT: $messages[] = pht('This file was moved from %s.', $from); break; case DifferentialChangeType::FILE_IMAGE: $messages[] = pht('This image was moved from %s.', $from); break; case DifferentialChangeType::FILE_DIRECTORY: $messages[] = pht('This directory was moved from %s.', $from); break; case DifferentialChangeType::FILE_BINARY: $messages[] = pht('This binary file was moved from %s.', $from); break; case DifferentialChangeType::FILE_SYMLINK: $messages[] = pht('This symlink was moved from %s.', $from); break; case DifferentialChangeType::FILE_SUBMODULE: $messages[] = pht('This submodule was moved from %s.', $from); break; } break; case DifferentialChangeType::TYPE_COPY_HERE: $from = phutil_tag('strong', array(), $changeset->getOldFile()); switch ($file) { case DifferentialChangeType::FILE_TEXT: $messages[] = pht('This file was copied from %s.', $from); break; case DifferentialChangeType::FILE_IMAGE: $messages[] = pht('This image was copied from %s.', $from); break; case DifferentialChangeType::FILE_DIRECTORY: $messages[] = pht('This directory was copied from %s.', $from); break; case DifferentialChangeType::FILE_BINARY: $messages[] = pht('This binary file was copied from %s.', $from); break; case DifferentialChangeType::FILE_SYMLINK: $messages[] = pht('This symlink was copied from %s.', $from); break; case DifferentialChangeType::FILE_SUBMODULE: $messages[] = pht('This submodule was copied from %s.', $from); break; } break; case DifferentialChangeType::TYPE_MOVE_AWAY: $paths = phutil_tag( 'strong', array(), implode(', ', $changeset->getAwayPaths())); switch ($file) { case DifferentialChangeType::FILE_TEXT: $messages[] = pht('This file was moved to %s.', $paths); break; case DifferentialChangeType::FILE_IMAGE: $messages[] = pht('This image was moved to %s.', $paths); break; case DifferentialChangeType::FILE_DIRECTORY: $messages[] = pht('This directory was moved to %s.', $paths); break; case DifferentialChangeType::FILE_BINARY: $messages[] = pht('This binary file was moved to %s.', $paths); break; case DifferentialChangeType::FILE_SYMLINK: $messages[] = pht('This symlink was moved to %s.', $paths); break; case DifferentialChangeType::FILE_SUBMODULE: $messages[] = pht('This submodule was moved to %s.', $paths); break; } break; case DifferentialChangeType::TYPE_COPY_AWAY: $paths = phutil_tag( 'strong', array(), implode(', ', $changeset->getAwayPaths())); switch ($file) { case DifferentialChangeType::FILE_TEXT: $messages[] = pht('This file was copied to %s.', $paths); break; case DifferentialChangeType::FILE_IMAGE: $messages[] = pht('This image was copied to %s.', $paths); break; case DifferentialChangeType::FILE_DIRECTORY: $messages[] = pht('This directory was copied to %s.', $paths); break; case DifferentialChangeType::FILE_BINARY: $messages[] = pht('This binary file was copied to %s.', $paths); break; case DifferentialChangeType::FILE_SYMLINK: $messages[] = pht('This symlink was copied to %s.', $paths); break; case DifferentialChangeType::FILE_SUBMODULE: $messages[] = pht('This submodule was copied to %s.', $paths); break; } break; case DifferentialChangeType::TYPE_MULTICOPY: $paths = phutil_tag( 'strong', array(), implode(', ', $changeset->getAwayPaths())); switch ($file) { case DifferentialChangeType::FILE_TEXT: $messages[] = pht( 'This file was deleted after being copied to %s.', $paths); break; case DifferentialChangeType::FILE_IMAGE: $messages[] = pht( 'This image was deleted after being copied to %s.', $paths); break; case DifferentialChangeType::FILE_DIRECTORY: $messages[] = pht( 'This directory was deleted after being copied to %s.', $paths); break; case DifferentialChangeType::FILE_BINARY: $messages[] = pht( 'This binary file was deleted after being copied to %s.', $paths); break; case DifferentialChangeType::FILE_SYMLINK: $messages[] = pht( 'This symlink was deleted after being copied to %s.', $paths); break; case DifferentialChangeType::FILE_SUBMODULE: $messages[] = pht( 'This submodule was deleted after being copied to %s.', $paths); break; } break; default: switch ($file) { case DifferentialChangeType::FILE_TEXT: // This is the default case, so we only render this header if // forced to since it's not very useful. if ($force) { $messages[] = pht('This file was not modified.'); } break; case DifferentialChangeType::FILE_IMAGE: $messages[] = pht('This is an image.'); break; case DifferentialChangeType::FILE_DIRECTORY: $messages[] = pht('This is a directory.'); break; case DifferentialChangeType::FILE_BINARY: $messages[] = pht('This is a binary file.'); break; case DifferentialChangeType::FILE_SYMLINK: $messages[] = pht('This is a symlink.'); break; case DifferentialChangeType::FILE_SUBMODULE: $messages[] = pht('This is a submodule.'); break; } break; } return $this->formatHeaderMessages($messages); } protected function renderUndershieldHeader() { $messages = array(); $changeset = $this->getChangeset(); $file = $changeset->getFileType(); // If this is a text file with at least one hunk, we may have converted // the text encoding. In this case, show a note. $show_encoding = ($file == DifferentialChangeType::FILE_TEXT) && ($changeset->getHunks()); if ($show_encoding) { $encoding = $this->getOriginalCharacterEncoding(); if ($encoding != 'utf8') { if ($encoding) { $messages[] = pht( 'This file was converted from %s for display.', phutil_tag('strong', array(), $encoding)); } else { $messages[] = pht('This file uses an unknown character encoding.'); } } } $blocks = $this->getDocumentEngineBlocks(); if ($blocks) { foreach ($blocks->getMessages() as $message) { $messages[] = $message; } } else { if ($this->getHighlightingDisabled()) { $byte_limit = DifferentialChangesetParser::HIGHLIGHT_BYTE_LIMIT; $byte_limit = phutil_format_bytes($byte_limit); $messages[] = pht( 'This file is larger than %s, so syntax highlighting is '. 'disabled by default.', $byte_limit); } } return $this->formatHeaderMessages($messages); } private function formatHeaderMessages(array $messages) { if (!$messages) { return null; } foreach ($messages as $key => $message) { $messages[$key] = phutil_tag('li', array(), $message); } return phutil_tag( 'ul', array( 'class' => 'differential-meta-notice', ), $messages); } protected function renderPropertyChangeHeader() { $changeset = $this->getChangeset(); list($old, $new) = $this->getChangesetProperties($changeset); // If we don't have any property changes, don't render this table. if ($old === $new) { return null; } $keys = array_keys($old + $new); sort($keys); $key_map = array( 'unix:filemode' => pht('File Mode'), 'file:dimensions' => pht('Image Dimensions'), 'file:mimetype' => pht('MIME Type'), 'file:size' => pht('File Size'), ); $rows = array(); foreach ($keys as $key) { $oval = idx($old, $key); $nval = idx($new, $key); if ($oval !== $nval) { if ($oval === null) { $oval = phutil_tag('em', array(), 'null'); } else { $oval = phutil_escape_html_newlines($oval); } if ($nval === null) { $nval = phutil_tag('em', array(), 'null'); } else { $nval = phutil_escape_html_newlines($nval); } $readable_key = idx($key_map, $key, $key); $row = array( $readable_key, $oval, $nval, ); $rows[] = $row; } } $classes = array('', 'oval', 'nval'); $headers = array( pht('Property'), pht('Old Value'), pht('New Value'), ); $table = id(new AphrontTableView($rows)) ->setHeaders($headers) ->setColumnClasses($classes); return phutil_tag( 'div', array( 'class' => 'differential-property-table', ), $table); } public function renderShield($message, $force = 'default') { $end = count($this->getOldLines()); $reference = $this->getRenderingReference(); if ($force !== 'text' && $force !== 'none' && $force !== 'default') { throw new Exception( pht( "Invalid '%s' parameter '%s'!", 'force', $force)); } $range = "0-{$end}"; if ($force == 'text') { // If we're forcing text, force the whole file to be rendered. $range = "{$range}/0-{$end}"; } $meta = array( 'ref' => $reference, 'range' => $range, ); $content = array(); $content[] = $message; if ($force !== 'none') { $content[] = ' '; $content[] = javelin_tag( 'a', array( 'mustcapture' => true, 'sigil' => 'show-more', 'class' => 'complete', 'href' => '#', 'meta' => $meta, ), pht('Show File Contents')); } return $this->wrapChangeInTable( javelin_tag( 'tr', array( 'sigil' => 'context-target', ), phutil_tag( 'td', array( 'class' => 'differential-shield', 'colspan' => 6, ), $content))); } abstract protected function renderColgroup(); protected function wrapChangeInTable($content) { if (!$content) { return null; } $classes = array(); $classes[] = 'differential-diff'; $classes[] = 'remarkup-code'; $classes[] = 'PhabricatorMonospaced'; $classes[] = $this->getRendererTableClass(); $sigils = array(); $sigils[] = 'differential-diff'; foreach ($this->getTableSigils() as $sigil) { $sigils[] = $sigil; } return javelin_tag( 'table', array( 'class' => implode(' ', $classes), 'sigil' => implode(' ', $sigils), ), array( $this->renderColgroup(), $content, )); } protected function getTableSigils() { return array(); } protected function buildInlineComment( PhabricatorInlineComment $comment, $on_right = false) { $viewer = $this->getUser(); $edit = $viewer && ($comment->getAuthorPHID() == $viewer->getPHID()) && ($comment->isDraft()) && $this->getShowEditAndReplyLinks(); $allow_reply = (bool)$viewer && $this->getShowEditAndReplyLinks(); $allow_done = !$comment->isDraft() && $this->getCanMarkDone(); return id(new PHUIDiffInlineCommentDetailView()) ->setViewer($viewer) ->setInlineComment($comment) ->setIsOnRight($on_right) ->setHandles($this->getHandles()) ->setMarkupEngine($this->getMarkupEngine()) ->setEditable($edit) ->setAllowReply($allow_reply) ->setCanMarkDone($allow_done) ->setObjectOwnerPHID($this->getObjectOwnerPHID()); } /** * Build links which users can click to show more context in a changeset. * * @param int Beginning of the line range to build links for. * @param int Length of the line range to build links for. * @param int Total number of lines in the changeset. * @return markup Rendered links. */ protected function renderShowContextLinks( $top, $len, $changeset_length, $is_blocks = false) { $block_size = 20; $end = ($top + $len) - $block_size; // If this is a large block, such that the "top" and "bottom" ranges are // non-overlapping, we'll provide options to show the top, bottom or entire // block. For smaller blocks, we only provide an option to show the entire // block, since it would be silly to show the bottom 20 lines of a 25-line // block. $is_large_block = ($len > ($block_size * 2)); $links = array(); $block_display = new PhutilNumber($block_size); if ($is_large_block) { $is_first_block = ($top == 0); if ($is_first_block) { if ($is_blocks) { $text = pht('Show First %s Block(s)', $block_display); } else { $text = pht('Show First %s Line(s)', $block_display); } } else { if ($is_blocks) { $text = pht("\xE2\x96\xB2 Show %s Block(s)", $block_display); } else { $text = pht("\xE2\x96\xB2 Show %s Line(s)", $block_display); } } $links[] = $this->renderShowContextLink( false, "{$top}-{$len}/{$top}-20", $text); } if ($is_blocks) { $text = pht('Show All %s Block(s)', new PhutilNumber($len)); } else { $text = pht('Show All %s Line(s)', new PhutilNumber($len)); } $links[] = $this->renderShowContextLink( true, "{$top}-{$len}/{$top}-{$len}", $text); if ($is_large_block) { $is_last_block = (($top + $len) >= $changeset_length); if ($is_last_block) { if ($is_blocks) { $text = pht('Show Last %s Block(s)', $block_display); } else { $text = pht('Show Last %s Line(s)', $block_display); } } else { if ($is_blocks) { $text = pht("\xE2\x96\xBC Show %s Block(s)", $block_display); } else { $text = pht("\xE2\x96\xBC Show %s Line(s)", $block_display); } } $links[] = $this->renderShowContextLink( false, "{$top}-{$len}/{$end}-20", $text); } return phutil_implode_html(" \xE2\x80\xA2 ", $links); } /** * Build a link that shows more context in a changeset. * * See @{method:renderShowContextLinks}. * * @param bool Does this link show all context when clicked? * @param string Range specification for lines to show. * @param string Text of the link. * @return markup Rendered link. */ private function renderShowContextLink($is_all, $range, $text) { $reference = $this->getRenderingReference(); return javelin_tag( 'a', array( 'href' => '#', 'mustcapture' => true, 'sigil' => 'show-more', 'meta' => array( 'type' => ($is_all ? 'all' : null), 'range' => $range, ), ), $text); } /** * Build the prefixes for line IDs used to track inline comments. * * @return pair<wild, wild> Left and right prefixes. */ protected function getLineIDPrefixes() { // These look like "C123NL45", which means the line is line 45 on the // "new" side of the file in changeset 123. // The "C" stands for "changeset", and is followed by a changeset ID. // "N" stands for "new" and means the comment should attach to the new file // when stored. "O" stands for "old" and means the comment should attach to // the old file. These are important because either the old or new part // of a file may appear on the left or right side of the diff in the // diff-of-diffs view. // The "L" stands for "line" and is followed by the line number. if ($this->getOldChangesetID()) { $left_prefix = array(); $left_prefix[] = 'C'; $left_prefix[] = $this->getOldChangesetID(); $left_prefix[] = $this->getOldAttachesToNewFile() ? 'N' : 'O'; $left_prefix[] = 'L'; $left_prefix = implode('', $left_prefix); } else { $left_prefix = null; } if ($this->getNewChangesetID()) { $right_prefix = array(); $right_prefix[] = 'C'; $right_prefix[] = $this->getNewChangesetID(); $right_prefix[] = $this->getNewAttachesToNewFile() ? 'N' : 'O'; $right_prefix[] = 'L'; $right_prefix = implode('', $right_prefix); } else { $right_prefix = null; } return array($left_prefix, $right_prefix); } }
php
Apache-2.0
5720a38cfe95b00ca4be5016dd0d2f3195f4fa04
2026-01-04T15:03:23.651835Z
false
phacility/phabricator
https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/differential/config/PhabricatorDifferentialConfigOptions.php
src/applications/differential/config/PhabricatorDifferentialConfigOptions.php
<?php final class PhabricatorDifferentialConfigOptions extends PhabricatorApplicationConfigOptions { public function getName() { return pht('Differential'); } public function getDescription() { return pht('Configure Differential code review.'); } public function getIcon() { return 'fa-cog'; } public function getGroup() { return 'apps'; } public function getOptions() { $caches_href = PhabricatorEnv::getDoclink('Managing Caches'); $custom_field_type = 'custom:PhabricatorCustomFieldConfigOptionType'; $fields = array( new DifferentialSummaryField(), new DifferentialTestPlanField(), new DifferentialReviewersField(), new DifferentialProjectReviewersField(), new DifferentialRepositoryField(), new DifferentialManiphestTasksField(), new DifferentialCommitsField(), new DifferentialJIRAIssuesField(), new DifferentialAsanaRepresentationField(), new DifferentialChangesSinceLastUpdateField(), new DifferentialBranchField(), new DifferentialBlameRevisionField(), new DifferentialPathField(), new DifferentialHostField(), new DifferentialLintField(), new DifferentialUnitField(), new DifferentialRevertPlanField(), ); $default_fields = array(); foreach ($fields as $field) { $default_fields[$field->getFieldKey()] = array( 'disabled' => $field->shouldDisableByDefault(), ); } $inline_description = $this->deformat( pht(<<<EOHELP To include patches inline in email bodies, set this option to a positive integer. Patches will be inlined if they are at most that many lines and at most 256 times that many bytes. For example, a value of 100 means "inline patches if they are at not more than 100 lines long and not more than 25,600 bytes large". By default, patches are not inlined. EOHELP )); return array( $this->newOption( 'differential.fields', $custom_field_type, $default_fields) ->setCustomData( id(new DifferentialRevision())->getCustomFieldBaseClass()) ->setDescription( pht( "Select and reorder revision fields.\n\n". "NOTE: This feature is under active development and subject ". "to change.")), $this->newOption('differential.require-test-plan-field', 'bool', true) ->setBoolOptions( array( pht("Require 'Test Plan' field"), pht("Make 'Test Plan' field optional"), )) ->setSummary(pht('Require "Test Plan" field?')) ->setDescription( pht( "Differential has a required 'Test Plan' field by default. You ". "can make it optional by setting this to false. You can also ". "completely remove it above, if you prefer.")), $this->newOption('differential.enable-email-accept', 'bool', false) ->setBoolOptions( array( pht('Enable Email "!accept" Action'), pht('Disable Email "!accept" Action'), )) ->setSummary(pht('Enable or disable "!accept" action via email.')) ->setDescription( pht( 'If inbound email is configured, users can interact with '. 'revisions by using "!actions" in email replies (for example, '. '"!resign" or "!rethink"). However, by default, users may not '. '"!accept" revisions via email: email authentication can be '. 'configured to be very weak, and email "!accept" is kind of '. 'sketchy and implies the revision may not actually be receiving '. 'thorough review. You can enable "!accept" by setting this '. 'option to true.')), $this->newOption('differential.generated-paths', 'list<regex>', array()) ->setSummary(pht('File regexps to treat as automatically generated.')) ->setDescription( pht( 'List of file regexps that should be treated as if they are '. 'generated by an automatic process, and thus be hidden by '. 'default in Differential.'. "\n\n". 'NOTE: This property is cached, so you will need to purge the '. 'cache after making changes if you want the new configuration '. 'to affect existing revisions. For instructions, see '. '**[[ %s | Managing Caches ]]** in the documentation.', $caches_href)) ->addExample("/config\.h$/\n#(^|/)autobuilt/#", pht('Valid Setting')), $this->newOption('differential.sticky-accept', 'bool', true) ->setBoolOptions( array( pht('Accepts persist across updates'), pht('Accepts are reset by updates'), )) ->setSummary( pht('Should "Accepted" revisions remain "Accepted" after updates?')) ->setDescription( pht( 'Normally, when revisions that have been "Accepted" are updated, '. 'they remain "Accepted". This allows reviewers to suggest minor '. 'alterations when accepting, and encourages authors to update '. 'if they make minor changes in response to this feedback.'. "\n\n". 'If you want updates to always require re-review, you can disable '. 'the "stickiness" of the "Accepted" status with this option. '. 'This may make the process for minor changes much more burdensome '. 'to both authors and reviewers.')), $this->newOption('differential.allow-self-accept', 'bool', false) ->setBoolOptions( array( pht('Allow self-accept'), pht('Disallow self-accept'), )) ->setSummary(pht('Allows users to accept their own revisions.')) ->setDescription( pht( "If you set this to true, users can accept their own revisions. ". "This action is disabled by default because it's most likely not ". "a behavior you want, but it proves useful if you are working ". "alone on a project and want to make use of all of ". "differential's features.")), $this->newOption('differential.always-allow-close', 'bool', false) ->setBoolOptions( array( pht('Allow any user'), pht('Restrict to submitter'), )) ->setSummary(pht('Allows any user to close accepted revisions.')) ->setDescription( pht( 'If you set this to true, any user can close any revision so '. 'long as it has been accepted. This can be useful depending on '. 'your development model. For example, github-style pull requests '. 'where the reviewer is often the actual committer can benefit '. 'from turning this option to true. If false, only the submitter '. 'can close a revision.')), $this->newOption('differential.always-allow-abandon', 'bool', false) ->setBoolOptions( array( pht('Allow any user'), pht('Restrict to submitter'), )) ->setSummary(pht('Allows any user to abandon revisions.')) ->setDescription( pht( 'If you set this to true, any user can abandon any revision. If '. 'false, only the submitter can abandon a revision.')), $this->newOption('differential.allow-reopen', 'bool', false) ->setBoolOptions( array( pht('Enable reopen'), pht('Disable reopen'), )) ->setSummary(pht('Allows any user to reopen a closed revision.')) ->setDescription( pht( 'If you set this to true, any user can reopen a revision so '. 'long as it has been closed. This can be useful if a revision '. 'is accidentally closed or if a developer changes his or her '. 'mind after closing a revision. If it is false, reopening '. 'is not allowed.')), $this->newOption('differential.close-on-accept', 'bool', false) ->setBoolOptions( array( pht('Treat Accepted Revisions as "Closed"'), pht('Treat Accepted Revisions as "Open"'), )) ->setSummary(pht('Allows "Accepted" to act as a closed status.')) ->setDescription( pht( 'Normally, Differential revisions remain on the dashboard when '. 'they are "Accepted", and the author then commits the changes '. 'to "Close" the revision and move it off the dashboard.'. "\n\n". 'If you have an unusual workflow where Differential is used for '. 'post-commit review (normally called "Audit", elsewhere), you '. 'can set this flag to treat the "Accepted" '. 'state as a "Closed" state and end the review workflow early.'. "\n\n". 'This sort of workflow is very unusual. Very few installs should '. 'need to change this option.')), $this->newOption( 'metamta.differential.attach-patches', 'bool', false) ->setBoolOptions( array( pht('Attach Patches'), pht('Do Not Attach Patches'), )) ->setSummary(pht('Attach patches to email, as text attachments.')) ->setDescription( pht( 'If you set this to true, patches will be attached to '. 'Differential mail (as text attachments). This will not work if '. 'you are using SendGrid as your mail adapter.')), $this->newOption( 'metamta.differential.inline-patches', 'int', 0) ->setSummary(pht('Inline patches in email, as body text.')) ->setDescription($inline_description), $this->newOption( 'metamta.differential.patch-format', 'enum', 'unified') ->setDescription( pht('Format for inlined or attached patches.')) ->setEnumOptions( array( 'unified' => pht('Unified'), 'git' => pht('Git'), )), ); } }
php
Apache-2.0
5720a38cfe95b00ca4be5016dd0d2f3195f4fa04
2026-01-04T15:03:23.651835Z
false
phacility/phabricator
https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/differential/conduit/DifferentialQueryDiffsConduitAPIMethod.php
src/applications/differential/conduit/DifferentialQueryDiffsConduitAPIMethod.php
<?php final class DifferentialQueryDiffsConduitAPIMethod extends DifferentialConduitAPIMethod { public function getAPIMethodName() { return 'differential.querydiffs'; } public function getMethodDescription() { return pht('Query differential diffs which match certain criteria.'); } public function getMethodStatus() { return self::METHOD_STATUS_FROZEN; } public function getMethodStatusDescription() { return pht( 'This method is frozen and will eventually be deprecated. New code '. 'should use "differential.diff.search" instead.'); } protected function defineParamTypes() { return array( 'ids' => 'optional list<uint>', 'revisionIDs' => 'optional list<uint>', ); } protected function defineReturnType() { return 'list<dict>'; } protected function execute(ConduitAPIRequest $request) { $ids = $request->getValue('ids', array()); $revision_ids = $request->getValue('revisionIDs', array()); if (!$ids && !$revision_ids) { // This method just returns nothing if you pass no constraints because // pagination hadn't been invented yet in 2008 when this method was // written. return array(); } $query = id(new DifferentialDiffQuery()) ->setViewer($request->getUser()) ->needChangesets(true); if ($ids) { $query->withIDs($ids); } if ($revision_ids) { $query->withRevisionIDs($revision_ids); } $diffs = $query->execute(); return mpull($diffs, 'getDiffDict', 'getID'); } }
php
Apache-2.0
5720a38cfe95b00ca4be5016dd0d2f3195f4fa04
2026-01-04T15:03:23.651835Z
false
phacility/phabricator
https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/differential/conduit/DifferentialCreateRevisionConduitAPIMethod.php
src/applications/differential/conduit/DifferentialCreateRevisionConduitAPIMethod.php
<?php final class DifferentialCreateRevisionConduitAPIMethod extends DifferentialConduitAPIMethod { public function getAPIMethodName() { return 'differential.createrevision'; } public function getMethodDescription() { return pht('Create a new Differential revision.'); } public function getMethodStatus() { return self::METHOD_STATUS_FROZEN; } public function getMethodStatusDescription() { return pht( 'This method is frozen and will eventually be deprecated. New code '. 'should use "differential.revision.edit" instead.'); } protected function defineParamTypes() { return array( // TODO: Arcanist passes this; prevent fatals after D4191 until Conduit // version 7 or newer. 'user' => 'ignored', 'diffid' => 'required diffid', 'fields' => 'required dict', ); } protected function defineReturnType() { return 'nonempty dict'; } protected function defineErrorTypes() { return array( 'ERR_BAD_DIFF' => pht('Bad diff ID.'), ); } protected function execute(ConduitAPIRequest $request) { $viewer = $request->getUser(); $diff = id(new DifferentialDiffQuery()) ->setViewer($viewer) ->withIDs(array($request->getValue('diffid'))) ->executeOne(); if (!$diff) { throw new ConduitException('ERR_BAD_DIFF'); } $revision = DifferentialRevision::initializeNewRevision($viewer); $revision->attachReviewers(array()); $result = $this->applyFieldEdit( $request, $revision, $diff, $request->getValue('fields', array()), $message = null); $revision_id = $result['object']['id']; return array( 'revisionid' => $revision_id, 'uri' => PhabricatorEnv::getURI('/D'.$revision_id), ); } }
php
Apache-2.0
5720a38cfe95b00ca4be5016dd0d2f3195f4fa04
2026-01-04T15:03:23.651835Z
false
phacility/phabricator
https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/differential/conduit/DifferentialRevisionSearchConduitAPIMethod.php
src/applications/differential/conduit/DifferentialRevisionSearchConduitAPIMethod.php
<?php final class DifferentialRevisionSearchConduitAPIMethod extends PhabricatorSearchEngineAPIMethod { public function getAPIMethodName() { return 'differential.revision.search'; } public function newSearchEngine() { return new DifferentialRevisionSearchEngine(); } public function getMethodSummary() { return pht('Read information about revisions.'); } }
php
Apache-2.0
5720a38cfe95b00ca4be5016dd0d2f3195f4fa04
2026-01-04T15:03:23.651835Z
false
phacility/phabricator
https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/differential/conduit/DifferentialGetRevisionConduitAPIMethod.php
src/applications/differential/conduit/DifferentialGetRevisionConduitAPIMethod.php
<?php final class DifferentialGetRevisionConduitAPIMethod extends DifferentialConduitAPIMethod { public function getAPIMethodName() { return 'differential.getrevision'; } public function getMethodStatus() { return self::METHOD_STATUS_DEPRECATED; } public function getMethodStatusDescription() { return pht("Replaced by '%s'.", 'differential.query'); } public function getMethodDescription() { return pht('Load the content of a revision from Differential.'); } protected function defineParamTypes() { return array( 'revision_id' => 'required id', ); } protected function defineReturnType() { return 'nonempty dict'; } protected function defineErrorTypes() { return array( 'ERR_BAD_REVISION' => pht('No such revision exists.'), ); } protected function execute(ConduitAPIRequest $request) { $diff = null; $revision_id = $request->getValue('revision_id'); $revision = id(new DifferentialRevisionQuery()) ->withIDs(array($revision_id)) ->setViewer($request->getUser()) ->needReviewers(true) ->needCommitPHIDs(true) ->executeOne(); if (!$revision) { throw new ConduitException('ERR_BAD_REVISION'); } $reviewer_phids = $revision->getReviewerPHIDs(); $diffs = id(new DifferentialDiffQuery()) ->setViewer($request->getUser()) ->withRevisionIDs(array($revision_id)) ->needChangesets(true) ->execute(); $diff_dicts = mpull($diffs, 'getDiffDict'); $commit_dicts = array(); $commit_phids = $revision->getCommitPHIDs(); $handles = id(new PhabricatorHandleQuery()) ->setViewer($request->getUser()) ->withPHIDs($commit_phids) ->execute(); foreach ($commit_phids as $commit_phid) { $commit_dicts[] = array( 'fullname' => $handles[$commit_phid]->getFullName(), 'dateCommitted' => $handles[$commit_phid]->getTimestamp(), ); } $field_data = $this->loadCustomFieldsForRevisions( $request->getUser(), array($revision)); $dict = array( 'id' => $revision->getID(), 'phid' => $revision->getPHID(), 'authorPHID' => $revision->getAuthorPHID(), 'uri' => PhabricatorEnv::getURI('/D'.$revision->getID()), 'title' => $revision->getTitle(), 'status' => $revision->getLegacyRevisionStatus(), 'statusName' => $revision->getStatusDisplayName(), 'summary' => $revision->getSummary(), 'testPlan' => $revision->getTestPlan(), 'lineCount' => $revision->getLineCount(), 'reviewerPHIDs' => $reviewer_phids, 'diffs' => $diff_dicts, 'commits' => $commit_dicts, 'auxiliary' => idx($field_data, $revision->getPHID(), array()), ); return $dict; } }
php
Apache-2.0
5720a38cfe95b00ca4be5016dd0d2f3195f4fa04
2026-01-04T15:03:23.651835Z
false
phacility/phabricator
https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/differential/conduit/DifferentialGetAllDiffsConduitAPIMethod.php
src/applications/differential/conduit/DifferentialGetAllDiffsConduitAPIMethod.php
<?php final class DifferentialGetAllDiffsConduitAPIMethod extends DifferentialConduitAPIMethod { public function getAPIMethodName() { return 'differential.getalldiffs'; } public function getMethodStatus() { return self::METHOD_STATUS_DEPRECATED; } public function getMethodStatusDescription() { return pht( 'This method has been deprecated in favor of %s.', 'differential.querydiffs'); } public function getMethodDescription() { return pht('Load all diffs for given revisions from Differential.'); } protected function defineParamTypes() { return array( 'revision_ids' => 'required list<int>', ); } protected function defineReturnType() { return 'dict'; } protected function execute(ConduitAPIRequest $request) { $results = array(); $revision_ids = $request->getValue('revision_ids'); if (!$revision_ids) { return $results; } $diffs = id(new DifferentialDiffQuery()) ->setViewer($request->getUser()) ->withRevisionIDs($revision_ids) ->execute(); foreach ($diffs as $diff) { $results[] = array( 'revision_id' => $diff->getRevisionID(), 'diff_id' => $diff->getID(), ); } return $results; } }
php
Apache-2.0
5720a38cfe95b00ca4be5016dd0d2f3195f4fa04
2026-01-04T15:03:23.651835Z
false
phacility/phabricator
https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/differential/conduit/DifferentialCreateCommentConduitAPIMethod.php
src/applications/differential/conduit/DifferentialCreateCommentConduitAPIMethod.php
<?php final class DifferentialCreateCommentConduitAPIMethod extends DifferentialConduitAPIMethod { public function getAPIMethodName() { return 'differential.createcomment'; } public function getMethodDescription() { return pht('Add a comment to a Differential revision.'); } public function getMethodStatus() { return self::METHOD_STATUS_FROZEN; } public function getMethodStatusDescription() { return pht( 'This method is frozen and will eventually be deprecated. New code '. 'should use "differential.revision.edit" instead.'); } protected function defineParamTypes() { return array( 'revision_id' => 'required revisionid', 'message' => 'optional string', 'action' => 'optional string', 'silent' => 'optional bool', 'attach_inlines' => 'optional bool', ); } protected function defineReturnType() { return 'nonempty dict'; } protected function defineErrorTypes() { return array( 'ERR_BAD_REVISION' => pht('Bad revision ID.'), ); } protected function execute(ConduitAPIRequest $request) { $viewer = $request->getUser(); $revision = id(new DifferentialRevisionQuery()) ->setViewer($viewer) ->withIDs(array($request->getValue('revision_id'))) ->needReviewers(true) ->needReviewerAuthority(true) ->needActiveDiffs(true) ->executeOne(); if (!$revision) { throw new ConduitException('ERR_BAD_REVISION'); } $xactions = array(); $modular_map = array( 'accept' => DifferentialRevisionAcceptTransaction::TRANSACTIONTYPE, 'reject' => DifferentialRevisionRejectTransaction::TRANSACTIONTYPE, 'resign' => DifferentialRevisionResignTransaction::TRANSACTIONTYPE, 'request_review' => DifferentialRevisionRequestReviewTransaction::TRANSACTIONTYPE, 'rethink' => DifferentialRevisionPlanChangesTransaction::TRANSACTIONTYPE, ); $action = $request->getValue('action'); if (isset($modular_map[$action])) { $xactions[] = id(new DifferentialTransaction()) ->setTransactionType($modular_map[$action]) ->setNewValue(true); } else if ($action) { switch ($action) { case 'comment': case 'none': break; default: throw new Exception( pht( 'Unsupported action "%s".', $action)); break; } } $content = $request->getValue('message'); if (strlen($content)) { $xactions[] = id(new DifferentialTransaction()) ->setTransactionType(PhabricatorTransactions::TYPE_COMMENT) ->attachComment( id(new DifferentialTransactionComment()) ->setContent($content)); } // NOTE: The legacy "attach_inlines" flag is now ignored and has no // effect. See T13513. // NOTE: The legacy "silent" flag is now ignored and has no effect. See // T13042. $editor = id(new DifferentialTransactionEditor()) ->setActor($viewer) ->setContentSource($request->newContentSource()) ->setContinueOnNoEffect(true) ->setContinueOnMissingFields(true); $editor->applyTransactions($revision, $xactions); return array( 'revisionid' => $revision->getID(), 'uri' => PhabricatorEnv::getURI('/D'.$revision->getID()), ); } }
php
Apache-2.0
5720a38cfe95b00ca4be5016dd0d2f3195f4fa04
2026-01-04T15:03:23.651835Z
false
phacility/phabricator
https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/differential/conduit/DifferentialGetRawDiffConduitAPIMethod.php
src/applications/differential/conduit/DifferentialGetRawDiffConduitAPIMethod.php
<?php final class DifferentialGetRawDiffConduitAPIMethod extends DifferentialConduitAPIMethod { public function getAPIMethodName() { return 'differential.getrawdiff'; } public function getMethodDescription() { return pht('Retrieve a raw diff'); } protected function defineParamTypes() { return array( 'diffID' => 'required diffID', ); } protected function defineReturnType() { return 'nonempty string'; } protected function defineErrorTypes() { return array( 'ERR_NOT_FOUND' => pht('Diff not found.'), ); } protected function execute(ConduitAPIRequest $request) { $diff_id = $request->getValue('diffID'); $viewer = $request->getUser(); $diff = id(new DifferentialDiffQuery()) ->withIDs(array($diff_id)) ->setViewer($viewer) ->needChangesets(true) ->executeOne(); if (!$diff) { throw new ConduitException('ERR_NOT_FOUND'); } $renderer = id(new DifferentialRawDiffRenderer()) ->setChangesets($diff->getChangesets()) ->setViewer($viewer) ->setFormat('git'); return $renderer->buildPatch(); } }
php
Apache-2.0
5720a38cfe95b00ca4be5016dd0d2f3195f4fa04
2026-01-04T15:03:23.651835Z
false
phacility/phabricator
https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/differential/conduit/DifferentialParseCommitMessageConduitAPIMethod.php
src/applications/differential/conduit/DifferentialParseCommitMessageConduitAPIMethod.php
<?php final class DifferentialParseCommitMessageConduitAPIMethod extends DifferentialConduitAPIMethod { public function getAPIMethodName() { return 'differential.parsecommitmessage'; } public function getMethodDescription() { return pht('Parse commit messages for Differential fields.'); } protected function defineParamTypes() { return array( 'corpus' => 'required string', 'partial' => 'optional bool', ); } protected function defineReturnType() { return 'nonempty dict'; } protected function execute(ConduitAPIRequest $request) { $viewer = $this->getViewer(); $parser = DifferentialCommitMessageParser::newStandardParser($viewer); $is_partial = $request->getValue('partial'); if ($is_partial) { $parser->setRaiseMissingFieldErrors(false); } $corpus = $request->getValue('corpus'); if ($corpus === null || !strlen($corpus)) { throw new Exception(pht('Field "corpus" must be non-empty.')); } $field_map = $parser->parseFields($corpus); $errors = $parser->getErrors(); $xactions = $parser->getTransactions(); $revision_id_value = idx( $field_map, DifferentialRevisionIDCommitMessageField::FIELDKEY); $revision_id_valid_domain = PhabricatorEnv::getProductionURI(''); return array( 'errors' => $errors, 'fields' => $field_map, 'revisionIDFieldInfo' => array( 'value' => $revision_id_value, 'validDomain' => $revision_id_valid_domain, ), 'transactions' => $xactions, ); } }
php
Apache-2.0
5720a38cfe95b00ca4be5016dd0d2f3195f4fa04
2026-01-04T15:03:23.651835Z
false
phacility/phabricator
https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/differential/conduit/DifferentialSetDiffPropertyConduitAPIMethod.php
src/applications/differential/conduit/DifferentialSetDiffPropertyConduitAPIMethod.php
<?php final class DifferentialSetDiffPropertyConduitAPIMethod extends DifferentialConduitAPIMethod { public function getAPIMethodName() { return 'differential.setdiffproperty'; } public function getMethodDescription() { return pht('Attach properties to Differential diffs.'); } protected function defineParamTypes() { return array( 'diff_id' => 'required diff_id', 'name' => 'required string', 'data' => 'required string', ); } protected function defineReturnType() { return 'void'; } protected function defineErrorTypes() { return array( 'ERR_NOT_FOUND' => pht('Diff was not found.'), ); } protected function execute(ConduitAPIRequest $request) { $data = $request->getValue('data'); if ($data === null || !strlen($data)) { throw new Exception(pht('Field "data" must be non-empty.')); } $diff_id = $request->getValue('diff_id'); if ($diff_id === null) { throw new Exception(pht('Field "diff_id" must be non-null.')); } $name = $request->getValue('name'); if ($name === null || !strlen($name)) { throw new Exception(pht('Field "name" must be non-empty.')); } $data = json_decode($data, true); self::updateDiffProperty($diff_id, $name, $data); } private static function updateDiffProperty($diff_id, $name, $data) { $property = id(new DifferentialDiffProperty())->loadOneWhere( 'diffID = %d AND name = %s', $diff_id, $name); if (!$property) { $property = new DifferentialDiffProperty(); $property->setDiffID($diff_id); $property->setName($name); } $property->setData($data); $property->save(); return $property; } }
php
Apache-2.0
5720a38cfe95b00ca4be5016dd0d2f3195f4fa04
2026-01-04T15:03:23.651835Z
false
phacility/phabricator
https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/differential/conduit/DifferentialQueryConduitAPIMethod.php
src/applications/differential/conduit/DifferentialQueryConduitAPIMethod.php
<?php final class DifferentialQueryConduitAPIMethod extends DifferentialConduitAPIMethod { public function getAPIMethodName() { return 'differential.query'; } public function getMethodDescription() { return pht('Query Differential revisions which match certain criteria.'); } public function getMethodStatus() { return self::METHOD_STATUS_FROZEN; } public function getMethodStatusDescription() { return pht( 'This method is frozen and will eventually be deprecated. New code '. 'should use "differential.revision.search" instead.'); } protected function defineParamTypes() { $hash_types = ArcanistDifferentialRevisionHash::getTypes(); $hash_const = $this->formatStringConstants($hash_types); $status_types = DifferentialLegacyQuery::getAllConstants(); $status_const = $this->formatStringConstants($status_types); $order_types = array( DifferentialRevisionQuery::ORDER_MODIFIED, DifferentialRevisionQuery::ORDER_CREATED, ); $order_const = $this->formatStringConstants($order_types); return array( 'authors' => 'optional list<phid>', 'ccs' => 'optional list<phid>', 'reviewers' => 'optional list<phid>', 'paths' => 'unsupported', 'commitHashes' => 'optional list<pair<'.$hash_const.', string>>', 'status' => 'optional '.$status_const, 'order' => 'optional '.$order_const, 'limit' => 'optional uint', 'offset' => 'optional uint', 'ids' => 'optional list<uint>', 'phids' => 'optional list<phid>', 'subscribers' => 'optional list<phid>', 'responsibleUsers' => 'optional list<phid>', 'branches' => 'optional list<string>', ); } protected function defineReturnType() { return 'list<dict>'; } protected function defineErrorTypes() { return array( 'ERR-INVALID-PARAMETER' => pht('Missing or malformed parameter.'), ); } protected function execute(ConduitAPIRequest $request) { $authors = $request->getValue('authors'); $ccs = $request->getValue('ccs'); $reviewers = $request->getValue('reviewers'); $status = $request->getValue('status'); $order = $request->getValue('order'); $path_pairs = $request->getValue('paths'); $commit_hashes = $request->getValue('commitHashes'); $limit = $request->getValue('limit'); $offset = $request->getValue('offset'); $ids = $request->getValue('ids'); $phids = $request->getValue('phids'); $subscribers = $request->getValue('subscribers'); $responsible_users = $request->getValue('responsibleUsers'); $branches = $request->getValue('branches'); $query = id(new DifferentialRevisionQuery()) ->setViewer($request->getUser()); if ($authors) { $query->withAuthors($authors); } if ($ccs) { $query->withCCs($ccs); } if ($reviewers) { $query->withReviewers($reviewers); } if ($path_pairs) { throw new Exception( pht( 'Parameter "paths" to Conduit API method "differential.query" is '. 'no longer supported. Use the "paths" constraint to '. '"differential.revision.search" instead. See T13639.')); } if ($commit_hashes) { $hash_types = ArcanistDifferentialRevisionHash::getTypes(); foreach ($commit_hashes as $info) { list($type, $hash) = $info; if (empty($type) || !in_array($type, $hash_types) || empty($hash)) { throw new ConduitException('ERR-INVALID-PARAMETER'); } } $query->withCommitHashes($commit_hashes); } if ($status) { $statuses = DifferentialLegacyQuery::getModernValues($status); if ($statuses) { $query->withStatuses($statuses); } } if ($order) { $query->setOrder($order); } if ($limit) { $query->setLimit($limit); } if ($offset) { $query->setOffset($offset); } if ($ids) { $query->withIDs($ids); } if ($phids) { $query->withPHIDs($phids); } if ($responsible_users) { $query->withResponsibleUsers($responsible_users); } if ($subscribers) { $query->withCCs($subscribers); } if ($branches) { $query->withBranches($branches); } $query->needReviewers(true); $query->needCommitPHIDs(true); $query->needDiffIDs(true); $query->needActiveDiffs(true); $query->needHashes(true); $revisions = $query->execute(); $field_data = $this->loadCustomFieldsForRevisions( $request->getUser(), $revisions); if ($revisions) { $ccs = id(new PhabricatorSubscribersQuery()) ->withObjectPHIDs(mpull($revisions, 'getPHID')) ->execute(); } else { $ccs = array(); } $results = array(); foreach ($revisions as $revision) { $diff = $revision->getActiveDiff(); if (!$diff) { continue; } $id = $revision->getID(); $phid = $revision->getPHID(); $result = array( 'id' => $id, 'phid' => $phid, 'title' => $revision->getTitle(), 'uri' => PhabricatorEnv::getProductionURI('/D'.$id), 'dateCreated' => $revision->getDateCreated(), 'dateModified' => $revision->getDateModified(), 'authorPHID' => $revision->getAuthorPHID(), // NOTE: For backward compatibility this is explicitly a string, like // "2", even though the value of the string is an integer. See PHI14. 'status' => (string)$revision->getLegacyRevisionStatus(), 'statusName' => $revision->getStatusDisplayName(), 'properties' => $revision->getProperties(), 'branch' => $diff->getBranch(), 'summary' => $revision->getSummary(), 'testPlan' => $revision->getTestPlan(), 'lineCount' => $revision->getLineCount(), 'activeDiffPHID' => $diff->getPHID(), 'diffs' => $revision->getDiffIDs(), 'commits' => $revision->getCommitPHIDs(), 'reviewers' => $revision->getReviewerPHIDs(), 'ccs' => idx($ccs, $phid, array()), 'hashes' => $revision->getHashes(), 'auxiliary' => idx($field_data, $phid, array()), 'repositoryPHID' => $diff->getRepositoryPHID(), ); // TODO: This is a hacky way to put permissions on this field until we // have first-class support, see T838. if ($revision->getAuthorPHID() == $request->getUser()->getPHID()) { $result['sourcePath'] = $diff->getSourcePath(); } $results[] = $result; } return $results; } }
php
Apache-2.0
5720a38cfe95b00ca4be5016dd0d2f3195f4fa04
2026-01-04T15:03:23.651835Z
false
phacility/phabricator
https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/differential/conduit/DifferentialConduitAPIMethod.php
src/applications/differential/conduit/DifferentialConduitAPIMethod.php
<?php abstract class DifferentialConduitAPIMethod extends ConduitAPIMethod { final public function getApplication() { return PhabricatorApplication::getByClass( 'PhabricatorDifferentialApplication'); } protected function buildDiffInfoDictionary(DifferentialDiff $diff) { $uri = '/differential/diff/'.$diff->getID().'/'; $uri = PhabricatorEnv::getProductionURI($uri); return array( 'id' => $diff->getID(), 'phid' => $diff->getPHID(), 'uri' => $uri, ); } protected function buildInlineInfoDictionary( DifferentialInlineComment $inline, DifferentialChangeset $changeset = null) { $file_path = null; $diff_id = null; if ($changeset) { $file_path = $inline->getIsNewFile() ? $changeset->getFilename() : $changeset->getOldFile(); $diff_id = $changeset->getDiffID(); } return array( 'id' => $inline->getID(), 'authorPHID' => $inline->getAuthorPHID(), 'filePath' => $file_path, 'isNewFile' => $inline->getIsNewFile(), 'lineNumber' => $inline->getLineNumber(), 'lineLength' => $inline->getLineLength(), 'diffID' => $diff_id, 'content' => $inline->getContent(), ); } protected function applyFieldEdit( ConduitAPIRequest $request, DifferentialRevision $revision, DifferentialDiff $diff, array $fields, $message) { $viewer = $request->getUser(); // We're going to build the body of a "differential.revision.edit" API // request, then just call that code directly. $xactions = array(); $xactions[] = array( 'type' => DifferentialRevisionUpdateTransaction::EDITKEY, 'value' => $diff->getPHID(), ); $field_map = DifferentialCommitMessageField::newEnabledFields($viewer); $values = $request->getValue('fields', array()); foreach ($values as $key => $value) { $field = idx($field_map, $key); if (!$field) { // NOTE: We're just ignoring fields we don't know about. This isn't // ideal, but the way the workflow currently works involves us getting // several read-only fields, like the revision ID field, which we should // just skip. continue; } // The transaction itself will be validated so this is somewhat // redundant, but this validator will sometimes give us a better error // message or a better reaction to a bad value type. $value = $field->readFieldValueFromConduit($value); foreach ($field->getFieldTransactions($value) as $xaction) { $xactions[] = $xaction; } } $message = $request->getValue('message'); if (strlen($message)) { // This is a little awkward, and should move elsewhere or be removed. It // largely exists for legacy reasons. See some discussion in T7899. $first_line = head(phutil_split_lines($message, false)); $first_line = id(new PhutilUTF8StringTruncator()) ->setMaximumBytes(250) ->setMaximumGlyphs(80) ->truncateString($first_line); $diff->setDescription($first_line); $diff->save(); $xactions[] = array( 'type' => PhabricatorCommentEditEngineExtension::EDITKEY, 'value' => $message, ); } $method = 'differential.revision.edit'; $params = array( 'transactions' => $xactions, ); if ($revision->getID()) { $params['objectIdentifier'] = $revision->getID(); } return id(new ConduitCall($method, $params, $strict = true)) ->setUser($viewer) ->execute(); } protected function loadCustomFieldsForRevisions( PhabricatorUser $viewer, array $revisions) { assert_instances_of($revisions, 'DifferentialRevision'); if (!$revisions) { return array(); } $field_lists = array(); foreach ($revisions as $revision) { $revision_phid = $revision->getPHID(); $field_list = PhabricatorCustomField::getObjectFields( $revision, PhabricatorCustomField::ROLE_CONDUIT); $field_list ->setViewer($viewer) ->readFieldsFromObject($revision); $field_lists[$revision_phid] = $field_list; } $all_fields = array(); foreach ($field_lists as $field_list) { foreach ($field_list->getFields() as $field) { $all_fields[] = $field; } } id(new PhabricatorCustomFieldStorageQuery()) ->addFields($all_fields) ->execute(); $results = array(); foreach ($field_lists as $revision_phid => $field_list) { $results[$revision_phid] = array(); foreach ($field_list->getFields() as $field) { $field_key = $field->getFieldKeyForConduit(); $value = $field->getConduitDictionaryValue(); $results[$revision_phid][$field_key] = $value; } } // For compatibility, fill in these "custom fields" by querying for them // efficiently. See T11404 for discussion. $legacy_edge_map = array( 'phabricator:projects' => PhabricatorProjectObjectHasProjectEdgeType::EDGECONST, 'phabricator:depends-on' => DifferentialRevisionDependsOnRevisionEdgeType::EDGECONST, ); $query = id(new PhabricatorEdgeQuery()) ->withSourcePHIDs(array_keys($results)) ->withEdgeTypes($legacy_edge_map); $query->execute(); foreach ($results as $revision_phid => $dict) { foreach ($legacy_edge_map as $edge_key => $edge_type) { $phid_list = $query->getDestinationPHIDs( array($revision_phid), array($edge_type)); $results[$revision_phid][$edge_key] = $phid_list; } } return $results; } }
php
Apache-2.0
5720a38cfe95b00ca4be5016dd0d2f3195f4fa04
2026-01-04T15:03:23.651835Z
false
phacility/phabricator
https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/differential/conduit/DifferentialCreateDiffConduitAPIMethod.php
src/applications/differential/conduit/DifferentialCreateDiffConduitAPIMethod.php
<?php final class DifferentialCreateDiffConduitAPIMethod extends DifferentialConduitAPIMethod { public function getAPIMethodName() { return 'differential.creatediff'; } public function getMethodDescription() { return pht('Create a new Differential diff.'); } protected function defineParamTypes() { $vcs_const = $this->formatStringConstants( array( 'svn', 'git', 'hg', )); $status_const = $this->formatStringConstants( array( 'none', 'skip', 'okay', 'warn', 'fail', )); return array( 'changes' => 'required list<dict>', 'sourceMachine' => 'required string', 'sourcePath' => 'required string', 'branch' => 'required string', 'bookmark' => 'optional string', 'sourceControlSystem' => 'required '.$vcs_const, 'sourceControlPath' => 'required string', 'sourceControlBaseRevision' => 'required string', 'creationMethod' => 'optional string', 'lintStatus' => 'required '.$status_const, 'unitStatus' => 'required '.$status_const, 'repositoryPHID' => 'optional phid', 'parentRevisionID' => 'deprecated', 'authorPHID' => 'deprecated', 'repositoryUUID' => 'deprecated', ); } protected function defineReturnType() { return 'nonempty dict'; } protected function execute(ConduitAPIRequest $request) { $viewer = $request->getUser(); $change_data = $request->getValue('changes'); if ($change_data === null) { throw new Exception(pht('Field "changes" must be non-empty.')); } $changes = array(); foreach ($change_data as $dict) { $changes[] = ArcanistDiffChange::newFromDictionary($dict); } $diff = DifferentialDiff::newFromRawChanges($viewer, $changes); // TODO: Remove repository UUID eventually; for now continue writing // the UUID. Note that we'll overwrite it below if we identify a // repository, and `arc` no longer sends it. This stuff is retained for // backward compatibility. $repository_uuid = $request->getValue('repositoryUUID'); $repository_phid = $request->getValue('repositoryPHID'); if ($repository_phid) { $repository = id(new PhabricatorRepositoryQuery()) ->setViewer($viewer) ->withPHIDs(array($repository_phid)) ->executeOne(); if ($repository) { $repository_phid = $repository->getPHID(); $repository_uuid = $repository->getUUID(); } } switch ($request->getValue('lintStatus')) { case 'skip': $lint_status = DifferentialLintStatus::LINT_SKIP; break; case 'okay': $lint_status = DifferentialLintStatus::LINT_OKAY; break; case 'warn': $lint_status = DifferentialLintStatus::LINT_WARN; break; case 'fail': $lint_status = DifferentialLintStatus::LINT_FAIL; break; case 'none': default: $lint_status = DifferentialLintStatus::LINT_NONE; break; } switch ($request->getValue('unitStatus')) { case 'skip': $unit_status = DifferentialUnitStatus::UNIT_SKIP; break; case 'okay': $unit_status = DifferentialUnitStatus::UNIT_OKAY; break; case 'warn': $unit_status = DifferentialUnitStatus::UNIT_WARN; break; case 'fail': $unit_status = DifferentialUnitStatus::UNIT_FAIL; break; case 'none': default: $unit_status = DifferentialUnitStatus::UNIT_NONE; break; } $source_path = $request->getValue('sourcePath'); $source_path = $this->normalizeSourcePath($source_path); $diff_data_dict = array( 'sourcePath' => $source_path, 'sourceMachine' => $request->getValue('sourceMachine'), 'branch' => $request->getValue('branch'), 'creationMethod' => $request->getValue('creationMethod'), 'authorPHID' => $viewer->getPHID(), 'bookmark' => $request->getValue('bookmark'), 'repositoryUUID' => $repository_uuid, 'repositoryPHID' => $repository_phid, 'sourceControlSystem' => $request->getValue('sourceControlSystem'), 'sourceControlPath' => $request->getValue('sourceControlPath'), 'sourceControlBaseRevision' => $request->getValue('sourceControlBaseRevision'), 'lintStatus' => $lint_status, 'unitStatus' => $unit_status, ); $xactions = array( id(new DifferentialDiffTransaction()) ->setTransactionType(DifferentialDiffTransaction::TYPE_DIFF_CREATE) ->setNewValue($diff_data_dict), ); id(new DifferentialDiffEditor()) ->setActor($viewer) ->setContentSource($request->newContentSource()) ->setContinueOnNoEffect(true) ->applyTransactions($diff, $xactions); $path = '/differential/diff/'.$diff->getID().'/'; $uri = PhabricatorEnv::getURI($path); return array( 'diffid' => $diff->getID(), 'phid' => $diff->getPHID(), 'uri' => $uri, ); } private function normalizeSourcePath($source_path) { // See T13385. This property is probably headed for deletion. Until we get // there, stop errors arising from running "arc diff" in a working copy // with too many characters. $max_size = id(new DifferentialDiff()) ->getColumnMaximumByteLength('sourcePath'); return id(new PhutilUTF8StringTruncator()) ->setMaximumBytes($max_size) ->setTerminator('') ->truncateString($source_path); } }
php
Apache-2.0
5720a38cfe95b00ca4be5016dd0d2f3195f4fa04
2026-01-04T15:03:23.651835Z
false
phacility/phabricator
https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/differential/conduit/DifferentialCreateInlineConduitAPIMethod.php
src/applications/differential/conduit/DifferentialCreateInlineConduitAPIMethod.php
<?php final class DifferentialCreateInlineConduitAPIMethod extends DifferentialConduitAPIMethod { public function getAPIMethodName() { return 'differential.createinline'; } public function getMethodDescription() { return pht('Add an inline comment to a Differential revision.'); } protected function defineParamTypes() { return array( 'revisionID' => 'optional revisionid', 'diffID' => 'optional diffid', 'filePath' => 'required string', 'isNewFile' => 'required bool', 'lineNumber' => 'required int', 'lineLength' => 'optional int', 'content' => 'required string', ); } protected function defineReturnType() { return 'nonempty dict'; } protected function defineErrorTypes() { return array( 'ERR-BAD-REVISION' => pht( 'Bad revision ID.'), 'ERR-BAD-DIFF' => pht( 'Bad diff ID, or diff does not belong to revision.'), 'ERR-NEED-DIFF' => pht( 'Neither revision ID nor diff ID was provided.'), 'ERR-NEED-FILE' => pht( 'A file path was not provided.'), 'ERR-BAD-FILE' => pht( "Requested file doesn't exist in this revision."), ); } protected function execute(ConduitAPIRequest $request) { $rid = $request->getValue('revisionID'); $did = $request->getValue('diffID'); if ($rid) { // Given both a revision and a diff, check that they match. // Given only a revision, find the active diff. $revision = id(new DifferentialRevisionQuery()) ->setViewer($request->getUser()) ->withIDs(array($rid)) ->executeOne(); if (!$revision) { throw new ConduitException('ERR-BAD-REVISION'); } if (!$did) { // did not! $diff = $revision->loadActiveDiff(); $did = $diff->getID(); } else { // did too! $diff = id(new DifferentialDiff())->load($did); if (!$diff || $diff->getRevisionID() != $rid) { throw new ConduitException('ERR-BAD-DIFF'); } } } else if ($did) { // Given only a diff, find the parent revision. $diff = id(new DifferentialDiff())->load($did); if (!$diff) { throw new ConduitException('ERR-BAD-DIFF'); } $rid = $diff->getRevisionID(); } else { // Given neither, bail. throw new ConduitException('ERR-NEED-DIFF'); } $file = $request->getValue('filePath'); if (!$file) { throw new ConduitException('ERR-NEED-FILE'); } $changes = id(new DifferentialChangeset())->loadAllWhere( 'diffID = %d', $did); $cid = null; foreach ($changes as $id => $change) { if ($file == $change->getFilename()) { $cid = $id; } } if ($cid == null) { throw new ConduitException('ERR-BAD-FILE'); } $inline = id(new DifferentialInlineComment()) ->setRevisionID($rid) ->setChangesetID($cid) ->setAuthorPHID($request->getUser()->getPHID()) ->setContent($request->getValue('content')) ->setIsNewFile((int)$request->getValue('isNewFile')) ->setLineNumber($request->getValue('lineNumber')) ->setLineLength($request->getValue('lineLength', 0)) ->save(); // Load everything again, just to be safe. $changeset = id(new DifferentialChangeset()) ->load($inline->getChangesetID()); return $this->buildInlineInfoDictionary($inline, $changeset); } }
php
Apache-2.0
5720a38cfe95b00ca4be5016dd0d2f3195f4fa04
2026-01-04T15:03:23.651835Z
false
phacility/phabricator
https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/differential/conduit/DifferentialCloseConduitAPIMethod.php
src/applications/differential/conduit/DifferentialCloseConduitAPIMethod.php
<?php final class DifferentialCloseConduitAPIMethod extends DifferentialConduitAPIMethod { public function getAPIMethodName() { return 'differential.close'; } public function getMethodDescription() { return pht('Close a Differential revision.'); } public function getMethodStatus() { return self::METHOD_STATUS_FROZEN; } public function getMethodStatusDescription() { return pht( 'This method is frozen and will eventually be deprecated. New code '. 'should use "differential.revision.edit" instead.'); } protected function defineParamTypes() { return array( 'revisionID' => 'required int', ); } protected function defineReturnType() { return 'void'; } protected function defineErrorTypes() { return array( 'ERR_NOT_FOUND' => pht('Revision was not found.'), ); } protected function execute(ConduitAPIRequest $request) { $viewer = $request->getUser(); $id = $request->getValue('revisionID'); $revision = id(new DifferentialRevisionQuery()) ->withIDs(array($id)) ->setViewer($viewer) ->needReviewers(true) ->executeOne(); if (!$revision) { throw new ConduitException('ERR_NOT_FOUND'); } $xactions = array(); $xactions[] = id(new DifferentialTransaction()) ->setTransactionType( DifferentialRevisionCloseTransaction::TRANSACTIONTYPE) ->setNewValue(true); $content_source = $request->newContentSource(); $editor = id(new DifferentialTransactionEditor()) ->setActor($viewer) ->setContentSource($request->newContentSource()) ->setContinueOnMissingFields(true) ->setContinueOnNoEffect(true); $editor->applyTransactions($revision, $xactions); return; } }
php
Apache-2.0
5720a38cfe95b00ca4be5016dd0d2f3195f4fa04
2026-01-04T15:03:23.651835Z
false
phacility/phabricator
https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/differential/conduit/DifferentialChangesetSearchConduitAPIMethod.php
src/applications/differential/conduit/DifferentialChangesetSearchConduitAPIMethod.php
<?php final class DifferentialChangesetSearchConduitAPIMethod extends PhabricatorSearchEngineAPIMethod { public function getAPIMethodName() { return 'differential.changeset.search'; } public function newSearchEngine() { return new DifferentialChangesetSearchEngine(); } public function getMethodSummary() { return pht('Read information about changesets.'); } }
php
Apache-2.0
5720a38cfe95b00ca4be5016dd0d2f3195f4fa04
2026-01-04T15:03:23.651835Z
false
phacility/phabricator
https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/differential/conduit/DifferentialRevisionEditConduitAPIMethod.php
src/applications/differential/conduit/DifferentialRevisionEditConduitAPIMethod.php
<?php final class DifferentialRevisionEditConduitAPIMethod extends PhabricatorEditEngineAPIMethod { public function getAPIMethodName() { return 'differential.revision.edit'; } public function newEditEngine() { return new DifferentialRevisionEditEngine(); } public function getMethodSummary() { return pht('Apply transactions to create or update a revision.'); } }
php
Apache-2.0
5720a38cfe95b00ca4be5016dd0d2f3195f4fa04
2026-01-04T15:03:23.651835Z
false
phacility/phabricator
https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/differential/conduit/DifferentialDiffSearchConduitAPIMethod.php
src/applications/differential/conduit/DifferentialDiffSearchConduitAPIMethod.php
<?php final class DifferentialDiffSearchConduitAPIMethod extends PhabricatorSearchEngineAPIMethod { public function getAPIMethodName() { return 'differential.diff.search'; } public function newSearchEngine() { return new DifferentialDiffSearchEngine(); } public function getMethodSummary() { return pht('Read information about diffs.'); } }
php
Apache-2.0
5720a38cfe95b00ca4be5016dd0d2f3195f4fa04
2026-01-04T15:03:23.651835Z
false
phacility/phabricator
https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/differential/conduit/DifferentialUpdateRevisionConduitAPIMethod.php
src/applications/differential/conduit/DifferentialUpdateRevisionConduitAPIMethod.php
<?php final class DifferentialUpdateRevisionConduitAPIMethod extends DifferentialConduitAPIMethod { public function getAPIMethodName() { return 'differential.updaterevision'; } public function getMethodDescription() { return pht('Update a Differential revision.'); } public function getMethodStatus() { return self::METHOD_STATUS_FROZEN; } public function getMethodStatusDescription() { return pht( 'This method is frozen and will eventually be deprecated. New code '. 'should use "differential.revision.edit" instead.'); } protected function defineParamTypes() { return array( 'id' => 'required revisionid', 'diffid' => 'required diffid', 'fields' => 'required dict', 'message' => 'required string', ); } protected function defineReturnType() { return 'nonempty dict'; } protected function defineErrorTypes() { return array( 'ERR_BAD_DIFF' => pht('Bad diff ID.'), 'ERR_BAD_REVISION' => pht('Bad revision ID.'), 'ERR_WRONG_USER' => pht('You are not the author of this revision.'), 'ERR_CLOSED' => pht('This revision has already been closed.'), ); } protected function execute(ConduitAPIRequest $request) { $viewer = $request->getUser(); $diff = id(new DifferentialDiffQuery()) ->setViewer($viewer) ->withIDs(array($request->getValue('diffid'))) ->executeOne(); if (!$diff) { throw new ConduitException('ERR_BAD_DIFF'); } $revision = id(new DifferentialRevisionQuery()) ->setViewer($request->getUser()) ->withIDs(array($request->getValue('id'))) ->needReviewers(true) ->needActiveDiffs(true) ->requireCapabilities( array( PhabricatorPolicyCapability::CAN_VIEW, PhabricatorPolicyCapability::CAN_EDIT, )) ->executeOne(); if (!$revision) { throw new ConduitException('ERR_BAD_REVISION'); } if ($revision->isPublished()) { throw new ConduitException('ERR_CLOSED'); } $this->applyFieldEdit( $request, $revision, $diff, $request->getValue('fields', array()), $request->getValue('message')); return array( 'revisionid' => $revision->getID(), 'uri' => PhabricatorEnv::getURI('/D'.$revision->getID()), ); } }
php
Apache-2.0
5720a38cfe95b00ca4be5016dd0d2f3195f4fa04
2026-01-04T15:03:23.651835Z
false
phacility/phabricator
https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/differential/conduit/DifferentialGetRevisionCommentsConduitAPIMethod.php
src/applications/differential/conduit/DifferentialGetRevisionCommentsConduitAPIMethod.php
<?php final class DifferentialGetRevisionCommentsConduitAPIMethod extends DifferentialConduitAPIMethod { public function getAPIMethodName() { return 'differential.getrevisioncomments'; } public function getMethodStatus() { return self::METHOD_STATUS_DEPRECATED; } public function getMethodStatusDescription() { return pht('Obsolete and doomed, see T2222.'); } public function getMethodDescription() { return pht('Retrieve Differential Revision Comments.'); } protected function defineParamTypes() { return array( 'ids' => 'required list<int>', 'inlines' => 'optional bool (deprecated)', ); } protected function defineReturnType() { return 'nonempty list<dict<string, wild>>'; } protected function execute(ConduitAPIRequest $request) { $viewer = $request->getUser(); $results = array(); $revision_ids = $request->getValue('ids'); if (!$revision_ids) { return $results; } $revisions = id(new DifferentialRevisionQuery()) ->setViewer($viewer) ->withIDs($revision_ids) ->execute(); if (!$revisions) { return $results; } $xactions = id(new DifferentialTransactionQuery()) ->setViewer($viewer) ->withObjectPHIDs(mpull($revisions, 'getPHID')) ->execute(); $revisions = mpull($revisions, null, 'getPHID'); foreach ($xactions as $xaction) { $revision = idx($revisions, $xaction->getObjectPHID()); if (!$revision) { continue; } $type = $xaction->getTransactionType(); if ($type == DifferentialTransaction::TYPE_ACTION) { $action = $xaction->getNewValue(); } else if ($type == PhabricatorTransactions::TYPE_COMMENT) { $action = 'comment'; } else { $action = 'none'; } $result = array( 'revisionID' => $revision->getID(), 'action' => $action, 'authorPHID' => $xaction->getAuthorPHID(), 'dateCreated' => $xaction->getDateCreated(), 'content' => ($xaction->hasComment() ? $xaction->getComment()->getContent() : null), ); $results[$revision->getID()][] = $result; } return $results; } }
php
Apache-2.0
5720a38cfe95b00ca4be5016dd0d2f3195f4fa04
2026-01-04T15:03:23.651835Z
false
phacility/phabricator
https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/differential/conduit/DifferentialGetDiffConduitAPIMethod.php
src/applications/differential/conduit/DifferentialGetDiffConduitAPIMethod.php
<?php final class DifferentialGetDiffConduitAPIMethod extends DifferentialConduitAPIMethod { public function getAPIMethodName() { return 'differential.getdiff'; } public function shouldAllowPublic() { return true; } public function getMethodStatus() { return self::METHOD_STATUS_DEPRECATED; } public function getMethodStatusDescription() { return pht( 'This method has been deprecated in favor of %s.', 'differential.querydiffs'); } public function getMethodDescription() { return pht( 'Load the content of a diff from Differential by revision ID '. 'or diff ID.'); } protected function defineParamTypes() { return array( 'revision_id' => 'optional id', 'diff_id' => 'optional id', ); } protected function defineReturnType() { return 'nonempty dict'; } protected function defineErrorTypes() { return array( 'ERR_BAD_DIFF' => pht('No such diff exists.'), ); } protected function execute(ConduitAPIRequest $request) { $diff_id = $request->getValue('diff_id'); // If we have a revision ID, we need the most recent diff. Figure that out // without loading all the attached data. $revision_id = $request->getValue('revision_id'); if ($revision_id) { $diffs = id(new DifferentialDiffQuery()) ->setViewer($request->getUser()) ->withRevisionIDs(array($revision_id)) ->execute(); if ($diffs) { $diff_id = head($diffs)->getID(); } else { throw new ConduitException('ERR_BAD_DIFF'); } } $diff = null; if ($diff_id) { $diff = id(new DifferentialDiffQuery()) ->setViewer($request->getUser()) ->withIDs(array($diff_id)) ->needChangesets(true) ->executeOne(); } if (!$diff) { throw new ConduitException('ERR_BAD_DIFF'); } return $diff->getDiffDict(); } }
php
Apache-2.0
5720a38cfe95b00ca4be5016dd0d2f3195f4fa04
2026-01-04T15:03:23.651835Z
false
phacility/phabricator
https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/differential/conduit/DifferentialCreateRawDiffConduitAPIMethod.php
src/applications/differential/conduit/DifferentialCreateRawDiffConduitAPIMethod.php
<?php final class DifferentialCreateRawDiffConduitAPIMethod extends DifferentialConduitAPIMethod { public function getAPIMethodName() { return 'differential.createrawdiff'; } public function getMethodDescription() { return pht('Create a new Differential diff from a raw diff source.'); } protected function defineParamTypes() { return array( 'diff' => 'required string', 'repositoryPHID' => 'optional string', 'viewPolicy' => 'optional string', ); } protected function defineReturnType() { return 'nonempty dict'; } protected function execute(ConduitAPIRequest $request) { $viewer = $request->getUser(); $raw_diff = $request->getValue('diff'); if ($raw_diff === null || !strlen($raw_diff)) { throw new Exception(pht('Field "raw_diff" must be non-empty.')); } $repository_phid = $request->getValue('repositoryPHID'); if ($repository_phid) { $repository = id(new PhabricatorRepositoryQuery()) ->setViewer($viewer) ->withPHIDs(array($repository_phid)) ->executeOne(); if (!$repository) { throw new Exception( pht('No such repository "%s"!', $repository_phid)); } } $parser = new ArcanistDiffParser(); $changes = $parser->parseDiff($raw_diff); $diff = DifferentialDiff::newFromRawChanges($viewer, $changes); // We're bounded by doing INSERTs for all the hunks and changesets, so // estimate the number of inserts we'll require. $size = 0; foreach ($diff->getChangesets() as $changeset) { $hunks = $changeset->getHunks(); $size += 1 + count($hunks); } $raw_limit = 10000; if ($size > $raw_limit) { throw new Exception( pht( 'The raw diff you have submitted is too large to parse (it affects '. 'more than %s paths and hunks).', new PhutilNumber($raw_limit))); } $diff_data_dict = array( 'creationMethod' => 'web', 'authorPHID' => $viewer->getPHID(), 'repositoryPHID' => $repository_phid, 'lintStatus' => DifferentialLintStatus::LINT_SKIP, 'unitStatus' => DifferentialUnitStatus::UNIT_SKIP, ); $xactions = array( id(new DifferentialDiffTransaction()) ->setTransactionType(DifferentialDiffTransaction::TYPE_DIFF_CREATE) ->setNewValue($diff_data_dict), ); if ($request->getValue('viewPolicy')) { $xactions[] = id(new DifferentialDiffTransaction()) ->setTransactionType(PhabricatorTransactions::TYPE_VIEW_POLICY) ->setNewValue($request->getValue('viewPolicy')); } id(new DifferentialDiffEditor()) ->setActor($viewer) ->setContentSource($request->newContentSource()) ->setContinueOnNoEffect(true) ->setLookupRepository(false) // respect user choice ->applyTransactions($diff, $xactions); return $this->buildDiffInfoDictionary($diff); } }
php
Apache-2.0
5720a38cfe95b00ca4be5016dd0d2f3195f4fa04
2026-01-04T15:03:23.651835Z
false
phacility/phabricator
https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/differential/conduit/DifferentialGetCommitMessageConduitAPIMethod.php
src/applications/differential/conduit/DifferentialGetCommitMessageConduitAPIMethod.php
<?php final class DifferentialGetCommitMessageConduitAPIMethod extends DifferentialConduitAPIMethod { public function getAPIMethodName() { return 'differential.getcommitmessage'; } public function getMethodDescription() { return pht('Retrieve Differential commit messages or message templates.'); } protected function defineParamTypes() { $edit_types = array('edit', 'create'); return array( 'revision_id' => 'optional revision_id', 'fields' => 'optional dict<string, wild>', 'edit' => 'optional '.$this->formatStringConstants($edit_types), ); } protected function defineReturnType() { return 'nonempty string'; } protected function defineErrorTypes() { return array( 'ERR_NOT_FOUND' => pht('Revision was not found.'), ); } protected function execute(ConduitAPIRequest $request) { $id = $request->getValue('revision_id'); $viewer = $request->getUser(); if ($id) { $revision = id(new DifferentialRevisionQuery()) ->withIDs(array($id)) ->setViewer($viewer) ->needReviewers(true) ->needActiveDiffs(true) ->executeOne(); if (!$revision) { throw new ConduitException('ERR_NOT_FOUND'); } } else { $revision = DifferentialRevision::initializeNewRevision($viewer); } // There are three modes here: "edit", "create", and "read" (which has // no value for the "edit" parameter). // In edit or create mode, we hide read-only fields. In create mode, we // show "Field:" templates for some fields even if they are empty. $edit_mode = $request->getValue('edit'); $is_any_edit = $edit_mode !== null && (bool)strlen($edit_mode); $is_create = ($edit_mode == 'create'); $field_list = DifferentialCommitMessageField::newEnabledFields($viewer); $custom_storage = $this->loadCustomFieldStorage($viewer, $revision); foreach ($field_list as $field) { $field->setCustomFieldStorage($custom_storage); } // If we're editing the message, remove fields like "Conflicts" and // "git-svn-id" which should not be presented to the user for editing. if ($is_any_edit) { foreach ($field_list as $field_key => $field) { if (!$field->isFieldEditable()) { unset($field_list[$field_key]); } } } $overrides = $request->getValue('fields', array()); $value_map = array(); foreach ($field_list as $field_key => $field) { if (array_key_exists($field_key, $overrides)) { $field_value = $overrides[$field_key]; } else { $field_value = $field->readFieldValueFromObject($revision); } // We're calling this method on the value no matter where we got it // from, so we hit the same validation logic for values which came over // the wire and which we generated. $field_value = $field->readFieldValueFromConduit($field_value); $value_map[$field_key] = $field_value; } $key_title = DifferentialTitleCommitMessageField::FIELDKEY; $commit_message = array(); foreach ($field_list as $field_key => $field) { $label = $field->getFieldName(); $wire_value = $value_map[$field_key]; $value = $field->renderFieldValue($wire_value); $is_template = ($is_create && $field->isTemplateField()); if (!is_string($value) && !is_null($value)) { throw new Exception( pht( 'Commit message field "%s" was expected to render a string or '. 'null value, but rendered a "%s" instead.', $field->getFieldKey(), gettype($value))); } $is_title = ($field_key == $key_title); if ($value === null || !strlen($value)) { if ($is_template) { $commit_message[] = $label.': '; } } else { if ($is_title) { $commit_message[] = $value; } else { $value = str_replace( array("\r\n", "\r"), array("\n", "\n"), $value); if (strpos($value, "\n") !== false || substr($value, 0, 2) === ' ') { $commit_message[] = "{$label}:\n{$value}"; } else { $commit_message[] = "{$label}: {$value}"; } } } } return implode("\n\n", $commit_message); } private function loadCustomFieldStorage( PhabricatorUser $viewer, DifferentialRevision $revision) { $custom_field_list = PhabricatorCustomField::getObjectFields( $revision, PhabricatorCustomField::ROLE_STORAGE); $custom_field_list ->setViewer($viewer) ->readFieldsFromStorage($revision); $custom_field_map = array(); foreach ($custom_field_list->getFields() as $custom_field) { if (!$custom_field->shouldUseStorage()) { continue; } $custom_field_key = $custom_field->getFieldKey(); $custom_field_value = $custom_field->getValueForStorage(); $custom_field_map[$custom_field_key] = $custom_field_value; } return $custom_field_map; } }
php
Apache-2.0
5720a38cfe95b00ca4be5016dd0d2f3195f4fa04
2026-01-04T15:03:23.651835Z
false
phacility/phabricator
https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/differential/conduit/DifferentialGetCommitPathsConduitAPIMethod.php
src/applications/differential/conduit/DifferentialGetCommitPathsConduitAPIMethod.php
<?php final class DifferentialGetCommitPathsConduitAPIMethod extends DifferentialConduitAPIMethod { public function getAPIMethodName() { return 'differential.getcommitpaths'; } public function getMethodDescription() { return pht( 'Query which paths should be included when committing a '. 'Differential revision.'); } protected function defineParamTypes() { return array( 'revision_id' => 'required int', ); } protected function defineReturnType() { return 'nonempty list<string>'; } protected function defineErrorTypes() { return array( 'ERR_NOT_FOUND' => pht('No such revision exists.'), ); } protected function execute(ConduitAPIRequest $request) { $id = $request->getValue('revision_id'); $revision = id(new DifferentialRevisionQuery()) ->setViewer($request->getUser()) ->withIDs(array($id)) ->executeOne(); if (!$revision) { throw new ConduitException('ERR_NOT_FOUND'); } $paths = array(); $diff = id(new DifferentialDiff())->loadOneWhere( 'revisionID = %d ORDER BY id DESC limit 1', $revision->getID()); $diff->attachChangesets($diff->loadChangesets()); foreach ($diff->getChangesets() as $changeset) { $paths[] = $changeset->getFilename(); } return $paths; } }
php
Apache-2.0
5720a38cfe95b00ca4be5016dd0d2f3195f4fa04
2026-01-04T15:03:23.651835Z
false