Page Menu
Home
Phorge
Search
Configure Global Search
Log In
Files
F2896787
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Award Token
Flag For Later
Advanced/Developer...
View Handle
View Hovercard
Size
54 KB
Referenced Files
None
Subscribers
None
View Options
diff --git a/src/applications/differential/config/PhabricatorDifferentialConfigOptions.php b/src/applications/differential/config/PhabricatorDifferentialConfigOptions.php
index 6e088d32d9..7b9533d41e 100644
--- a/src/applications/differential/config/PhabricatorDifferentialConfigOptions.php
+++ b/src/applications/differential/config/PhabricatorDifferentialConfigOptions.php
@@ -1,250 +1,303 @@
<?php
final class PhabricatorDifferentialConfigOptions
extends PhabricatorApplicationConfigOptions {
public function getName() {
return pht('Differential');
}
public function getDescription() {
return pht('Configure Differential code review.');
}
public function getOptions() {
+ $custom_field_type = 'custom:PhabricatorCustomFieldConfigOptionType';
+
+ $fields = array(
+ new DifferentialTitleField(),
+ new DifferentialSummaryField(),
+ new DifferentialTestPlanField(),
+ new DifferentialAuthorField(),
+ new DifferentialReviewersField(),
+ new DifferentialProjectReviewersField(),
+ new DifferentialReviewedByField(),
+ new DifferentialSubscribersField(),
+ new DifferentialRepositoryField(),
+ new DifferentialLintField(),
+ new DifferentialUnitField(),
+ new DifferentialViewPolicyField(),
+ new DifferentialEditPolicyField(),
+
+ new DifferentialDependsOnField(),
+ new DifferentialDependenciesField(),
+ new DifferentialManiphestTasksField(),
+ new DifferentialCommitsField(),
+
+ new DifferentialJIRAIssuesField(),
+ new DifferentialAsanaRepresentationField(),
+
+ new DifferentialBlameRevisionField(),
+ new DifferentialPathField(),
+ new DifferentialHostField(),
+ new DifferentialRevertPlanField(),
+
+ new DifferentialApplyPatchField(),
+
+ new DifferentialRevisionIDField(),
+ );
+
+ $default_fields = array();
+ foreach ($fields as $field) {
+ $default_fields[$field->getFieldKey()] = array(
+ 'disabled' => $field->shouldDisableByDefault(),
+ );
+ }
+
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.whitespace-matters',
'list<regex>',
array(
'/\.py$/',
'/\.l?hs$/',
))
->setDescription(
pht(
"List of file regexps where whitespace is meaningful and should ".
"not use 'ignore-all' by default")),
$this->newOption(
'differential.field-selector',
'class',
'DifferentialDefaultFieldSelector')
->setBaseClass('DifferentialFieldSelector')
->setDescription(pht('Field selector class')),
$this->newOption('differential.show-host-field', 'bool', false)
->setBoolOptions(
array(
pht('Show "Host" Fields'),
pht('Hide "Host" Fields'),
))
->setSummary(pht('Show or hide the "Host" and "Path" fields.'))
->setDescription(
pht(
'Differential can show "Host" and "Path" fields on revisions, '.
'with information about the machine and working directory where '.
'the change came from. These fields are disabled by default '.
'because they may occasionally have sensitive information, but '.
'they can be useful if you work in an environment with shared '.
'development machines. You can set this option to true to enable '.
'these fields.')),
$this->newOption('differential.show-test-plan-field', 'bool', true)
->setBoolOptions(
array(
pht('Show "Test Plan" Field'),
pht('Hide "Test Plan" Field'),
))
->setSummary(pht('Show or hide the "Test Plan" field.'))
->setDescription(
pht(
'Differential has a required "Test Plan" field by default, which '.
'requires authors to fill out information about how they verified '.
'the correctness of their changes when they send code for review. '.
'If you would prefer not to use this field, you can disable it '.
'here. You can also make it optional (instead of required) by '.
'setting {{differential.require-test-plan-field}}.')),
$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 get hidden by ".
"default in differential."))
->addExample("/config\.h$/\n#/autobuilt/#", pht("Valid Setting")),
$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.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 in '.
'Phabricator), 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('differential.days-fresh', 'int', 1)
->setSummary(
pht(
"For how many business days should a revision be considered ".
"'fresh'?"))
->setDescription(
pht(
"Revisions newer than this number of days are marked as fresh in ".
"Action Required and Revisions Waiting on You views. Only work ".
"days (not weekends and holidays) are included. Set to 0 to ".
"disable this feature.")),
$this->newOption('differential.days-stale', 'int', 3)
->setSummary(
pht("After this many days, a revision will be considered 'stale'."))
->setDescription(
pht(
"Similar to `differential.days-fresh` but marks stale revisions. ".
"If the revision is even older than it is when marked as 'old'.")),
$this->newOption(
'metamta.differential.reply-handler-domain',
'string',
null)
->setDescription(
pht('Inbound email domain for Differential replies.')),
$this->newOption(
'metamta.differential.reply-handler',
'class',
'DifferentialReplyHandler')
->setBaseClass('PhabricatorMailReplyHandler')
->setDescription(pht('Alternate reply handler class.')),
$this->newOption(
'metamta.differential.subject-prefix',
'string',
'[Differential]')
->setDescription(pht('Subject prefix for Differential mail.')),
$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, Phabricator will attach patches 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(
pht(
"To include patches inline in email bodies, set this to a ".
"positive integer. Patches will be inlined if they are at most ".
"that many lines. For instance, a value of 100 means 'inline ".
"patches if they are no longer than 100 lines'. By default, ".
"patches are not inlined.")),
// TODO: Implement 'enum'? Options are 'unified' or 'git'.
$this->newOption(
'metamta.differential.patch-format',
'string',
'unified')
->setDescription(
pht("Format for inlined or attached patches: 'git' or 'unified'.")),
$this->newOption(
'metamta.differential.unified-comment-context',
'bool',
false)
->setBoolOptions(
array(
pht("Show context"),
pht("Do not show context"),
))
->setSummary(pht("Show diff context around inline comments in email."))
->setDescription(
pht(
"Normally, inline comments in emails are shown with a file and ".
"line but without any diff context. Enabling this option adds ".
"diff context.")),
);
}
}
diff --git a/src/applications/differential/customfield/DifferentialAsanaRepresentationField.php b/src/applications/differential/customfield/DifferentialAsanaRepresentationField.php
index 7167b6cd38..c83b9ecd15 100644
--- a/src/applications/differential/customfield/DifferentialAsanaRepresentationField.php
+++ b/src/applications/differential/customfield/DifferentialAsanaRepresentationField.php
@@ -1,64 +1,68 @@
<?php
final class DifferentialAsanaRepresentationField
extends DifferentialCustomField {
public function getFieldKey() {
return 'differential:asana-representation';
}
public function getFieldName() {
return pht('In Asana');
}
+ public function canDisableField() {
+ return false;
+ }
+
public function getFieldDescription() {
return pht('Shows revision representation in Asana.');
}
public function shouldAppearInPropertyView() {
return (bool)PhabricatorEnv::getEnvConfig('asana.workspace-id');
}
public function renderPropertyViewLabel() {
return $this->getFieldName();
}
public function renderPropertyViewValue(array $handles) {
$viewer = $this->getViewer();
$src_phid = $this->getObject()->getPHID();
$edge_type = PhabricatorEdgeConfig::TYPE_PHOB_HAS_ASANATASK;
$query = id(new PhabricatorEdgeQuery())
->withSourcePHIDs(array($src_phid))
->withEdgeTypes(array($edge_type))
->needEdgeData(true);
$edges = $query->execute();
if (!$edges) {
return null;
}
$edge = head($edges[$src_phid][$edge_type]);
if (!empty($edge['data']['gone'])) {
return phutil_tag(
'em',
array(),
pht('Asana Task Deleted'));
}
$ref = id(new DoorkeeperImportEngine())
->setViewer($viewer)
->withPHIDs(array($edge['dst']))
->needLocalOnly(true)
->executeOne();
if (!$ref) {
return null;
}
return id(new DoorkeeperTagView())
->setExternalObject($ref->getExternalObject());
}
}
diff --git a/src/applications/differential/customfield/DifferentialAuditorsField.php b/src/applications/differential/customfield/DifferentialAuditorsField.php
index 6bb32523ed..c756c1e9e9 100644
--- a/src/applications/differential/customfield/DifferentialAuditorsField.php
+++ b/src/applications/differential/customfield/DifferentialAuditorsField.php
@@ -1,53 +1,57 @@
<?php
final class DifferentialAuditorsField
extends DifferentialStoredCustomField {
public function getFieldKey() {
return 'phabricator:auditors';
}
public function getFieldName() {
return pht('Auditors');
}
public function getFieldDescription() {
return pht('Allows commits to trigger audits explicitly.');
}
public function getValueForStorage() {
return json_encode($this->getValue());
}
public function setValueFromStorage($value) {
$this->setValue(phutil_json_decode($value));
return $this;
}
public function shouldAppearInCommitMessage() {
return true;
}
public function shouldAllowEditInCommitMessage() {
return true;
}
+ public function canDisableField() {
+ return false;
+ }
+
public function getRequiredHandlePHIDsForCommitMessage() {
return nonempty($this->getValue(), array());
}
public function parseCommitMessageValue($value) {
return $this->parseObjectList(
$value,
array(
PhabricatorPeoplePHIDTypeUser::TYPECONST,
PhabricatorProjectPHIDTypeProject::TYPECONST,
));
}
public function renderCommitMessageValue(array $handles) {
return $this->renderObjectList($handles);
}
}
diff --git a/src/applications/differential/customfield/DifferentialAuthorField.php b/src/applications/differential/customfield/DifferentialAuthorField.php
index 4496aabcae..6e14c8bbae 100644
--- a/src/applications/differential/customfield/DifferentialAuthorField.php
+++ b/src/applications/differential/customfield/DifferentialAuthorField.php
@@ -1,34 +1,38 @@
<?php
final class DifferentialAuthorField
extends DifferentialCustomField {
public function getFieldKey() {
return 'differential:author';
}
public function getFieldName() {
return pht('Author');
}
public function getFieldDescription() {
return pht('Stores the revision author.');
}
+ public function canDisableField() {
+ return false;
+ }
+
public function shouldAppearInPropertyView() {
return true;
}
public function renderPropertyViewLabel() {
return $this->getFieldName();
}
public function getRequiredHandlePHIDsForPropertyView() {
return array($this->getObject()->getAuthorPHID());
}
public function renderPropertyViewValue(array $handles) {
return $handles[$this->getObject()->getAuthorPHID()]->renderLink();
}
}
diff --git a/src/applications/differential/customfield/DifferentialBlameRevisionField.php b/src/applications/differential/customfield/DifferentialBlameRevisionField.php
index 3c894c0282..c308114a87 100644
--- a/src/applications/differential/customfield/DifferentialBlameRevisionField.php
+++ b/src/applications/differential/customfield/DifferentialBlameRevisionField.php
@@ -1,114 +1,114 @@
<?php
final class DifferentialBlameRevisionField
extends DifferentialStoredCustomField {
public function getFieldKey() {
return 'phabricator:blame-revision';
}
public function getFieldKeyForConduit() {
return 'blameRevision';
}
public function getFieldName() {
return pht('Blame Revision');
}
public function getFieldDescription() {
return pht('Stores a reference to what this fixes.');
}
public function shouldDisableByDefault() {
return true;
}
public function shouldAppearInPropertyView() {
return true;
}
public function renderPropertyViewLabel() {
return $this->getFieldName();
}
public function renderPropertyViewValue(array $handles) {
return $this->getValue();
}
public function shouldAppearInEditView() {
return true;
}
public function shouldAppearInApplicationTransactions() {
return true;
}
public function getOldValueForApplicationTransactions() {
return $this->getValue();
}
public function getNewValueForApplicationTransactions() {
return $this->getValue();
}
public function readValueFromRequest(AphrontRequest $request) {
$this->setValue($request->getStr($this->getFieldKey()));
}
public function renderEditControl(array $handles) {
return id(new AphrontFormTextControl())
->setName($this->getFieldKey())
->setValue($this->getValue())
->setLabel($this->getFieldName());
}
public function getApplicationTransactionTitle(
PhabricatorApplicationTransaction $xaction) {
$author_phid = $xaction->getAuthorPHID();
$old = $xaction->getOldValue();
$new = $xaction->getNewValue();
return pht(
'%s updated the blame revision for this revision.',
$xaction->renderHandleLink($author_phid));
}
public function getApplicationTransactionTitleForFeed(
PhabricatorApplicationTransaction $xaction,
PhabricatorFeedStory $story) {
$object_phid = $xaction->getObjectPHID();
$author_phid = $xaction->getAuthorPHID();
$old = $xaction->getOldValue();
$new = $xaction->getNewValue();
return pht(
'%s updated the blame revision for %s.',
$xaction->renderHandleLink($author_phid),
$xaction->renderHandleLink($object_phid));
}
public function shouldAppearInCommitMessage() {
return true;
}
public function shouldAllowEditInCommitMessage() {
return true;
}
public function shouldOverwriteWhenCommitMessageIsEdited() {
return true;
}
public function getCommitMessageLabels() {
return array(
'Blame Revision',
'Blame Rev',
);
}
- public function renderCommitMessageValue() {
+ public function renderCommitMessageValue(array $handles) {
return $this->getValue();
}
}
diff --git a/src/applications/differential/customfield/DifferentialCommitsField.php b/src/applications/differential/customfield/DifferentialCommitsField.php
index d030dcedb1..377bac50d1 100644
--- a/src/applications/differential/customfield/DifferentialCommitsField.php
+++ b/src/applications/differential/customfield/DifferentialCommitsField.php
@@ -1,34 +1,38 @@
<?php
final class DifferentialCommitsField
extends DifferentialCustomField {
public function getFieldKey() {
return 'differential:commits';
}
public function getFieldName() {
return pht('Commits');
}
+ public function canDisableField() {
+ return false;
+ }
+
public function getFieldDescription() {
return pht('Shows associated commits.');
}
public function shouldAppearInPropertyView() {
return true;
}
public function renderPropertyViewLabel() {
return $this->getFieldName();
}
public function getRequiredHandlePHIDsForPropertyView() {
return $this->getObject()->getCommitPHIDs();
}
public function renderPropertyViewValue(array $handles) {
return $this->renderHandleList($handles);
}
}
diff --git a/src/applications/differential/customfield/DifferentialDependenciesField.php b/src/applications/differential/customfield/DifferentialDependenciesField.php
index 575110a885..5b50a4e624 100644
--- a/src/applications/differential/customfield/DifferentialDependenciesField.php
+++ b/src/applications/differential/customfield/DifferentialDependenciesField.php
@@ -1,36 +1,40 @@
<?php
final class DifferentialDependenciesField
extends DifferentialCustomField {
public function getFieldKey() {
return 'differential:dependencies';
}
public function getFieldName() {
return pht('Dependencies');
}
+ public function canDisableField() {
+ return false;
+ }
+
public function getFieldDescription() {
return pht('Lists revisions this one is depended on by.');
}
public function shouldAppearInPropertyView() {
return true;
}
public function renderPropertyViewLabel() {
return $this->getFieldName();
}
public function getRequiredHandlePHIDsForPropertyView() {
return PhabricatorEdgeQuery::loadDestinationPHIDs(
$this->getObject()->getPHID(),
PhabricatorEdgeConfig::TYPE_DREV_DEPENDED_ON_BY_DREV);
}
public function renderPropertyViewValue(array $handles) {
return $this->renderHandleList($handles);
}
}
diff --git a/src/applications/differential/customfield/DifferentialDependsOnField.php b/src/applications/differential/customfield/DifferentialDependsOnField.php
index a6b2c998b5..34ae563e16 100644
--- a/src/applications/differential/customfield/DifferentialDependsOnField.php
+++ b/src/applications/differential/customfield/DifferentialDependsOnField.php
@@ -1,44 +1,48 @@
<?php
final class DifferentialDependsOnField
extends DifferentialCustomField {
public function getFieldKey() {
return 'differential:depends-on';
}
public function getFieldName() {
return pht('Depends On');
}
+ public function canDisableField() {
+ return false;
+ }
+
public function getFieldDescription() {
return pht('Lists revisions this one depends on.');
}
public function shouldAppearInPropertyView() {
return true;
}
public function renderPropertyViewLabel() {
return $this->getFieldName();
}
public function getRequiredHandlePHIDsForPropertyView() {
return PhabricatorEdgeQuery::loadDestinationPHIDs(
$this->getObject()->getPHID(),
PhabricatorEdgeConfig::TYPE_DREV_DEPENDS_ON_DREV);
}
public function renderPropertyViewValue(array $handles) {
return $this->renderHandleList($handles);
}
public function getProTips() {
return array(
pht(
'Create a dependendency between revisions by writing '.
'"Depends on D123" in your summary.'),
);
}
}
diff --git a/src/applications/differential/customfield/DifferentialJIRAIssuesField.php b/src/applications/differential/customfield/DifferentialJIRAIssuesField.php
index cdae1b4785..bcd4cbff81 100644
--- a/src/applications/differential/customfield/DifferentialJIRAIssuesField.php
+++ b/src/applications/differential/customfield/DifferentialJIRAIssuesField.php
@@ -1,267 +1,271 @@
<?php
final class DifferentialJIRAIssuesField
extends DifferentialStoredCustomField {
private $error;
public function getFieldKey() {
return 'phabricator:jira-issues';
}
public function getFieldKeyForConduit() {
return 'jira.issues';
}
+ public function canDisableField() {
+ return false;
+ }
+
public function getValueForStorage() {
return json_encode($this->getValue());
}
public function setValueFromStorage($value) {
$this->setValue(phutil_json_decode($value));
return $this;
}
public function getFieldName() {
return pht('JIRA Issues');
}
public function getFieldDescription() {
return pht('Lists associated JIRA issues.');
}
public function shouldAppearInPropertyView() {
return true;
}
public function renderPropertyViewLabel() {
return $this->getFieldName();
}
public function renderPropertyViewValue(array $handles) {
$xobjs = $this->loadDoorkeeperExternalObjects($this->getValue());
if (!$xobjs) {
return null;
}
$links = array();
foreach ($xobjs as $xobj) {
$links[] = id(new DoorkeeperTagView())
->setExternalObject($xobj);
}
return phutil_implode_html(phutil_tag('br'), $links);
}
private function buildDoorkeeperRefs($value) {
$provider = PhabricatorAuthProviderOAuth1JIRA::getJIRAProvider();
$refs = array();
if ($value) {
foreach ($value as $jira_key) {
$refs[] = id(new DoorkeeperObjectRef())
->setApplicationType(DoorkeeperBridgeJIRA::APPTYPE_JIRA)
->setApplicationDomain($provider->getProviderDomain())
->setObjectType(DoorkeeperBridgeJIRA::OBJTYPE_ISSUE)
->setObjectID($jira_key);
}
}
return $refs;
}
private function loadDoorkeeperExternalObjects($value) {
$refs = $this->buildDoorkeeperRefs($value);
if (!$refs) {
return array();
}
$xobjs = id(new DoorkeeperExternalObjectQuery())
->setViewer($this->getViewer())
->withObjectKeys(mpull($refs, 'getObjectKey'))
->execute();
return $xobjs;
}
public function shouldAppearInEditView() {
return PhabricatorAuthProviderOAuth1JIRA::getJIRAProvider();
}
public function shouldAppearInApplicationTransactions() {
return PhabricatorAuthProviderOAuth1JIRA::getJIRAProvider();
}
public function readValueFromRequest(AphrontRequest $request) {
$this->setValue($request->getStrList($this->getFieldKey()));
return $this;
}
public function renderEditControl(array $handles) {
return id(new AphrontFormTextControl())
->setLabel(pht('JIRA Issues'))
->setCaption(
pht('Example: %s', phutil_tag('tt', array(), 'JIS-3, JIS-9')))
->setName($this->getFieldKey())
->setValue(implode(', ', nonempty($this->getValue(), array())))
->setError($this->error);
}
public function getOldValueForApplicationTransactions() {
return nonempty($this->getValue(), array());
}
public function getNewValueForApplicationTransactions() {
return nonempty($this->getValue(), array());
}
public function validateApplicationTransactions(
PhabricatorApplicationTransactionEditor $editor,
$type,
array $xactions) {
$this->error = null;
$errors = parent::validateApplicationTransactions(
$editor,
$type,
$xactions);
$transaction = null;
foreach ($xactions as $xaction) {
$value = $xaction->getNewValue();
$refs = id(new DoorkeeperImportEngine())
->setViewer($this->getViewer())
->setRefs($this->buildDoorkeeperRefs($value))
->execute();
$bad = array();
foreach ($refs as $ref) {
if (!$ref->getIsVisible()) {
$bad[] = $ref->getObjectID();
}
}
if ($bad) {
$bad = implode(', ', $bad);
$this->error = pht('Invalid');
$error = new PhabricatorApplicationTransactionValidationError(
$type,
pht('Invalid'),
pht(
"Some JIRA issues could not be loaded. They may not exist, or ".
"you may not have permission to view them: %s",
$bad),
$xaction);
$errors[] = $error;
}
}
return $errors;
}
public function getApplicationTransactionTitle(
PhabricatorApplicationTransaction $xaction) {
$old = $xaction->getOldValue();
if (!is_array($old)) {
$old = array();
}
$new = $xaction->getNewValue();
if (!is_array($new)) {
$new = array();
}
$add = array_diff($new, $old);
$rem = array_diff($old, $new);
$author_phid = $xaction->getAuthorPHID();
if ($add && $rem) {
return pht(
'%s updated JIRA issue(s): added %d %s; removed %d %s.',
$xaction->renderHandleLink($author_phid),
new PhutilNumber(count($add)),
implode(', ', $add),
new PhutilNumber(count($rem)),
implode(', ', $rem));
} else if ($add) {
return pht(
'%s added %d JIRA issue(s): %s.',
$xaction->renderHandleLink($author_phid),
new PhutilNumber(count($add)),
implode(', ', $add));
} else if ($rem) {
return pht(
'%s removed %d JIRA issue(s): %s.',
$xaction->renderHandleLink($author_phid),
new PhutilNumber(count($rem)),
implode(', ', $rem));
}
return parent::getApplicationTransactionTitle($xaction);
}
public function applyApplicationTransactionExternalEffects(
PhabricatorApplicationTransaction $xaction) {
// Update the CustomField storage.
parent::applyApplicationTransactionExternalEffects($xaction);
// Now, synchronize the Doorkeeper edges.
$revision = $this->getObject();
$revision_phid = $revision->getPHID();
$edge_type = PhabricatorEdgeConfig::TYPE_PHOB_HAS_JIRAISSUE;
$xobjs = $this->loadDoorkeeperExternalObjects($xaction->getNewValue());
$edge_dsts = mpull($xobjs, 'getPHID');
$edges = PhabricatorEdgeQuery::loadDestinationPHIDs(
$revision_phid,
$edge_type);
$editor = id(new PhabricatorEdgeEditor())
->setActor($this->getViewer());
foreach (array_diff($edges, $edge_dsts) as $rem_edge) {
$editor->removeEdge($revision_phid, $edge_type, $rem_edge);
}
foreach (array_diff($edge_dsts, $edges) as $add_edge) {
$editor->addEdge($revision_phid, $edge_type, $add_edge);
}
$editor->save();
}
public function shouldAppearInCommitMessage() {
return true;
}
public function shouldAppearInCommitMessageTemplate() {
return true;
}
public function getCommitMessageLabels() {
return array(
'JIRA',
'JIRA Issues',
'JIRA Issue',
);
}
public function parseValueFromCommitMessage($value) {
return preg_split('/[\s,]+/', $value, $limit = -1, PREG_SPLIT_NO_EMPTY);
}
public function renderCommitMessageValue(array $handles) {
$value = $this->getValue();
if (!$value) {
return null;
}
return implode(', ', $value);
}
}
diff --git a/src/applications/differential/customfield/DifferentialManiphestTasksField.php b/src/applications/differential/customfield/DifferentialManiphestTasksField.php
index 2c2b3e9e60..e01defb619 100644
--- a/src/applications/differential/customfield/DifferentialManiphestTasksField.php
+++ b/src/applications/differential/customfield/DifferentialManiphestTasksField.php
@@ -1,83 +1,87 @@
<?php
final class DifferentialManiphestTasksField
extends DifferentialCustomField {
public function getFieldKey() {
return 'differential:maniphest-tasks';
}
public function getFieldKeyForConduit() {
return 'maniphestTaskPHIDs';
}
+ public function canDisableField() {
+ return false;
+ }
+
public function getFieldName() {
return pht('Maniphest Tasks');
}
public function getFieldDescription() {
return pht('Lists associated tasks.');
}
public function shouldAppearInPropertyView() {
return true;
}
public function renderPropertyViewLabel() {
return $this->getFieldName();
}
public function getRequiredHandlePHIDsForPropertyView() {
if (!$this->getObject()->getPHID()) {
return array();
}
return PhabricatorEdgeQuery::loadDestinationPHIDs(
$this->getObject()->getPHID(),
PhabricatorEdgeConfig::TYPE_DREV_HAS_RELATED_TASK);
}
public function renderPropertyViewValue(array $handles) {
return $this->renderHandleList($handles);
}
public function shouldAppearInCommitMessage() {
return true;
}
public function shouldAllowEditInCommitMessage() {
return true;
}
public function getCommitMessageLabels() {
return array(
'Maniphest Task',
'Maniphest Tasks',
);
}
public function parseValueFromCommitMessage($value) {
return $this->parseObjectList(
$value,
array(
ManiphestPHIDTypeTask::TYPECONST,
));
}
public function getRequiredHandlePHIDsForCommitMessage() {
return $this->getRequiredHandlePHIDsForPropertyView();
}
public function renderCommitMessageValue(array $handles) {
return $this->renderObjectList($handles);
}
public function getProTips() {
return array(
pht(
'Write "Fixes T123" in your summary to automatically close the '.
'corresponding task when this change lands.'),
);
}
}
diff --git a/src/applications/differential/customfield/DifferentialProjectReviewersField.php b/src/applications/differential/customfield/DifferentialProjectReviewersField.php
index deacef4dab..aff5644a52 100644
--- a/src/applications/differential/customfield/DifferentialProjectReviewersField.php
+++ b/src/applications/differential/customfield/DifferentialProjectReviewersField.php
@@ -1,64 +1,68 @@
<?php
final class DifferentialProjectReviewersField
extends DifferentialCustomField {
public function getFieldKey() {
return 'differential:project-reviewers';
}
public function getFieldName() {
return pht('Project Reviewers');
}
public function getFieldDescription() {
return pht('Display project reviewers.');
}
public function shouldAppearInPropertyView() {
return true;
}
+ public function canDisableField() {
+ return false;
+ }
+
public function renderPropertyViewLabel() {
return $this->getFieldName();
}
public function getRequiredHandlePHIDsForPropertyView() {
return mpull($this->getProjectReviewers(), 'getReviewerPHID');
}
public function renderPropertyViewValue(array $handles) {
$reviewers = $this->getProjectReviewers();
if (!$reviewers) {
return null;
}
$view = id(new DifferentialReviewersView())
->setUser($this->getViewer())
->setReviewers($reviewers)
->setHandles($handles);
// TODO: Active diff stuff.
return $view;
}
private function getProjectReviewers() {
$reviewers = array();
foreach ($this->getObject()->getReviewerStatus() as $reviewer) {
if (!$reviewer->isUser()) {
$reviewers[] = $reviewer;
}
}
return $reviewers;
}
public function getProTips() {
return array(
pht(
'You can add a project as a subscriber or reviewer by writing '.
'"#projectname" in the appropriate field.'),
);
}
}
diff --git a/src/applications/differential/customfield/DifferentialReviewedByField.php b/src/applications/differential/customfield/DifferentialReviewedByField.php
index a798e0969e..9c905712d8 100644
--- a/src/applications/differential/customfield/DifferentialReviewedByField.php
+++ b/src/applications/differential/customfield/DifferentialReviewedByField.php
@@ -1,58 +1,62 @@
<?php
final class DifferentialReviewedByField
extends DifferentialCoreCustomField {
public function getFieldKey() {
return 'differential:reviewed-by';
}
public function getFieldKeyForConduit() {
return 'reviewedByPHIDs';
}
public function getFieldName() {
return pht('Reviewed By');
}
public function getFieldDescription() {
return pht('Records accepting reviewers in the durable message.');
}
public function shouldAppearInApplicationTransactions() {
return false;
}
public function shouldAppearInEditView() {
return false;
}
+ public function canDisableField() {
+ return true;
+ }
+
protected function readValueFromRevision(
DifferentialRevision $revision) {
$phids = array();
foreach ($revision->getReviewerStatus() as $reviewer) {
switch ($reviewer->getStatus()) {
case DifferentialReviewerStatus::STATUS_ACCEPTED:
case DifferentialReviewerStatus::STATUS_ACCEPTED_OLDER:
$phids[] = $reviewer->getReviewerPHID();
break;
}
}
return $phids;
}
public function shouldAppearInCommitMessage() {
return true;
}
public function getRequiredHandlePHIDsForCommitMessage() {
return $this->getValue();
}
public function renderCommitMessageValue(array $handles) {
return $this->renderObjectList($handles);
}
}
diff --git a/src/applications/differential/customfield/DifferentialRevisionIDField.php b/src/applications/differential/customfield/DifferentialRevisionIDField.php
index f4e8110b98..f835dcd769 100644
--- a/src/applications/differential/customfield/DifferentialRevisionIDField.php
+++ b/src/applications/differential/customfield/DifferentialRevisionIDField.php
@@ -1,41 +1,45 @@
<?php
final class DifferentialRevisionIDField
extends DifferentialCustomField {
public function getFieldKey() {
+ return 'differential:revision-id';
+ }
+
+ public function getFieldKeyForConduit() {
return 'revisionID';
}
public function getFieldName() {
return pht('Differential Revision');
}
public function getFieldDescription() {
return pht(
'Ties commits to revisions and provides a permananent link between '.
'them.');
}
public function canDisableField() {
return false;
}
public function shouldAppearInCommitMessage() {
return true;
}
public function shouldAllowEditInCommitMessage() {
return false;
}
public function parseValueFromCommitMessage($value) {
return DifferentialRevisionIDFieldSpecification::parseRevisionIDFromURI(
$value);
}
public function renderCommitMessageValue(array $handles) {
return PhabricatorEnv::getProductionURI('/D'.$this->getObject()->getID());
}
}
diff --git a/src/applications/differential/storage/DifferentialRevision.php b/src/applications/differential/storage/DifferentialRevision.php
index 10b4105c3f..df1d99c418 100644
--- a/src/applications/differential/storage/DifferentialRevision.php
+++ b/src/applications/differential/storage/DifferentialRevision.php
@@ -1,536 +1,500 @@
<?php
final class DifferentialRevision extends DifferentialDAO
implements
PhabricatorTokenReceiverInterface,
PhabricatorPolicyInterface,
PhabricatorFlaggableInterface,
PhrequentTrackableInterface,
HarbormasterBuildableInterface,
PhabricatorSubscribableInterface,
PhabricatorCustomFieldInterface {
protected $title = '';
protected $originalTitle;
protected $status;
protected $summary = '';
protected $testPlan = '';
protected $authorPHID;
protected $lastReviewerPHID;
protected $lineCount = 0;
protected $attached = array();
protected $mailKey;
protected $branchName;
protected $arcanistProjectPHID;
protected $repositoryPHID;
protected $viewPolicy = PhabricatorPolicies::POLICY_USER;
protected $editPolicy = PhabricatorPolicies::POLICY_USER;
private $relationships = self::ATTACHABLE;
private $commits = self::ATTACHABLE;
private $activeDiff = self::ATTACHABLE;
private $diffIDs = self::ATTACHABLE;
private $hashes = self::ATTACHABLE;
private $repository = self::ATTACHABLE;
private $reviewerStatus = self::ATTACHABLE;
private $customFields = self::ATTACHABLE;
private $drafts = array();
private $flags = array();
const TABLE_COMMIT = 'differential_commit';
const RELATION_REVIEWER = 'revw';
const RELATION_SUBSCRIBED = 'subd';
public static function initializeNewRevision(PhabricatorUser $actor) {
$app = id(new PhabricatorApplicationQuery())
->setViewer($actor)
->withClasses(array('PhabricatorApplicationDifferential'))
->executeOne();
$view_policy = $app->getPolicy(
DifferentialCapabilityDefaultView::CAPABILITY);
return id(new DifferentialRevision())
->setViewPolicy($view_policy)
->setAuthorPHID($actor->getPHID())
->attachRelationships(array())
->setStatus(ArcanistDifferentialRevisionStatus::NEEDS_REVIEW);
}
public function getConfiguration() {
return array(
self::CONFIG_AUX_PHID => true,
self::CONFIG_SERIALIZATION => array(
'attached' => self::SERIALIZATION_JSON,
'unsubscribed' => self::SERIALIZATION_JSON,
),
) + parent::getConfiguration();
}
public function getMonogram() {
$id = $this->getID();
return "D{$id}";
}
public function setTitle($title) {
$this->title = $title;
if (!$this->getID()) {
$this->originalTitle = $title;
}
return $this;
}
public function loadIDsByCommitPHIDs($phids) {
if (!$phids) {
return array();
}
$revision_ids = queryfx_all(
$this->establishConnection('r'),
'SELECT * FROM %T WHERE commitPHID IN (%Ls)',
self::TABLE_COMMIT,
$phids);
return ipull($revision_ids, 'revisionID', 'commitPHID');
}
public function loadCommitPHIDs() {
if (!$this->getID()) {
return ($this->commits = array());
}
$commits = queryfx_all(
$this->establishConnection('r'),
'SELECT commitPHID FROM %T WHERE revisionID = %d',
self::TABLE_COMMIT,
$this->getID());
$commits = ipull($commits, 'commitPHID');
return ($this->commits = $commits);
}
public function getCommitPHIDs() {
return $this->assertAttached($this->commits);
}
public function getActiveDiff() {
// TODO: Because it's currently technically possible to create a revision
// without an associated diff, we allow an attached-but-null active diff.
// It would be good to get rid of this once we make diff-attaching
// transactional.
return $this->assertAttached($this->activeDiff);
}
public function attachActiveDiff($diff) {
$this->activeDiff = $diff;
return $this;
}
public function getDiffIDs() {
return $this->assertAttached($this->diffIDs);
}
public function attachDiffIDs(array $ids) {
rsort($ids);
$this->diffIDs = array_values($ids);
return $this;
}
public function attachCommitPHIDs(array $phids) {
$this->commits = array_values($phids);
return $this;
}
public function getAttachedPHIDs($type) {
return array_keys(idx($this->attached, $type, array()));
}
public function setAttachedPHIDs($type, array $phids) {
$this->attached[$type] = array_fill_keys($phids, array());
return $this;
}
public function generatePHID() {
return PhabricatorPHID::generateNewPHID(
DifferentialPHIDTypeRevision::TYPECONST);
}
public function loadComments() {
if (!$this->getID()) {
return array();
}
return id(new DifferentialCommentQuery())
->withRevisionPHIDs(array($this->getPHID()))
->execute();
}
public function loadActiveDiff() {
return id(new DifferentialDiff())->loadOneWhere(
'revisionID = %d ORDER BY id DESC LIMIT 1',
$this->getID());
}
public function save() {
if (!$this->getMailKey()) {
$this->mailKey = Filesystem::readRandomCharacters(40);
}
return parent::save();
}
public function delete() {
$this->openTransaction();
$diffs = id(new DifferentialDiffQuery())
->setViewer(PhabricatorUser::getOmnipotentUser())
->withRevisionIDs(array($this->getID()))
->execute();
foreach ($diffs as $diff) {
$diff->delete();
}
$conn_w = $this->establishConnection('w');
queryfx(
$conn_w,
'DELETE FROM %T WHERE revisionID = %d',
self::TABLE_COMMIT,
$this->getID());
$comments = id(new DifferentialCommentQuery())
->withRevisionPHIDs(array($this->getPHID()))
->execute();
foreach ($comments as $comment) {
$comment->delete();
}
$inlines = id(new DifferentialInlineCommentQuery())
->withRevisionIDs(array($this->getID()))
->execute();
foreach ($inlines as $inline) {
$inline->delete();
}
// we have to do paths a little differentally as they do not have
// an id or phid column for delete() to act on
$dummy_path = new DifferentialAffectedPath();
queryfx(
$conn_w,
'DELETE FROM %T WHERE revisionID = %d',
$dummy_path->getTableName(),
$this->getID());
$result = parent::delete();
$this->saveTransaction();
return $result;
}
public function loadRelationships() {
if (!$this->getID()) {
$this->relationships = array();
return;
}
$data = array();
$subscriber_phids = PhabricatorEdgeQuery::loadDestinationPHIDs(
$this->getPHID(),
PhabricatorEdgeConfig::TYPE_OBJECT_HAS_SUBSCRIBER);
$subscriber_phids = array_reverse($subscriber_phids);
foreach ($subscriber_phids as $phid) {
$data[] = array(
'relation' => self::RELATION_SUBSCRIBED,
'objectPHID' => $phid,
'reasonPHID' => null,
);
}
$reviewer_phids = PhabricatorEdgeQuery::loadDestinationPHIDs(
$this->getPHID(),
PhabricatorEdgeConfig::TYPE_DREV_HAS_REVIEWER);
$reviewer_phids = array_reverse($reviewer_phids);
foreach ($reviewer_phids as $phid) {
$data[] = array(
'relation' => self::RELATION_REVIEWER,
'objectPHID' => $phid,
'reasonPHID' => null,
);
}
return $this->attachRelationships($data);
}
public function attachRelationships(array $relationships) {
$this->relationships = igroup($relationships, 'relation');
return $this;
}
public function getReviewers() {
return $this->getRelatedPHIDs(self::RELATION_REVIEWER);
}
public function getCCPHIDs() {
return $this->getRelatedPHIDs(self::RELATION_SUBSCRIBED);
}
private function getRelatedPHIDs($relation) {
$this->assertAttached($this->relationships);
return ipull($this->getRawRelations($relation), 'objectPHID');
}
public function getRawRelations($relation) {
return idx($this->relationships, $relation, array());
}
public function getPrimaryReviewer() {
$reviewers = $this->getReviewers();
$last = $this->lastReviewerPHID;
if (!$last || !in_array($last, $reviewers)) {
return head($this->getReviewers());
}
return $last;
}
public function loadReviewedBy() {
$reviewer = null;
if ($this->status == ArcanistDifferentialRevisionStatus::ACCEPTED ||
$this->status == ArcanistDifferentialRevisionStatus::CLOSED) {
$comments = $this->loadComments();
foreach ($comments as $comment) {
$action = $comment->getAction();
if ($action == DifferentialAction::ACTION_ACCEPT) {
$reviewer = $comment->getAuthorPHID();
} else if ($action == DifferentialAction::ACTION_REJECT ||
$action == DifferentialAction::ACTION_ABANDON ||
$action == DifferentialAction::ACTION_RETHINK) {
$reviewer = null;
}
}
}
return $reviewer;
}
public function getHashes() {
return $this->assertAttached($this->hashes);
}
public function attachHashes(array $hashes) {
$this->hashes = $hashes;
return $this;
}
public function getCapabilities() {
return array(
PhabricatorPolicyCapability::CAN_VIEW,
PhabricatorPolicyCapability::CAN_EDIT,
);
}
public function getPolicy($capability) {
switch ($capability) {
case PhabricatorPolicyCapability::CAN_VIEW:
return $this->getViewPolicy();
case PhabricatorPolicyCapability::CAN_EDIT:
return $this->getEditPolicy();
}
}
public function hasAutomaticCapability($capability, PhabricatorUser $user) {
// A revision's author (which effectively means "owner" after we added
// commandeering) can always view and edit it.
$author_phid = $this->getAuthorPHID();
if ($author_phid) {
if ($user->getPHID() == $author_phid) {
return true;
}
}
return false;
}
public function describeAutomaticCapability($capability) {
$description = array(
pht('The owner of a revision can always view and edit it.'),
);
switch ($capability) {
case PhabricatorPolicyCapability::CAN_VIEW:
$description[] = pht(
"A revision's reviewers can always view it.");
$description[] = pht(
'If a revision belongs to a repository, other users must be able '.
'to view the repository in order to view the revision.');
break;
}
return $description;
}
public function getUsersToNotifyOfTokenGiven() {
return array(
$this->getAuthorPHID(),
);
}
public function getReviewerStatus() {
return $this->assertAttached($this->reviewerStatus);
}
public function attachReviewerStatus(array $reviewers) {
assert_instances_of($reviewers, 'DifferentialReviewer');
$this->reviewerStatus = $reviewers;
return $this;
}
public function getRepository() {
return $this->assertAttached($this->repository);
}
public function attachRepository(PhabricatorRepository $repository = null) {
$this->repository = $repository;
return $this;
}
public function isClosed() {
return DifferentialRevisionStatus::isClosedStatus($this->getStatus());
}
public function getFlag(PhabricatorUser $viewer) {
return $this->assertAttachedKey($this->flags, $viewer->getPHID());
}
public function attachFlag(
PhabricatorUser $viewer,
PhabricatorFlag $flag = null) {
$this->flags[$viewer->getPHID()] = $flag;
return $this;
}
public function getDrafts(PhabricatorUser $viewer) {
return $this->assertAttachedKey($this->drafts, $viewer->getPHID());
}
public function attachDrafts(PhabricatorUser $viewer, array $drafts) {
$this->drafts[$viewer->getPHID()] = $drafts;
return $this;
}
/* -( HarbormasterBuildableInterface )------------------------------------- */
public function getHarbormasterBuildablePHID() {
return $this->loadActiveDiff()->getPHID();
}
public function getHarbormasterContainerPHID() {
return $this->getPHID();
}
/* -( PhabricatorSubscribableInterface )----------------------------------- */
public function isAutomaticallySubscribed($phid) {
if ($phid == $this->getAuthorPHID()) {
return true;
}
// TODO: This only happens when adding or removing CCs, and is safe from a
// policy perspective, but the subscription pathway should have some
// opportunity to load this data properly. For now, this is the only case
// where implicit subscription is not an intrinsic property of the object.
if ($this->reviewerStatus == self::ATTACHABLE) {
$reviewers = id(new DifferentialRevisionQuery())
->setViewer(PhabricatorUser::getOmnipotentUser())
->withPHIDs(array($this->getPHID()))
->needReviewerStatus(true)
->executeOne()
->getReviewerStatus();
} else {
$reviewers = $this->getReviewerStatus();
}
foreach ($reviewers as $reviewer) {
if ($reviewer->getReviewerPHID() == $phid) {
return true;
}
}
return false;
}
public function shouldShowSubscribersProperty() {
return true;
}
public function shouldAllowSubscription($phid) {
return true;
}
/* -( PhabricatorCustomFieldInterface )------------------------------------ */
public function getCustomFieldSpecificationForRole($role) {
- $fields = array(
- new DifferentialAuthorField(),
-
- new DifferentialTitleField(),
- new DifferentialSummaryField(),
- new DifferentialTestPlanField(),
- new DifferentialReviewersField(),
- new DifferentialProjectReviewersField(),
- new DifferentialSubscribersField(),
- new DifferentialRepositoryField(),
- new DifferentialViewPolicyField(),
- new DifferentialEditPolicyField(),
-
- new DifferentialDependsOnField(),
- new DifferentialDependenciesField(),
- new DifferentialManiphestTasksField(),
- new DifferentialCommitsField(),
-
- new DifferentialJIRAIssuesField(),
- new DifferentialAsanaRepresentationField(),
-
- new DifferentialBlameRevisionField(),
- new DifferentialPathField(),
- new DifferentialHostField(),
- new DifferentialRevertPlanField(),
-
- new DifferentialApplyPatchField(),
- );
-
- $result = array();
- foreach ($fields as $field) {
- $result[$field->getFieldKey()] = array(
- 'disabled' => $field->shouldDisableByDefault(),
- );
- }
-
- return $result;
+ return PhabricatorEnv::getEnvConfig('differential.fields');
}
public function getCustomFieldBaseClass() {
return 'DifferentialCustomField';
}
public function getCustomFields() {
return $this->assertAttached($this->customFields);
}
public function attachCustomFields(PhabricatorCustomFieldAttachment $fields) {
$this->customFields = $fields;
return $this;
}
}
File Metadata
Details
Attached
Mime Type
text/x-diff
Expires
Jan 19 2025, 23:34 (6 w, 6 d ago)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
1129956
Default Alt Text
(54 KB)
Attached To
Mode
rP Phorge
Attached
Detach File
Event Timeline
Log In to Comment