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

Remove ReleephRequestEvent

Summary: Ref T3663. This is obsolete code which is used only in this migration, which Facebook has already performed and which isn't relevant for any other installs.

Test Plan: `grep`

Reviewers: btrahan

Reviewed By: btrahan

CC: aran

Maniphest Tasks: T3663

Differential Revision: https://secure.phabricator.com/D6777
This commit is contained in:
epriestley 2013-08-20 09:15:35 -07:00
parent 43b35a02ce
commit 973bb0c76e
4 changed files with 5 additions and 232 deletions

View file

@ -1,131 +1,8 @@
<?php
echo "Migrating Releeph requests events to transactions...\n";
// Previously, this migrated ReleephRequestEvents into ApplicationTransactions.
// Only Facebook ever generated meaningful ReleephRequestEvent data, and has
// already migrated, so this was cleaned up when ReleephRequestEvent was
// removed.
$table = new ReleephRequest();
$table->openTransaction();
$table->beginReadLocking();
foreach (new LiskMigrationIterator($table) as $rq) {
printf("RQ%d:", $rq->getID());
$intents_cursor = array();
$last_pick_status = null;
$last_commit_id = null;
foreach ($rq->loadEvents() as $event) {
$author = $event->getActorPHID();
$details = $event->getDetails();
$content_source = PhabricatorContentSource::newForSource(
PhabricatorContentSource::SOURCE_UNKNOWN,
array('ReleephRequestEventID' => $event->getID()));
$xaction = id(new ReleephRequestTransaction())
->setObjectPHID($rq->getPHID())
->setAuthorPHID($author)
->setContentSource($content_source)
->setDateCreated($event->getDateCreated())
->setDateModified($event->getDateModified())
->setViewPolicy(PhabricatorPolicies::POLICY_PUBLIC)
->setEditPolicy($author);
printf(" %s(#%d)", $event->getType(), $event->getID());
switch ($event->getType()) {
case ReleephRequestEvent::TYPE_COMMENT:
$xaction
->setTransactionType(PhabricatorTransactions::TYPE_COMMENT)
->save(); // to generate a PHID
$comment = id(new ReleephRequestTransactionComment())
->setAuthorPHID($author)
->setTransactionPHID($xaction->getPHID())
->setViewPolicy(PhabricatorPolicies::POLICY_PUBLIC)
->setEditPolicy($author)
->setCommentVersion(1)
->setContent($event->getComment())
->setContentSource($content_source)
->save();
$xaction
->setCommentPHID($comment->getPHID())
->setCommentVersion(1);
break;
case ReleephRequestEvent::TYPE_STATUS:
// Ignore STATUS events; these are legacy events that we no longer
// support anyway!
continue 2;
case ReleephRequestEvent::TYPE_USER_INTENT:
$old_intent = idx($intents_cursor, $author);
$new_intent = $event->getDetail('newIntent');
$xaction
->setTransactionType(ReleephRequestTransaction::TYPE_USER_INTENT)
->setMetadataValue('isAuthoritative', $event->getDetail('wasPusher'))
->setOldValue($old_intent)
->setNewValue($new_intent);
$intents_cursor[$author] = $new_intent;
break;
case ReleephRequestEvent::TYPE_PICK_STATUS:
$new_pick_status = $event->getDetail('newPickStatus');
$xaction
->setTransactionType(ReleephRequestTransaction::TYPE_PICK_STATUS)
->setOldValue($last_pick_status)
->setNewValue($new_pick_status);
$last_pick_status = $new_pick_status;
break;
case ReleephRequestEvent::TYPE_COMMIT:
$new_commit_id = $event->getDetail('newCommitIdentifier');
$xaction
->setTransactionType(ReleephRequestTransaction::TYPE_COMMIT)
->setMetadataValue('action', $event->getDetail('action'))
->setOldValue($last_commit_id)
->setNewValue($new_commit_id);
$last_commit_id = $new_commit_id;
break;
case ReleephRequestEvent::TYPE_DISCOVERY:
$xaction
->setTransactionType(ReleephRequestTransaction::TYPE_DISCOVERY)
->setNewValue($event->getDetail('newCommitPHID'));
break;
case ReleephRequestEvent::TYPE_CREATE:
$xaction
->setTransactionType(ReleephRequestTransaction::TYPE_REQUEST)
->setOldValue(null)
->setNewValue($rq->getRequestCommitPHID());
break;
case ReleephRequestEvent::TYPE_MANUAL_ACTION:
$xaction
->setTransactionType(
ReleephRequestTransaction::TYPE_MANUAL_IN_BRANCH);
switch ($event->getDetail('action')) {
case 'pick':
$xaction->setNewValue(1);
break;
case 'revert':
$xaction->setNewValue(0);
break;
}
break;
default:
throw new Exception(sprintf(
"Unhandled ReleephRequestEvent type '%s' in RQ%d",
$event->getType(),
$rq->getID()));
}
$xaction->save();
}
echo("\n");
}
$table->endReadLocking();
$table->saveTransaction();
echo "Done.\n";
echo "(This migration is obsolete.)\n";

View file

@ -1987,7 +1987,6 @@ phutil_register_library_map(array(
'ReleephRequestCommentController' => 'applications/releeph/controller/request/ReleephRequestCommentController.php',
'ReleephRequestDifferentialCreateController' => 'applications/releeph/controller/request/ReleephRequestDifferentialCreateController.php',
'ReleephRequestEditController' => 'applications/releeph/controller/request/ReleephRequestEditController.php',
'ReleephRequestEvent' => 'applications/releeph/storage/request/ReleephRequestEvent.php',
'ReleephRequestException' => 'applications/releeph/storage/request/exception/ReleephRequestException.php',
'ReleephRequestHeaderListView' => 'applications/releeph/view/request/header/ReleephRequestHeaderListView.php',
'ReleephRequestHeaderView' => 'applications/releeph/view/request/header/ReleephRequestHeaderView.php',
@ -4189,7 +4188,6 @@ phutil_register_library_map(array(
'ReleephRequestCommentController' => 'ReleephProjectController',
'ReleephRequestDifferentialCreateController' => 'ReleephProjectController',
'ReleephRequestEditController' => 'ReleephProjectController',
'ReleephRequestEvent' => 'ReleephDAO',
'ReleephRequestException' => 'Exception',
'ReleephRequestHeaderListView' => 'AphrontView',
'ReleephRequestHeaderView' => 'AphrontView',

View file

@ -234,14 +234,6 @@ final class ReleephRequest extends ReleephDAO
return $this->loadReleephBranch()->loadReleephProject();
}
public function loadEvents() {
return $this->loadRelatives(
new ReleephRequestEvent(),
'releephRequestID',
'getID',
'(1 = 1) ORDER BY dateCreated, id');
}
public function loadPhabricatorRepositoryCommit() {
return $this->loadOneRelative(
new PhabricatorRepositoryCommit(),

View file

@ -1,94 +0,0 @@
<?php
final class ReleephRequestEvent extends ReleephDAO {
const TYPE_CREATE = 'create';
const TYPE_STATUS = 'status'; // old events
const TYPE_USER_INTENT = 'user-intent';
const TYPE_PICK_STATUS = 'pick-status';
const TYPE_COMMIT = 'commit';
const TYPE_MANUAL_ACTION = 'manual-action';
const TYPE_DISCOVERY = 'discovery';
const TYPE_COMMENT = 'comment';
protected $releephRequestID;
protected $type;
protected $actorPHID;
protected $details = array();
public function getConfiguration() {
return array(
self::CONFIG_SERIALIZATION => array(
'details' => self::SERIALIZATION_JSON,
),
) + parent::getConfiguration();
}
public function getDetail($key, $default = null) {
return idx($this->details, $key, $default);
}
public function setDetail($key, $value) {
$this->details[$key] = $value;
return $this;
}
private function setDetails(array $details) {
throw new Exception('Use setDetail()!');
}
public function setStatusBefore($status) {
return $this->setDetail('oldStatus', $status);
}
public function setStatusAfter($status) {
return $this->setDetail('newStatus', $status);
}
public function getStatusBefore() {
return $this->getDetail('oldStatus');
}
public function getStatusAfter() {
return $this->getDetail('newStatus');
}
public function getComment() {
return $this->getDetail('comment');
}
public function extractPHIDs() {
$phids = array();
$phids[] = $this->actorPHID;
foreach ($this->details as $key => $value) {
if (strpos($key, 'PHID') !== false || strpos($key, 'phid') !== false) {
$phids[] = $value;
}
}
return $phids;
}
public function canGroupWith(ReleephRequestEvent $next) {
if ($this->getActorPHID() != $next->getActorPHID()) {
return false;
}
if ($this->getComment() && $next->getComment()) {
return false;
}
// Break the chain if the next event changes the status
if ($next->getStatusBefore() != $next->getStatusAfter()) {
return false;
}
// Don't group if the next event starts off with a different status to the
// one we ended with. This probably shouldn't ever happen.
if ($this->getStatusAfter() != $next->getStatusBefore()) {
return false;
}
return true;
}
}