mirror of
https://we.phorge.it/source/phorge.git
synced 2024-11-19 05:12:41 +01:00
Merge branch 'master' of github.com:facebook/phabricator
This commit is contained in:
commit
6fb24ba4a4
10 changed files with 133 additions and 284 deletions
|
@ -88,6 +88,7 @@ phutil_register_library_map(array(
|
|||
'ConduitAPI_differential_parsecommitmessage_Method' => 'applications/conduit/method/differential/parsecommitmessage',
|
||||
'ConduitAPI_differential_setdiffproperty_Method' => 'applications/conduit/method/differential/setdiffproperty',
|
||||
'ConduitAPI_differential_updaterevision_Method' => 'applications/conduit/method/differential/updaterevision',
|
||||
'ConduitAPI_differential_updatetaskrevisionassoc_Method' => 'applications/conduit/method/differential/updatetaskrevisionassoc',
|
||||
'ConduitAPI_diffusion_getcommits_Method' => 'applications/conduit/method/diffusion/getcommits',
|
||||
'ConduitAPI_file_upload_Method' => 'applications/conduit/method/file/upload',
|
||||
'ConduitAPI_path_getowners_Method' => 'applications/conduit/method/path/getowners',
|
||||
|
@ -540,6 +541,7 @@ phutil_register_library_map(array(
|
|||
'ConduitAPI_differential_parsecommitmessage_Method' => 'ConduitAPIMethod',
|
||||
'ConduitAPI_differential_setdiffproperty_Method' => 'ConduitAPIMethod',
|
||||
'ConduitAPI_differential_updaterevision_Method' => 'ConduitAPIMethod',
|
||||
'ConduitAPI_differential_updatetaskrevisionassoc_Method' => 'ConduitAPIMethod',
|
||||
'ConduitAPI_diffusion_getcommits_Method' => 'ConduitAPIMethod',
|
||||
'ConduitAPI_file_upload_Method' => 'ConduitAPIMethod',
|
||||
'ConduitAPI_path_getowners_Method' => 'ConduitAPIMethod',
|
||||
|
|
|
@ -83,7 +83,7 @@ class PhabricatorConduitConsoleController
|
|||
id(new AphrontFormTextControl())
|
||||
->setLabel($param)
|
||||
->setName("params[{$param}]")
|
||||
->setCaption($desc));
|
||||
->setCaption(phutil_escape_html($desc)));
|
||||
}
|
||||
|
||||
$form
|
||||
|
|
|
@ -34,7 +34,7 @@ class ConduitAPI_differential_find_Method extends ConduitAPIMethod {
|
|||
|
||||
return array(
|
||||
'query' => 'required enum<'.$types.'>',
|
||||
'guids' => 'required nonempty list<phid>',
|
||||
'guids' => 'required nonempty list<guids>',
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -49,14 +49,18 @@ class ConduitAPI_differential_find_Method extends ConduitAPIMethod {
|
|||
|
||||
protected function execute(ConduitAPIRequest $request) {
|
||||
$query = $request->getValue('query');
|
||||
$phids = $request->getValue('guids');
|
||||
$guids = $request->getValue('guids');
|
||||
|
||||
$results = array();
|
||||
if (!$guids) {
|
||||
return $results;
|
||||
}
|
||||
|
||||
$revisions = id(new DifferentialRevisionListData(
|
||||
$query,
|
||||
(array)$phids))
|
||||
(array)$guids))
|
||||
->loadRevisions();
|
||||
|
||||
$results = array();
|
||||
foreach ($revisions as $revision) {
|
||||
$diff = $revision->loadActiveDiff();
|
||||
if (!$diff) {
|
||||
|
@ -64,6 +68,7 @@ class ConduitAPI_differential_find_Method extends ConduitAPIMethod {
|
|||
}
|
||||
$results[] = array(
|
||||
'id' => $revision->getID(),
|
||||
'phid' => $revision->getPHID(),
|
||||
'name' => $revision->getTitle(),
|
||||
'statusName' => DifferentialRevisionStatus::getNameForRevisionStatus(
|
||||
$revision->getStatus()),
|
||||
|
|
|
@ -0,0 +1,71 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
* Copyright 2011 Facebook, Inc.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
class ConduitAPI_differential_updatetaskrevisionassoc_Method
|
||||
extends ConduitAPIMethod {
|
||||
public function getMethodDescription() {
|
||||
return "Given a task together with its original and new associated ".
|
||||
"revisions, update the revisions for their attached_tasks.";
|
||||
}
|
||||
|
||||
public function defineParamTypes() {
|
||||
return array(
|
||||
'task_phid' => 'required nonempty string',
|
||||
'orig_rev_phids' => 'required list<string>',
|
||||
'new_rev_phids' => 'required list<string>',
|
||||
);
|
||||
}
|
||||
|
||||
public function defineReturnType() {
|
||||
return 'void';
|
||||
}
|
||||
|
||||
public function defineErrorTypes() {
|
||||
return array(
|
||||
'ERR_NO_TASKATTACHER_DEFINED' => 'No task attacher defined.',
|
||||
);
|
||||
}
|
||||
|
||||
protected function execute(ConduitAPIRequest $request) {
|
||||
$task_phid = $request->getValue('task_phid');
|
||||
$orig_rev_phids = $request->getValue('orig_rev_phids');
|
||||
if (empty($orig_rev_phids)) {
|
||||
$orig_rev_phids = array();
|
||||
}
|
||||
|
||||
$new_rev_phids = $request->getValue('new_rev_phids');
|
||||
if (empty($new_rev_phids)) {
|
||||
$new_rev_phids = array();
|
||||
}
|
||||
|
||||
$task_class = PhabricatorEnv::getEnvConfig(
|
||||
'differential.attach-task-class');
|
||||
if (!$task_class) {
|
||||
throw new ConduitException('ERR_NO_TASKATTACHER_DEFINED');
|
||||
}
|
||||
|
||||
PhutilSymbolLoader::loadClass($task_class);
|
||||
$task_attacher = newv($task_class, array());
|
||||
$task_attacher->updateTaskRevisionAssoc(
|
||||
$task_phid,
|
||||
$orig_rev_phids,
|
||||
$new_rev_phids);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,17 @@
|
|||
<?php
|
||||
/**
|
||||
* This file is automatically generated. Lint this module to rebuild it.
|
||||
* @generated
|
||||
*/
|
||||
|
||||
|
||||
|
||||
phutil_require_module('phabricator', 'applications/conduit/method/base');
|
||||
phutil_require_module('phabricator', 'applications/conduit/protocol/exception');
|
||||
phutil_require_module('phabricator', 'infrastructure/env');
|
||||
|
||||
phutil_require_module('phutil', 'symbols');
|
||||
phutil_require_module('phutil', 'utils');
|
||||
|
||||
|
||||
phutil_require_source('ConduitAPI_differential_updatetaskrevisionassoc_Method.php');
|
|
@ -157,6 +157,11 @@ class DifferentialRevisionViewController extends DifferentialController {
|
|||
$custom_renderer->generateActionLinks($revision, $target));
|
||||
}
|
||||
|
||||
$whitespace = $request->getStr(
|
||||
'whitespace',
|
||||
DifferentialChangesetParser::WHITESPACE_IGNORE_TRAILING
|
||||
);
|
||||
|
||||
$revision_detail->setActions($actions);
|
||||
|
||||
$revision_detail->setUser($user);
|
||||
|
@ -169,24 +174,26 @@ class DifferentialRevisionViewController extends DifferentialController {
|
|||
$comment_view->setUser($user);
|
||||
$comment_view->setTargetDiff($target);
|
||||
|
||||
$changeset_view = new DifferentialChangesetListView();
|
||||
$changeset_view->setChangesets($visible_changesets);
|
||||
$changeset_view->setEditable(true);
|
||||
$changeset_view->setRevision($revision);
|
||||
$changeset_view->setVsMap($vs_map);
|
||||
$changeset_view->setWhitespace($whitespace);
|
||||
|
||||
$diff_history = new DifferentialRevisionUpdateHistoryView();
|
||||
$diff_history->setDiffs($diffs);
|
||||
$diff_history->setSelectedVersusDiffID($diff_vs);
|
||||
$diff_history->setSelectedDiffID($target->getID());
|
||||
$diff_history->setSelectedWhitespace($request->getStr('whitespace'));
|
||||
$diff_history->setSelectedWhitespace($whitespace);
|
||||
|
||||
$toc_view = new DifferentialDiffTableOfContentsView();
|
||||
$toc_view->setChangesets($changesets);
|
||||
$toc_view->setStandaloneViewLink(empty($visible_changesets));
|
||||
$toc_view->setVsMap($vs_map);
|
||||
$toc_view->setRevisionID($revision->getID());
|
||||
$toc_view->setWhitespace($whitespace);
|
||||
|
||||
$changeset_view = new DifferentialChangesetListView();
|
||||
$changeset_view->setChangesets($visible_changesets);
|
||||
$changeset_view->setEditable(true);
|
||||
$changeset_view->setRevision($revision);
|
||||
$changeset_view->setVsMap($vs_map);
|
||||
$changeset_view->setWhitespace($request->getStr('whitespace'));
|
||||
|
||||
$draft = id(new PhabricatorDraft())->loadOneWhere(
|
||||
'authorPHID = %s AND draftKey = %s',
|
||||
|
@ -604,273 +611,3 @@ class DifferentialRevisionViewController extends DifferentialController {
|
|||
->replace();
|
||||
}
|
||||
}
|
||||
/*
|
||||
|
||||
|
||||
protected function getSandcastleURI(Diff $diff) {
|
||||
$uri = $this->getDiffProperty($diff, 'facebook:sandcastle_uri');
|
||||
if (!$uri) {
|
||||
$uri = $diff->getSandboxURL();
|
||||
}
|
||||
return $uri;
|
||||
}
|
||||
|
||||
protected function getDiffProperty(Diff $diff, $property, $default = null) {
|
||||
$diff_id = $diff->getID();
|
||||
if (empty($this->diffProperties[$diff_id])) {
|
||||
$props = id(new DifferentialDiffProperty())
|
||||
->loadAllWhere('diffID = %s', $diff_id);
|
||||
$dict = array_pull($props, 'getData', 'getName');
|
||||
$this->diffProperties[$diff_id] = $dict;
|
||||
}
|
||||
return idx($this->diffProperties[$diff_id], $property, $default);
|
||||
}
|
||||
|
||||
$diff_table->appendChild(
|
||||
<tr>
|
||||
<td colspan="8" class="diff-differ-submit">
|
||||
<label>Whitespace Changes:</label>
|
||||
{id(<select name="whitespace" />)->setOptions(
|
||||
array(
|
||||
'ignore-all' => 'Ignore All',
|
||||
'ignore-trailing' => 'Ignore Trailing',
|
||||
'show-all' => 'Show All',
|
||||
), $request->getStr('whitespace'))}{' '}
|
||||
<button type="submit">Show Diff</button>
|
||||
</td>
|
||||
</tr>);
|
||||
|
||||
$load_ids = array_filter(array($old, $diff->getID()));
|
||||
|
||||
$viewer_id = $this->getRequest()->getViewerContext()->getUserID();
|
||||
|
||||
$raw_objects = queryfx_all(
|
||||
smc_get_db('cdb.differential', 'r'),
|
||||
'SELECT * FROM changeset WHERE changeset.diffID IN (%Ld)',
|
||||
$load_ids);
|
||||
|
||||
$raw_objects = array_group($raw_objects, 'diffID');
|
||||
$objects = $raw_objects[$diff->getID()];
|
||||
|
||||
if (!$objects) {
|
||||
$changesets = array();
|
||||
} else {
|
||||
$changesets = id(new DifferentialChangeset())->loadAllFromArray($objects);
|
||||
}
|
||||
|
||||
|
||||
|
||||
$feedback = id(new DifferentialFeedback())->loadAllWithRevision($revision);
|
||||
$feedback = array_merge($implied_feedback, $feedback);
|
||||
|
||||
$inline_comments = $this->loadInlineComments($feedback, $changesets);
|
||||
|
||||
$diff_map = array();
|
||||
$diffs = array_psort($diffs, 'getID');
|
||||
foreach ($diffs as $diff) {
|
||||
$diff_map[$diff->getID()] = count($diff_map) + 1;
|
||||
}
|
||||
$visible_changesets = array_fill_keys($visible_changesets, true);
|
||||
$hidden_changesets = array();
|
||||
foreach ($changesets as $changeset) {
|
||||
$id = $changeset->getID();
|
||||
if (isset($visible_changesets[$id])) {
|
||||
continue;
|
||||
}
|
||||
$hidden_changesets[$id] = $diff_map[$changeset->getDiffID()];
|
||||
}
|
||||
|
||||
|
||||
$engine = new RemarkupEngine();
|
||||
$engine->enableFeature(RemarkupEngine::FEATURE_GUESS_IMAGES);
|
||||
$engine->enableFeature(RemarkupEngine::FEATURE_YOUTUBE);
|
||||
$engine->setCurrentSandcastle($this->getSandcastleURI($target_diff));
|
||||
|
||||
$syntax_link =
|
||||
<a href={'http://www.intern.facebook.com/intern/wiki/index.php' .
|
||||
'/Articles/Remarkup_Syntax_Reference'}
|
||||
target="_blank"
|
||||
tabindex="4">Remarkup Reference</a>;
|
||||
|
||||
|
||||
$notice = null;
|
||||
if ($this->getRequest()->getBool('diff_changed')) {
|
||||
$notice =
|
||||
<tools:notice title="Revision Updated Recently">
|
||||
This revision was updated with a <strong>new diff</strong> while you
|
||||
were providing feedback. Your inline comments appear on the
|
||||
<strong>old diff</strong>.
|
||||
</tools:notice>;
|
||||
}
|
||||
|
||||
$engineering_repository_id = RepositoryRef::getByCallsign('E')->getID();
|
||||
$svn_revision = $revision->getSVNRevision();
|
||||
if ($status == DifferentialConstants::COMMITTED &&
|
||||
$svn_revision &&
|
||||
$revision->getRepositoryID() == $engineering_repository_id) {
|
||||
$href = '/intern/push/request.php?rev='.$svn_revision;
|
||||
$href = RedirectURI($href)->setTier('intern');
|
||||
$links[] = array(
|
||||
'merge',
|
||||
<a href={$href} id="ask_for_merge_link">Ask for Merge</a>,
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
protected function renderDiffPropertyMoreLink(Diff $diff, $name) {
|
||||
$target = <div class="star-more"
|
||||
style="display: none;">
|
||||
<div class="star-loading">Loading...</div>
|
||||
</div>;
|
||||
$meta = array(
|
||||
'target' => $target->requireUniqueID(),
|
||||
'uri' => '/differential/diffprop/'.$diff->getID().'/'.$name.'/',
|
||||
);
|
||||
$more =
|
||||
<span sigil="star-link-container">
|
||||
·
|
||||
<a mustcapture="true"
|
||||
sigil="star-more"
|
||||
href="#"
|
||||
meta={$meta}>Show Details</a>
|
||||
</span>;
|
||||
return <x:frag>{$more}{$target}</x:frag>;
|
||||
}
|
||||
|
||||
|
||||
|
||||
protected function getRevisionStatusDisplay(DifferentialRevision $revision) {
|
||||
$viewer_id = $this->getRequest()->getViewerContext()->getUserID();
|
||||
$viewer_is_owner = ($viewer_id == $revision->getOwnerID());
|
||||
$status = $revision->getStatus();
|
||||
|
||||
$more = null;
|
||||
switch ($status) {
|
||||
case DifferentialConstants::NEEDS_REVIEW:
|
||||
$message = 'Pending Review';
|
||||
break;
|
||||
case DifferentialConstants::NEEDS_REVISION:
|
||||
$message = 'Awaiting Revision';
|
||||
if ($viewer_is_owner) {
|
||||
$more = 'Make the requested changes and update the revision.';
|
||||
}
|
||||
break;
|
||||
case DifferentialConstants::ACCEPTED:
|
||||
$message = 'Ready for Commit';
|
||||
if ($viewer_is_owner) {
|
||||
$more =
|
||||
<x:frag>
|
||||
Run <tt>arc commit</tt> (svn) or <tt>arc amend</tt> (git) to
|
||||
proceed.
|
||||
</x:frag>;
|
||||
}
|
||||
break;
|
||||
case DifferentialConstants::COMMITTED:
|
||||
$message = 'Committed';
|
||||
$ref = $revision->getRevisionRef();
|
||||
$more = $ref
|
||||
? (<a href={URI($ref->getDetailURL())}>
|
||||
{$ref->getName()}
|
||||
</a>)
|
||||
: null;
|
||||
|
||||
$engineering_repository_id = RepositoryRef::getByCallsign('E')->getID();
|
||||
if ($revision->getSVNRevision() &&
|
||||
$revision->getRepositoryID() == $engineering_repository_id) {
|
||||
Javelin::initBehavior(
|
||||
'differential-revtracker-status',
|
||||
array(
|
||||
'uri' => '/differential/revtracker/'.$revision->getID().'/',
|
||||
'statusId' => 'revtracker_status',
|
||||
'mergeLinkId' => 'ask_for_merge_link',
|
||||
));
|
||||
}
|
||||
break;
|
||||
case DifferentialConstants::ABANDONED:
|
||||
$message = 'Abandoned';
|
||||
break;
|
||||
default:
|
||||
throw new Exception("Unknown revision status.");
|
||||
}
|
||||
|
||||
if ($more) {
|
||||
$message =
|
||||
<x:frag>
|
||||
<strong id="revtracker_status">{$message}</strong>
|
||||
· {$more}
|
||||
</x:frag>;
|
||||
} else {
|
||||
$message = <strong id="revtracker_status">{$message}</strong>;
|
||||
}
|
||||
|
||||
return $message;
|
||||
}
|
||||
|
||||
}
|
||||
protected function getDetailFields(
|
||||
DifferentialRevision $revision,
|
||||
Diff $diff,
|
||||
array $handles) {
|
||||
|
||||
$sandcastle = $this->getSandcastleURI($diff);
|
||||
if ($sandcastle) {
|
||||
$fields['Sandcastle'] = <a href={$sandcastle}>{$sandcastle}</a>;
|
||||
}
|
||||
|
||||
|
||||
$blame_rev = $revision->getSvnBlameRevision();
|
||||
if ($blame_rev) {
|
||||
if ($revision->getRepositoryRef() && is_numeric($blame_rev)) {
|
||||
$ref = new RevisionRef($revision->getRepositoryRef(), $blame_rev);
|
||||
$fields['Blame Revision'] =
|
||||
<a href={URI($ref->getDetailURL())}>
|
||||
{$ref->getName()}
|
||||
</a>;
|
||||
} else {
|
||||
$fields['Blame Revision'] = $blame_rev;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
$bugzilla_id = $revision->getBugzillaID();
|
||||
if ($bugzilla_id) {
|
||||
$href = 'http://bugs.developers.facebook.com/show_bug.cgi?id='.
|
||||
$bugzilla_id;
|
||||
$fields['Bugzilla'] = <a href={$href}>{'#'.$bugzilla_id}</a>;
|
||||
}
|
||||
|
||||
$fields['Apply Patch'] = <tt>arc patch --revision {$revision->getID()}</tt>;
|
||||
|
||||
if ($diff->getParentRevisionID()) {
|
||||
$parent = id(new DifferentialRevision())->load(
|
||||
$diff->getParentRevisionID());
|
||||
if ($parent) {
|
||||
$fields['Depends On'] =
|
||||
<a href={$parent->getURI()}>
|
||||
D{$parent->getID()}: {$parent->getName()}
|
||||
</a>;
|
||||
}
|
||||
}
|
||||
|
||||
Javelin::initBehavior('differential-star-more');
|
||||
if ($unit_details) {
|
||||
$fields['Unit Tests'] =
|
||||
<x:frag>
|
||||
{$fields['Unit Tests']}
|
||||
{$this->renderDiffPropertyMoreLink($diff, 'unit')}
|
||||
</x:frag>;
|
||||
}
|
||||
|
||||
$platform_impact = $revision->getPlatformImpact();
|
||||
if ($platform_impact) {
|
||||
$fields['Platform Impact'] =
|
||||
<text linebreaks="true">{$platform_impact}</text>;
|
||||
}
|
||||
|
||||
return $fields;
|
||||
}
|
||||
|
||||
|
||||
*/
|
||||
|
|
|
@ -10,6 +10,7 @@ phutil_require_module('phabricator', 'aphront/response/404');
|
|||
phutil_require_module('phabricator', 'applications/differential/constants/action');
|
||||
phutil_require_module('phabricator', 'applications/differential/constants/revisionstatus');
|
||||
phutil_require_module('phabricator', 'applications/differential/controller/base');
|
||||
phutil_require_module('phabricator', 'applications/differential/parser/changeset');
|
||||
phutil_require_module('phabricator', 'applications/differential/storage/changeset');
|
||||
phutil_require_module('phabricator', 'applications/differential/storage/comment');
|
||||
phutil_require_module('phabricator', 'applications/differential/storage/diffproperty');
|
||||
|
|
|
@ -26,4 +26,15 @@ abstract class DifferentialTasksAttacher {
|
|||
$user_phid,
|
||||
DifferentialRevision $revision,
|
||||
array $task_ids);
|
||||
|
||||
/**
|
||||
* This method will be called with a task and its original and new
|
||||
* associated revisions. Implementation of this method should update
|
||||
* the affected revisions to maintain the new associations.
|
||||
*/
|
||||
abstract public function updateTaskRevisionAssoc(
|
||||
$task_phid,
|
||||
array $orig_rev_phids,
|
||||
array $new_rev_phids);
|
||||
|
||||
}
|
||||
|
|
|
@ -23,7 +23,7 @@ class DifferentialChangesetListView extends AphrontView {
|
|||
private $revision;
|
||||
private $renderURI = '/differential/changeset/';
|
||||
private $vsMap = array();
|
||||
private $whitespace = null;
|
||||
private $whitespace;
|
||||
|
||||
public function setChangesets($changesets) {
|
||||
$this->changesets = $changesets;
|
||||
|
|
|
@ -22,6 +22,7 @@ final class DifferentialDiffTableOfContentsView extends AphrontView {
|
|||
private $standaloneViewLink = null;
|
||||
private $renderURI = '/differential/changeset/';
|
||||
private $revisionID;
|
||||
private $whitespace;
|
||||
|
||||
public function setChangesets($changesets) {
|
||||
$this->changesets = $changesets;
|
||||
|
@ -43,6 +44,10 @@ final class DifferentialDiffTableOfContentsView extends AphrontView {
|
|||
return $this;
|
||||
}
|
||||
|
||||
public function setWhitespace($whitespace) {
|
||||
$this->whitespace = $whitespace;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function render() {
|
||||
|
||||
|
@ -95,7 +100,7 @@ final class DifferentialDiffTableOfContentsView extends AphrontView {
|
|||
array(
|
||||
'id' => $ref,
|
||||
'vs' => $vs_id,
|
||||
'whitespace' => 'TODO',
|
||||
'whitespace' => $this->whitespace,
|
||||
'revision_id' => $this->revisionID,
|
||||
));
|
||||
|
||||
|
|
Loading…
Reference in a new issue