mirror of
https://we.phorge.it/source/phorge.git
synced 2024-12-21 13:00:56 +01:00
Merge branch 'master' of github.com:facebook/phabricator
This commit is contained in:
commit
74777227a3
19 changed files with 490 additions and 32 deletions
|
@ -78,15 +78,19 @@ phutil_register_library_map(array(
|
|||
'ConduitAPI_differential_creatediff_Method' => 'applications/conduit/method/differential/creatediff',
|
||||
'ConduitAPI_differential_createrevision_Method' => 'applications/conduit/method/differential/createrevision',
|
||||
'ConduitAPI_differential_find_Method' => 'applications/conduit/method/differential/find',
|
||||
'ConduitAPI_differential_getalldiffs_Method' => 'applications/conduit/method/differential/getalldiffs',
|
||||
'ConduitAPI_differential_getcommitmessage_Method' => 'applications/conduit/method/differential/getcommitmessage',
|
||||
'ConduitAPI_differential_getcommitpaths_Method' => 'applications/conduit/method/differential/getcommitpaths',
|
||||
'ConduitAPI_differential_getdiff_Method' => 'applications/conduit/method/differential/getdiff',
|
||||
'ConduitAPI_differential_getrevision_Method' => 'applications/conduit/method/differential/getrevision',
|
||||
'ConduitAPI_differential_getrevisionfeedback_Method' => 'applications/conduit/method/differential/getrevisionfeedback',
|
||||
'ConduitAPI_differential_markcommitted_Method' => 'applications/conduit/method/differential/markcommitted',
|
||||
'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_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',
|
||||
'ConduitAPI_user_find_Method' => 'applications/conduit/method/user/find',
|
||||
'ConduitAPI_user_whoami_Method' => 'applications/conduit/method/user/whoami',
|
||||
'ConduitException' => 'applications/conduit/protocol/exception',
|
||||
|
@ -524,15 +528,19 @@ phutil_register_library_map(array(
|
|||
'ConduitAPI_differential_creatediff_Method' => 'ConduitAPIMethod',
|
||||
'ConduitAPI_differential_createrevision_Method' => 'ConduitAPIMethod',
|
||||
'ConduitAPI_differential_find_Method' => 'ConduitAPIMethod',
|
||||
'ConduitAPI_differential_getalldiffs_Method' => 'ConduitAPIMethod',
|
||||
'ConduitAPI_differential_getcommitmessage_Method' => 'ConduitAPIMethod',
|
||||
'ConduitAPI_differential_getcommitpaths_Method' => 'ConduitAPIMethod',
|
||||
'ConduitAPI_differential_getdiff_Method' => 'ConduitAPIMethod',
|
||||
'ConduitAPI_differential_getrevision_Method' => 'ConduitAPIMethod',
|
||||
'ConduitAPI_differential_getrevisionfeedback_Method' => 'ConduitAPIMethod',
|
||||
'ConduitAPI_differential_markcommitted_Method' => 'ConduitAPIMethod',
|
||||
'ConduitAPI_differential_parsecommitmessage_Method' => 'ConduitAPIMethod',
|
||||
'ConduitAPI_differential_setdiffproperty_Method' => 'ConduitAPIMethod',
|
||||
'ConduitAPI_differential_updaterevision_Method' => 'ConduitAPIMethod',
|
||||
'ConduitAPI_diffusion_getcommits_Method' => 'ConduitAPIMethod',
|
||||
'ConduitAPI_file_upload_Method' => 'ConduitAPIMethod',
|
||||
'ConduitAPI_path_getowners_Method' => 'ConduitAPIMethod',
|
||||
'ConduitAPI_user_find_Method' => 'ConduitAPIMethod',
|
||||
'ConduitAPI_user_whoami_Method' => 'ConduitAPIMethod',
|
||||
'DarkConsoleConfigPlugin' => 'DarkConsolePlugin',
|
||||
|
|
|
@ -0,0 +1,60 @@
|
|||
<?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_getalldiffs_Method extends ConduitAPIMethod {
|
||||
|
||||
public function getMethodDescription() {
|
||||
return "Load all diffs for given revisions from Differential.";
|
||||
}
|
||||
|
||||
public function defineParamTypes() {
|
||||
return array(
|
||||
'revision_ids' => 'required list<int>',
|
||||
);
|
||||
}
|
||||
|
||||
public function defineReturnType() {
|
||||
return 'dict';
|
||||
}
|
||||
|
||||
public function defineErrorTypes() {
|
||||
return array();
|
||||
}
|
||||
|
||||
protected function execute(ConduitAPIRequest $request) {
|
||||
$results = array();
|
||||
$revision_ids = $request->getValue('revision_ids');
|
||||
|
||||
if (!$revision_ids) {
|
||||
return $results;
|
||||
}
|
||||
|
||||
$diffs = id(new DifferentialDiff())->loadAllWhere(
|
||||
'revisionID IN (%Ld)',
|
||||
$revision_ids);
|
||||
|
||||
foreach ($diffs as $diff) {
|
||||
$results[] = array(
|
||||
'revision_id' => $diff->getRevisionID(),
|
||||
'diff_id' => $diff->getID(),
|
||||
);
|
||||
}
|
||||
|
||||
return $results;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,15 @@
|
|||
<?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/differential/storage/diff');
|
||||
|
||||
phutil_require_module('phutil', 'utils');
|
||||
|
||||
|
||||
phutil_require_source('ConduitAPI_differential_getalldiffs_Method.php');
|
|
@ -69,6 +69,10 @@ class ConduitAPI_differential_getdiff_Method extends ConduitAPIMethod {
|
|||
$changeset->attachHunks($changeset->loadHunks());
|
||||
}
|
||||
|
||||
return $this->createDiffDict($diff);
|
||||
}
|
||||
|
||||
public static function createDiffDict(DifferentialDiff $diff) {
|
||||
$dict = array(
|
||||
'id' => $diff->getID(),
|
||||
'parent' => $diff->getParentRevisionID(),
|
||||
|
|
|
@ -0,0 +1,83 @@
|
|||
<?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_getrevision_Method extends ConduitAPIMethod {
|
||||
|
||||
public function getMethodDescription() {
|
||||
return "Load the content of a revision from Differential.";
|
||||
}
|
||||
|
||||
public function defineParamTypes() {
|
||||
return array(
|
||||
'revision_id' => 'required id',
|
||||
);
|
||||
}
|
||||
|
||||
public function defineReturnType() {
|
||||
return 'nonempty dict';
|
||||
}
|
||||
|
||||
public function defineErrorTypes() {
|
||||
return array(
|
||||
'ERR_BAD_REVISION' => 'No such revision exists.',
|
||||
);
|
||||
}
|
||||
|
||||
protected function execute(ConduitAPIRequest $request) {
|
||||
$diff = null;
|
||||
|
||||
$revision_id = $request->getValue('revision_id');
|
||||
$revision = id(new DifferentialRevision())->load($revision_id);
|
||||
if (!$revision) {
|
||||
throw new ConduitException('ERR_BAD_REVISION');
|
||||
}
|
||||
|
||||
$diffs = $revision->loadDiffs();
|
||||
|
||||
$diff_dicts = array();
|
||||
foreach ($diffs as $diff) {
|
||||
$diff->attachChangesets($diff->loadChangesets());
|
||||
// TODO: We could batch this to improve performance.
|
||||
foreach ($diff->getChangesets() as $changeset) {
|
||||
$changeset->attachHunks($changeset->loadHunks());
|
||||
}
|
||||
$diff_dicts[] =
|
||||
ConduitAPI_differential_getdiff_Method::createDiffDict($diff);
|
||||
}
|
||||
|
||||
$dict = array(
|
||||
'id' => $revision->getID(),
|
||||
'phid' => $revision->getPHID(),
|
||||
'authorPHID' => $revision->getAuthorPHID(),
|
||||
'title' => $revision->getTitle(),
|
||||
'status' => $revision->getStatus(),
|
||||
'statusName' => DifferentialRevisionStatus::getNameForRevisionStatus(
|
||||
$revision->getStatus()),
|
||||
'summary' => $revision->getSummary(),
|
||||
'testPlan' => $revision->getTestPlan(),
|
||||
'revertPlan' => $revision->getRevertPlan(),
|
||||
'blameRevision' => $revision->getBlameRevision(),
|
||||
'dateCommitted' => $revision->getDateCommitted(),
|
||||
'lineCount' => $revision->getLineCount(),
|
||||
'diffs' => $diff_dicts,
|
||||
);
|
||||
|
||||
return $dict;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,18 @@
|
|||
<?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/method/differential/getdiff');
|
||||
phutil_require_module('phabricator', 'applications/conduit/protocol/exception');
|
||||
phutil_require_module('phabricator', 'applications/differential/constants/revisionstatus');
|
||||
phutil_require_module('phabricator', 'applications/differential/storage/revision');
|
||||
|
||||
phutil_require_module('phutil', 'utils');
|
||||
|
||||
|
||||
phutil_require_source('ConduitAPI_differential_getrevision_Method.php');
|
|
@ -0,0 +1,72 @@
|
|||
<?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_getrevisionfeedback_Method
|
||||
extends ConduitAPIMethod {
|
||||
|
||||
public function getMethodDescription() {
|
||||
return "Retrieve Differential Revision Feedback.";
|
||||
}
|
||||
|
||||
public function defineParamTypes() {
|
||||
return array(
|
||||
'ids' => 'required list<int>',
|
||||
);
|
||||
}
|
||||
|
||||
public function defineReturnType() {
|
||||
return 'nonempty list<dict<string, wild>>';
|
||||
}
|
||||
|
||||
public function defineErrorTypes() {
|
||||
return array(
|
||||
);
|
||||
}
|
||||
|
||||
protected function execute(ConduitAPIRequest $request) {
|
||||
$results = array();
|
||||
$revision_ids = $request->getValue('ids');
|
||||
|
||||
if (!$revision_ids) {
|
||||
return $results;
|
||||
}
|
||||
|
||||
$comments = id(new DifferentialComment())->loadAllWhere(
|
||||
'revisionID IN (%Ld)',
|
||||
$revision_ids);
|
||||
|
||||
// Helper dictionary to keep track of where the id/action pair is
|
||||
// stored in results array.
|
||||
$indexes = array();
|
||||
foreach ($comments as $comment) {
|
||||
$action = $comment->getAction();
|
||||
$revision_id = $comment->getRevisionID();
|
||||
|
||||
if (isset($indexes[$action.$revision_id])) {
|
||||
$results[$indexes[$action.$revision_id]]['count']++;
|
||||
} else {
|
||||
$indexes[$action.$revision_id] = count($results);
|
||||
$results[] = array('id' => $revision_id,
|
||||
'action' => $action,
|
||||
'count' => 1);
|
||||
}
|
||||
}
|
||||
|
||||
return $results;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,15 @@
|
|||
<?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/differential/storage/comment');
|
||||
|
||||
phutil_require_module('phutil', 'utils');
|
||||
|
||||
|
||||
phutil_require_source('ConduitAPI_differential_getrevisionfeedback_Method.php');
|
|
@ -0,0 +1,84 @@
|
|||
<?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_path_getowners_Method extends ConduitAPIMethod {
|
||||
|
||||
public function getMethodDescription() {
|
||||
return "Find owners package given its name";
|
||||
}
|
||||
|
||||
public function defineParamTypes() {
|
||||
return array(
|
||||
'repositoryCallsign' => 'required nonempty string',
|
||||
'path' => 'required nonempty string'
|
||||
);
|
||||
}
|
||||
|
||||
public function defineReturnType() {
|
||||
return 'array of packages containing phid, primary_owner (phid=>username),'.
|
||||
'owners(array of phid=>username)';
|
||||
}
|
||||
|
||||
public function defineErrorTypes() {
|
||||
return array(
|
||||
'ERR_REP_NOT_FOUND' => 'The repository callsign is not recognized',
|
||||
'ERR_PATH_NOT_FOUND' => 'The specified path is not known to any package',
|
||||
);
|
||||
}
|
||||
|
||||
protected function execute(ConduitAPIRequest $request) {
|
||||
|
||||
$repository = id(new PhabricatorRepository())->loadOneWhere('callsign = %s',
|
||||
$request->getValue('repositoryCallsign'));
|
||||
|
||||
if (empty($repository)) {
|
||||
throw new ConduitException('ERR_REP_NOT_FOUND');
|
||||
}
|
||||
|
||||
$packages = PhabricatorOwnersPackage::loadOwningPackages(
|
||||
$repository, $request->getValue('path'));
|
||||
if (empty($packages)) {
|
||||
throw new ConduitException('ERR_PATH_NOT_FOUND');
|
||||
}
|
||||
|
||||
$owner = new PhabricatorOwnersOwner();
|
||||
$user = new PhabricatorUser();
|
||||
$result = array();
|
||||
foreach ($packages as $package) {
|
||||
$p_result = array();
|
||||
$p_result['phid'] = $package->getID();
|
||||
$primary_owner_phid = $package->getPrimaryOwnerPHID();
|
||||
if (!empty($primary_owner_phid)) {
|
||||
$p_user = $user->loadOneWhere('phid = %s',
|
||||
$primary_owner_phid);
|
||||
$p_result['primaryOwner'] = $p_user->getPhid();
|
||||
}
|
||||
|
||||
$p_owners = $owner->loadAllForPackages(array($package));
|
||||
$p_users = $user->loadAllWhere('phid IN (%Ls)',
|
||||
mpull($p_owners, 'getUserPHID'));
|
||||
|
||||
$p_result['owners'] = array_values(mpull($p_users, 'getPhid'));
|
||||
|
||||
$result[] = $p_result;
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
}
|
19
src/applications/conduit/method/path/getowners/__init__.php
Normal file
19
src/applications/conduit/method/path/getowners/__init__.php
Normal file
|
@ -0,0 +1,19 @@
|
|||
<?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', 'applications/owners/storage/owner');
|
||||
phutil_require_module('phabricator', 'applications/owners/storage/package');
|
||||
phutil_require_module('phabricator', 'applications/people/storage/user');
|
||||
phutil_require_module('phabricator', 'applications/repository/storage/repository');
|
||||
|
||||
phutil_require_module('phutil', 'utils');
|
||||
|
||||
|
||||
phutil_require_source('ConduitAPI_path_getowners_Method.php');
|
|
@ -132,6 +132,7 @@ class DifferentialChangesetViewController extends DifferentialController {
|
|||
$parser->setChangeset($changeset);
|
||||
$parser->setRightSideCommentMapping($right_source, $right_new);
|
||||
$parser->setLeftSideCommentMapping($left_source, $left_new);
|
||||
$parser->setWhitespaceMode($request->getStr('whitespace'));
|
||||
|
||||
$phids = array();
|
||||
$inlines = $this->loadInlineComments($id, $author_phid);
|
||||
|
|
|
@ -70,7 +70,7 @@ class DifferentialInlineCommentEditController extends DifferentialController {
|
|||
|
||||
if ($request->isFormPost()) {
|
||||
$inline->delete();
|
||||
return $this->buildDeletedResponse();
|
||||
return $this->buildEmptyResponse();
|
||||
}
|
||||
|
||||
$edit_dialog->setTitle('Really delete this comment?');
|
||||
|
@ -95,7 +95,7 @@ class DifferentialInlineCommentEditController extends DifferentialController {
|
|||
$on_right);
|
||||
} else {
|
||||
$inline->delete();
|
||||
return $this->buildDeletedResponse();
|
||||
return $this->buildEmptyResponse();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -112,7 +112,7 @@ class DifferentialInlineCommentEditController extends DifferentialController {
|
|||
case 'create':
|
||||
|
||||
if (!$request->isFormPost() || !strlen($text)) {
|
||||
return new AphrontAjaxResponse();
|
||||
return $this->buildEmptyResponse();
|
||||
}
|
||||
|
||||
$inline = id(new DifferentialInlineComment())
|
||||
|
@ -173,7 +173,7 @@ class DifferentialInlineCommentEditController extends DifferentialController {
|
|||
));
|
||||
}
|
||||
|
||||
private function buildDeletedResponse() {
|
||||
private function buildEmptyResponse() {
|
||||
return id(new AphrontAjaxResponse())
|
||||
->setContent(
|
||||
array(
|
||||
|
|
|
@ -173,6 +173,7 @@ class DifferentialRevisionViewController extends DifferentialController {
|
|||
$diff_history->setDiffs($diffs);
|
||||
$diff_history->setSelectedVersusDiffID($diff_vs);
|
||||
$diff_history->setSelectedDiffID($target->getID());
|
||||
$diff_history->setSelectedWhitespace($request->getStr('whitespace'));
|
||||
|
||||
$toc_view = new DifferentialDiffTableOfContentsView();
|
||||
$toc_view->setChangesets($changesets);
|
||||
|
@ -185,6 +186,7 @@ class DifferentialRevisionViewController extends DifferentialController {
|
|||
$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',
|
||||
|
|
|
@ -675,10 +675,10 @@ EOSYNTHETIC;
|
|||
|
||||
$diff = DifferentialDiff::newFromRawChanges($changes);
|
||||
$changesets = $diff->getChangesets();
|
||||
$alt_changeset = reset($changesets);
|
||||
$changeset = reset($changesets);
|
||||
|
||||
$this->subparser = new DifferentialChangesetParser();
|
||||
$this->subparser->setChangeset($alt_changeset);
|
||||
$this->subparser->setChangeset($changeset);
|
||||
$this->subparser->setWhitespaceMode(self::WHITESPACE_IGNORE_TRAILING);
|
||||
}
|
||||
foreach ($changeset->getHunks() as $hunk) {
|
||||
|
|
|
@ -23,6 +23,7 @@ class DifferentialChangesetListView extends AphrontView {
|
|||
private $revision;
|
||||
private $renderURI = '/differential/changeset/';
|
||||
private $vsMap = array();
|
||||
private $whitespace = null;
|
||||
|
||||
public function setChangesets($changesets) {
|
||||
$this->changesets = $changesets;
|
||||
|
@ -49,6 +50,11 @@ class DifferentialChangesetListView extends AphrontView {
|
|||
return $this;
|
||||
}
|
||||
|
||||
public function setWhitespace($whitespace) {
|
||||
$this->whitespace = $whitespace;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function render() {
|
||||
require_celerity_resource('differential-changeset-view-css');
|
||||
|
||||
|
@ -77,7 +83,7 @@ class DifferentialChangesetListView extends AphrontView {
|
|||
array(
|
||||
'id' => $ref,
|
||||
'vs' => $vs_id,
|
||||
'whitespace' => 'TODO',
|
||||
'whitespace' => $this->whitespace,
|
||||
));
|
||||
|
||||
$detail_button = phutil_render_tag(
|
||||
|
@ -109,10 +115,9 @@ class DifferentialChangesetListView extends AphrontView {
|
|||
$vs_id);
|
||||
}
|
||||
|
||||
$whitespace = null;
|
||||
Javelin::initBehavior('differential-populate', array(
|
||||
'registry' => $mapping,
|
||||
'whitespace' => $whitespace,
|
||||
'whitespace' => $this->whitespace,
|
||||
'uri' => $this->renderURI,
|
||||
));
|
||||
|
||||
|
|
|
@ -21,6 +21,7 @@ final class DifferentialRevisionUpdateHistoryView extends AphrontView {
|
|||
private $diffs = array();
|
||||
private $selectedVersusDiffID;
|
||||
private $selectedDiffID;
|
||||
private $selectedWhitespace;
|
||||
|
||||
public function setDiffs($diffs) {
|
||||
$this->diffs = $diffs;
|
||||
|
@ -37,6 +38,11 @@ final class DifferentialRevisionUpdateHistoryView extends AphrontView {
|
|||
return $this;
|
||||
}
|
||||
|
||||
public function setSelectedWhitespace($whitespace) {
|
||||
$this->selectedWhitespace = $whitespace;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function render() {
|
||||
|
||||
require_celerity_resource('differential-core-view-css');
|
||||
|
@ -157,7 +163,25 @@ final class DifferentialRevisionUpdateHistoryView extends AphrontView {
|
|||
'radios' => $radios,
|
||||
));
|
||||
|
||||
$select = '<select><option>Ignore All</option></select>';
|
||||
$options = array(
|
||||
'ignore-all' => 'Ignore All',
|
||||
'ignore-trailing' => 'Ignore Trailing',
|
||||
'show-all' => 'Show All',
|
||||
);
|
||||
|
||||
$select = '<select name="whitespace">';
|
||||
foreach ($options as $value => $label) {
|
||||
$select .= phutil_render_tag(
|
||||
'option',
|
||||
array(
|
||||
'value' => $value,
|
||||
'selected' => ($value == $this->selectedWhitespace)
|
||||
? 'selected'
|
||||
: null,
|
||||
),
|
||||
phutil_escape_html($label));
|
||||
}
|
||||
$select .= '</select>';
|
||||
|
||||
return
|
||||
'<div class="differential-revision-history differential-panel">'.
|
||||
|
|
|
@ -79,29 +79,65 @@ class PhabricatorOwnersPackage extends PhabricatorOwnersDAO {
|
|||
);
|
||||
|
||||
foreach ($paths as $path) {
|
||||
$trailing_slash = preg_match('@/$@', $path) ? '/' : '';
|
||||
$path = trim($path, '/');
|
||||
$parts = explode('/', $path);
|
||||
while (count($parts)) {
|
||||
$fragments['/'.implode('/', $parts).$trailing_slash] = true;
|
||||
$trailing_slash = '/';
|
||||
array_pop($parts);
|
||||
$fragments += self::splitPath($path);
|
||||
}
|
||||
|
||||
return self::loadPackagesForPaths($repository, array_keys($fragments));
|
||||
}
|
||||
|
||||
public static function loadOwningPackages($repository, $path) {
|
||||
if (empty($path)) {
|
||||
return array();
|
||||
}
|
||||
|
||||
$fragments = self::splitPath($path);
|
||||
return self::loadPackagesForPaths($repository, array_keys($fragments), 1);
|
||||
}
|
||||
|
||||
private static function loadPackagesForPaths(
|
||||
PhabricatorRepository $repository,
|
||||
array $paths,
|
||||
$limit = 0) {
|
||||
$package = new PhabricatorOwnersPackage();
|
||||
$path = new PhabricatorOwnersPath();
|
||||
$conn = $package->establishConnection('r');
|
||||
|
||||
$repository_clause = qsprintf($conn, 'AND p.repositoryPHID = %s',
|
||||
$repository->getPHID());
|
||||
|
||||
$limit_clause = '';
|
||||
if (!empty($limit)) {
|
||||
$limit_clause = qsprintf($conn, 'LIMIT %d', $limit);
|
||||
}
|
||||
|
||||
$data = queryfx_all(
|
||||
$conn,
|
||||
'SELECT pkg.id FROM %T pkg JOIN %T p ON p.packageID = pkg.id
|
||||
WHERE p.path IN (%Ls) %Q ORDER BY LENGTH(p.path) DESC %Q',
|
||||
$package->getTableName(),
|
||||
$path->getTableName(),
|
||||
$paths,
|
||||
$repository_clause,
|
||||
$limit_clause);
|
||||
|
||||
$ids = ipull($data, 'id');
|
||||
|
||||
if (empty($ids)) {
|
||||
return array();
|
||||
}
|
||||
|
||||
$order = array();
|
||||
foreach ($ids as $id) {
|
||||
if (empty($order[$id])) {
|
||||
$order[$id] = true;
|
||||
}
|
||||
}
|
||||
|
||||
$package = new PhabricatorOwnersPackage();
|
||||
$path = new PhabricatorOwnersPath();
|
||||
$data = queryfx_all(
|
||||
$package->establishConnection('r'),
|
||||
'SELECT pkg.* FROM %T pkg JOIN %T p ON p.packageID = pkg.id
|
||||
WHERE p.repositoryPHID = %s
|
||||
AND p.path IN (%Ls)',
|
||||
$package->getTableName(),
|
||||
$path->getTableName(),
|
||||
$repository->getPHID(),
|
||||
array_keys($fragments));
|
||||
$packages = $package->loadAllWhere('id in (%Ld)', array_keys($order));
|
||||
|
||||
return $package->loadAllFromArray($data);
|
||||
$packages = array_select_keys($packages, array_keys($order));
|
||||
|
||||
return $packages;
|
||||
}
|
||||
|
||||
public function save() {
|
||||
|
@ -167,4 +203,16 @@ class PhabricatorOwnersPackage extends PhabricatorOwnersDAO {
|
|||
return parent::delete();
|
||||
}
|
||||
|
||||
private static function splitPath($path) {
|
||||
$result = array();
|
||||
$trailing_slash = preg_match('@/$@', $path) ? '/' : '';
|
||||
$path = trim($path, '/');
|
||||
$parts = explode('/', $path);
|
||||
while (count($parts)) {
|
||||
$result['/'.implode('/', $parts).$trailing_slash] = true;
|
||||
$trailing_slash = '/';
|
||||
array_pop($parts);
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -10,6 +10,7 @@ phutil_require_module('phabricator', 'applications/owners/storage/base');
|
|||
phutil_require_module('phabricator', 'applications/owners/storage/owner');
|
||||
phutil_require_module('phabricator', 'applications/owners/storage/path');
|
||||
phutil_require_module('phabricator', 'applications/phid/storage/phid');
|
||||
phutil_require_module('phabricator', 'storage/qsprintf');
|
||||
phutil_require_module('phabricator', 'storage/queryfx');
|
||||
|
||||
phutil_require_module('phutil', 'utils');
|
||||
|
|
|
@ -32,13 +32,12 @@ class PhabricatorRemarkupRuleImageMacro
|
|||
$this->images[$row->getName()] = $row->getFilePHID();
|
||||
}
|
||||
$this->images[self::RANDOM_IMAGE_NAME] = '';
|
||||
$this->hash = 0;
|
||||
}
|
||||
|
||||
public function apply($text) {
|
||||
$this->hash = 0;
|
||||
|
||||
return preg_replace_callback(
|
||||
'@\b([a-zA-Z0-9_\-]+)\b@U',
|
||||
'@\b([a-zA-Z0-9_\-]+)\b@',
|
||||
array($this, 'markupImageMacro'),
|
||||
$text);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue