mirror of
https://we.phorge.it/source/phorge.git
synced 2024-12-28 16:30:59 +01:00
Convert differential.revisionPHID commit detail to edge
Summary: Migration doesn't delete differential.revisionPHID but maybe it should? Test Plan: Reparsed commit, ran the migration, deleted differential.revisionPHID, looked at task with attached commit with attached revision. Reviewers: epriestley, edward Reviewed By: epriestley CC: aran, Korvin, AnhNhan Differential Revision: https://secure.phabricator.com/D5634
This commit is contained in:
parent
4fb1a9e00f
commit
e31e998f3b
9 changed files with 74 additions and 40 deletions
33
resources/sql/patches/20130409.commitdrev.php
Normal file
33
resources/sql/patches/20130409.commitdrev.php
Normal file
|
@ -0,0 +1,33 @@
|
|||
<?php
|
||||
|
||||
echo "Migrating differential.revisionPHID to edges...\n";
|
||||
$commit_table = new PhabricatorRepositoryCommit();
|
||||
$data_table = new PhabricatorRepositoryCommitData();
|
||||
$editor = id(new PhabricatorEdgeEditor())->setSuppressEvents(true);
|
||||
$commit_table->establishConnection('w');
|
||||
$edges = 0;
|
||||
|
||||
foreach (new LiskMigrationIterator($commit_table) as $commit) {
|
||||
$data = $commit->loadOneRelative($data_table, 'commitID');
|
||||
if (!$data) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$revision_phid = $data->getCommitDetail('differential.revisionPHID');
|
||||
if (!$revision_phid) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$commit_drev = PhabricatorEdgeConfig::TYPE_COMMIT_HAS_DREV;
|
||||
$editor->addEdge($commit->getPHID(), $commit_drev, $revision_phid);
|
||||
$edges++;
|
||||
if ($edges % 256 == 0) {
|
||||
echo ".";
|
||||
$editor->save();
|
||||
$editor = id(new PhabricatorEdgeEditor())->setSuppressEvents(true);
|
||||
}
|
||||
}
|
||||
|
||||
echo ".";
|
||||
$editor->save();
|
||||
echo "\nDone.\n";
|
|
@ -364,7 +364,8 @@ final class DiffusionCommitController extends DiffusionController {
|
|||
->withSourcePHIDs(array($commit_phid))
|
||||
->withEdgeTypes(array(
|
||||
PhabricatorEdgeConfig::TYPE_COMMIT_HAS_TASK,
|
||||
PhabricatorEdgeConfig::TYPE_COMMIT_HAS_PROJECT
|
||||
PhabricatorEdgeConfig::TYPE_COMMIT_HAS_PROJECT,
|
||||
PhabricatorEdgeConfig::TYPE_COMMIT_HAS_DREV,
|
||||
))
|
||||
->execute();
|
||||
|
||||
|
@ -372,8 +373,10 @@ final class DiffusionCommitController extends DiffusionController {
|
|||
$edges[$commit_phid][PhabricatorEdgeConfig::TYPE_COMMIT_HAS_TASK]);
|
||||
$proj_phids = array_keys(
|
||||
$edges[$commit_phid][PhabricatorEdgeConfig::TYPE_COMMIT_HAS_PROJECT]);
|
||||
$revision_phid = key(
|
||||
$edges[$commit_phid][PhabricatorEdgeConfig::TYPE_COMMIT_HAS_DREV]);
|
||||
|
||||
$phids = array_merge($task_phids, $proj_phids);
|
||||
$phids = array_mergev($edges[$commit_phid]);
|
||||
if ($data->getCommitDetail('authorPHID')) {
|
||||
$phids[] = $data->getCommitDetail('authorPHID');
|
||||
}
|
||||
|
@ -383,9 +386,6 @@ final class DiffusionCommitController extends DiffusionController {
|
|||
if ($data->getCommitDetail('committerPHID')) {
|
||||
$phids[] = $data->getCommitDetail('committerPHID');
|
||||
}
|
||||
if ($data->getCommitDetail('differential.revisionPHID')) {
|
||||
$phids[] = $data->getCommitDetail('differential.revisionPHID');
|
||||
}
|
||||
if ($parents) {
|
||||
foreach ($parents as $parent) {
|
||||
$phids[] = $parent->getPHID();
|
||||
|
@ -432,7 +432,6 @@ final class DiffusionCommitController extends DiffusionController {
|
|||
}
|
||||
}
|
||||
|
||||
$revision_phid = $data->getCommitDetail('differential.revisionPHID');
|
||||
if ($revision_phid) {
|
||||
$props['Differential Revision'] = $handles[$revision_phid]->renderLink();
|
||||
}
|
||||
|
|
|
@ -18,7 +18,6 @@ final class DiffusionHovercardEventListener extends PhutilEventListener {
|
|||
$viewer = $event->getUser();
|
||||
$hovercard = $event->getValue('hovercard');
|
||||
$object_handle = $event->getValue('handle');
|
||||
$phid = $object_handle->getPHID();
|
||||
$commit = $event->getValue('object');
|
||||
|
||||
if (!($commit instanceof PhabricatorRepositoryCommit)) {
|
||||
|
@ -26,7 +25,11 @@ final class DiffusionHovercardEventListener extends PhutilEventListener {
|
|||
}
|
||||
|
||||
$commit_data = $commit->loadCommitData();
|
||||
$revision = $commit_data->getCommitDetail('differential.revisionPHID');
|
||||
|
||||
$revision = PhabricatorEdgeQuery::loadDestinationPHIDs(
|
||||
$commit->getPHID(),
|
||||
PhabricatorEdgeConfig::TYPE_COMMIT_HAS_DREV);
|
||||
$revision = reset($revision);
|
||||
|
||||
$author = $commit->getAuthorPHID();
|
||||
|
||||
|
|
|
@ -502,26 +502,19 @@ final class ManiphestTaskDetailController extends ManiphestController {
|
|||
$commit_phids = array_keys(
|
||||
$edges[PhabricatorEdgeConfig::TYPE_TASK_HAS_COMMIT]);
|
||||
if ($commit_phids) {
|
||||
$commits = id(new PhabricatorRepositoryCommit())
|
||||
->putInSet(new LiskDAOSet())
|
||||
->loadAllWhere('phid IN (%Ls)', $commit_phids);
|
||||
$commit_drev = PhabricatorEdgeConfig::TYPE_COMMIT_HAS_DREV;
|
||||
$drev_edges = id(new PhabricatorEdgeQuery())
|
||||
->withSourcePHIDs($commit_phids)
|
||||
->withEdgeTypes(array($commit_drev))
|
||||
->execute();
|
||||
|
||||
foreach ($commits as $commit) {
|
||||
$phid = $commit->getPHID();
|
||||
foreach ($commit_phids as $phid) {
|
||||
$revisions_commits[$phid] = $handles[$phid]->renderLink();
|
||||
|
||||
$data = $commit->loadOneRelative(
|
||||
new PhabricatorRepositoryCommitData(),
|
||||
'commitID');
|
||||
|
||||
$revision_phid = ($data
|
||||
? $data->getCommitDetail('differential.revisionPHID')
|
||||
: null);
|
||||
|
||||
$revision_phid = key($drev_edges[$phid][$commit_drev]);
|
||||
$revision_handle = idx($handles, $revision_phid);
|
||||
if ($revision_handle) {
|
||||
$has_drev = PhabricatorEdgeConfig::TYPE_TASK_HAS_RELATED_DREV;
|
||||
unset($edges[$has_drev][$revision_phid]);
|
||||
$task_drev = PhabricatorEdgeConfig::TYPE_TASK_HAS_RELATED_DREV;
|
||||
unset($edges[$task_drev][$revision_phid]);
|
||||
$revisions_commits[$phid] = hsprintf(
|
||||
'%s / %s',
|
||||
$revision_handle->renderLink($revision_handle->getName()),
|
||||
|
|
|
@ -8,14 +8,9 @@ final class ReleephRevisionFieldSpecification
|
|||
}
|
||||
|
||||
public function renderValueForHeaderView() {
|
||||
$data = $this
|
||||
$phid = $this
|
||||
->getReleephRequest()
|
||||
->loadPhabricatorRepositoryCommitData();
|
||||
if (!$data) {
|
||||
return null;
|
||||
}
|
||||
|
||||
$phid = $data->getCommitDetail('differential.revisionPHID');
|
||||
->loadRequestCommitDiffPHID();
|
||||
if (!$phid) {
|
||||
return null;
|
||||
}
|
||||
|
|
|
@ -228,11 +228,10 @@ final class ReleephRequest extends ReleephDAO {
|
|||
}
|
||||
|
||||
public function loadRequestCommitDiffPHID() {
|
||||
$commit_data = $this->loadPhabricatorRepositoryCommitData();
|
||||
if (!$commit_data) {
|
||||
return null;
|
||||
}
|
||||
return $commit_data->getCommitDetail('differential.revisionPHID');
|
||||
$revision_phid = PhabricatorEdgeQuery::loadDestinationPHIDs(
|
||||
$this->getRequestCommitPHID(),
|
||||
PhabricatorEdgeConfig::TYPE_COMMIT_HAS_DREV);
|
||||
return reset($revision_phid);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -118,9 +118,11 @@ abstract class PhabricatorRepositoryCommitMessageParserWorker
|
|||
|
||||
$revision = id(new DifferentialRevision())->load($revision_id);
|
||||
if ($revision) {
|
||||
$data->setCommitDetail(
|
||||
'differential.revisionPHID',
|
||||
$revision->getPHID());
|
||||
$commit_drev = PhabricatorEdgeConfig::TYPE_COMMIT_HAS_DREV;
|
||||
id(new PhabricatorEdgeEditor())
|
||||
->setActor($user)
|
||||
->addEdge($commit->getPHID(), $commit_drev, $revision->getPHID())
|
||||
->save();
|
||||
|
||||
$revision->loadRelationships();
|
||||
queryfx(
|
||||
|
|
|
@ -48,6 +48,9 @@ final class PhabricatorEdgeConfig extends PhabricatorEdgeConstants {
|
|||
const TYPE_PURCAHSE_HAS_CHARGE = 29;
|
||||
const TYPE_CHARGE_HAS_PURCHASE = 30;
|
||||
|
||||
const TYPE_DREV_HAS_COMMIT = 31;
|
||||
const TYPE_COMMIT_HAS_DREV = 32;
|
||||
|
||||
const TYPE_TEST_NO_CYCLE = 9000;
|
||||
|
||||
|
||||
|
@ -94,6 +97,9 @@ final class PhabricatorEdgeConfig extends PhabricatorEdgeConstants {
|
|||
|
||||
self::TYPE_ACCOUNT_HAS_MEMBER => self::TYPE_MEMBER_HAS_ACCOUNT,
|
||||
self::TYPE_MEMBER_HAS_ACCOUNT => self::TYPE_ACCOUNT_HAS_MEMBER,
|
||||
|
||||
self::TYPE_DREV_HAS_COMMIT => self::TYPE_COMMIT_HAS_DREV,
|
||||
self::TYPE_COMMIT_HAS_DREV => self::TYPE_DREV_HAS_COMMIT,
|
||||
);
|
||||
|
||||
return idx($map, $edge_type);
|
||||
|
|
|
@ -1233,7 +1233,11 @@ final class PhabricatorBuiltinPatchList extends PhabricatorSQLPatchList {
|
|||
'20130403.conpherencecachemig.php' => array(
|
||||
'type' => 'php',
|
||||
'name' => $this->getPatchPath('20130403.conpherencecachemig.php'),
|
||||
)
|
||||
),
|
||||
'20130409.commitdrev.php' => array(
|
||||
'type' => 'php',
|
||||
'name' => $this->getPatchPath('20130409.commitdrev.php'),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue