1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-12-28 08:20:57 +01:00

Use Edges to store dependencies between revisions in Differential

Summary: See D3006. Move this data to the edge store.

Test Plan:
  - Created dependencies, migrated, verified dependencies were preserved.
  - Added new dependencies, they worked.

Reviewers: vrana, btrahan

Reviewed By: btrahan

CC: aran

Maniphest Tasks: T1162

Differential Revision: https://secure.phabricator.com/D3007
This commit is contained in:
epriestley 2012-07-18 20:42:06 -07:00
parent 9196a6bd9f
commit ee709a0543
5 changed files with 63 additions and 5 deletions

View file

@ -0,0 +1,42 @@
<?php
/*
* Copyright 2012 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.
*/
echo "Migrating differential dependencies to edges...\n";
foreach (new LiskMigrationIterator(new DifferentialRevision()) as $rev) {
$id = $rev->getID();
echo "Revision {$id}: ";
$deps = $rev->getAttachedPHIDs(PhabricatorPHIDConstants::PHID_TYPE_DREV);
if (!$deps) {
echo "-\n";
continue;
}
$editor = new PhabricatorEdgeEditor();
$editor->setSuppressEvents(true);
foreach ($deps as $dep) {
$editor->addEdge(
$rev->getPHID(),
PhabricatorEdgeConfig::TYPE_DREV_DEPENDS_ON_DREV,
$dep);
}
$editor->save();
echo "OKAY\n";
}
echo "Done.\n";

View file

@ -1,7 +1,7 @@
<?php
/*
* Copyright 2011 Facebook, Inc.
* Copyright 2012 Facebook, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -46,9 +46,9 @@ final class DifferentialDependenciesFieldSpecification
}
private function getDependentRevisionPHIDs() {
$revision = $this->getRevision();
return $revision->getAttachedPHIDs(
PhabricatorPHIDConstants::PHID_TYPE_DREV);
return PhabricatorEdgeQuery::loadDestinationPHIDs(
$this->getRevision()->getPHID(),
PhabricatorEdgeConfig::TYPE_DREV_DEPENDS_ON_DREV);
}
}

View file

@ -119,7 +119,6 @@ final class PhabricatorSearchAttachController
} else {
switch ($this->action) {
case self::ACTION_ATTACH:
case self::ACTION_DEPENDENCIES:
$phids = $object->getAttachedPHIDs($attach_type);
break;
default:
@ -274,6 +273,7 @@ final class PhabricatorSearchAttachController
private function getEdgeType($src_type, $dst_type) {
$t_cmit = PhabricatorPHIDConstants::PHID_TYPE_CMIT;
$t_task = PhabricatorPHIDConstants::PHID_TYPE_TASK;
$t_drev = PhabricatorPHIDConstants::PHID_TYPE_DREV;
$map = array(
$t_cmit => array(
@ -283,6 +283,9 @@ final class PhabricatorSearchAttachController
$t_cmit => PhabricatorEdgeConfig::TYPE_TASK_HAS_COMMIT,
$t_task => PhabricatorEdgeConfig::TYPE_TASK_DEPENDS_ON_TASK,
),
$t_drev => array(
$t_drev => PhabricatorEdgeConfig::TYPE_DREV_DEPENDS_ON_DREV,
),
);
if (empty($map[$src_type][$dst_type])) {

View file

@ -23,9 +23,13 @@ final class PhabricatorEdgeConfig extends PhabricatorEdgeConstants {
const TYPE_TASK_HAS_COMMIT = 1;
const TYPE_COMMIT_HAS_TASK = 2;
const TYPE_TASK_DEPENDS_ON_TASK = 3;
const TYPE_TASK_DEPENDED_ON_BY_TASK = 4;
const TYPE_DREV_DEPENDS_ON_DREV = 5;
const TYPE_DREV_DEPENDED_ON_BY_DREV = 6;
const TYPE_TEST_NO_CYCLE = 9000;
public static function getInverse($edge_type) {
@ -35,6 +39,9 @@ final class PhabricatorEdgeConfig extends PhabricatorEdgeConstants {
self::TYPE_TASK_DEPENDS_ON_TASK => self::TYPE_TASK_DEPENDED_ON_BY_TASK,
self::TYPE_TASK_DEPENDED_ON_BY_TASK => self::TYPE_TASK_DEPENDS_ON_TASK,
self::TYPE_DREV_DEPENDS_ON_DREV => self::TYPE_DREV_DEPENDED_ON_BY_DREV,
self::TYPE_DREV_DEPENDED_ON_BY_DREV => self::TYPE_DREV_DEPENDS_ON_DREV,
);
return idx($map, $edge_type);
@ -44,6 +51,7 @@ final class PhabricatorEdgeConfig extends PhabricatorEdgeConstants {
static $map = array(
self::TYPE_TEST_NO_CYCLE => true,
self::TYPE_TASK_DEPENDS_ON_TASK => true,
self::TYPE_DREV_DEPENDS_ON_DREV => true,
);
return isset($map[$edge_type]);
}

View file

@ -919,6 +919,11 @@ final class PhabricatorBuiltinPatchList extends PhabricatorSQLPatchList {
'type' => 'php',
'name' => $this->getPatchPath('migrate-maniphest-dependencies.php'),
),
'migrate-differential-dependencies.php' => array(
'type' => 'php',
'name' => $this->getPatchPath(
'migrate-differential-dependencies.php'),
),
);
}