1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-11-25 16:22:43 +01:00

Remove "cut point commit identifier" from Releeph

Summary: Ref T3656. Releeph denormalizes branch cut point identifiers into Branch objects, but this information isn't useful or used for sorting, filtering, or enforcing unique constraints. Instead, derive it via noramlized pathways from the `cutPointCommitPHID`.

Test Plan: Ran storage upgrade. Ran `releephwork.getbranch` and `releeph.getbranches`. Grepped for `cutPointCommitIdentifier`.

Reviewers: btrahan

Reviewed By: btrahan

CC: LegNeato, aran

Maniphest Tasks: T3656

Differential Revision: https://secure.phabricator.com/D6636
This commit is contained in:
epriestley 2013-08-14 09:01:38 -07:00
parent a84cc777c8
commit 9f41032693
7 changed files with 48 additions and 8 deletions

View file

@ -0,0 +1,2 @@
ALTER TABLE {$NAMESPACE}_releeph.releeph_branch
DROP cutPointCommitIdentifier;

View file

@ -52,7 +52,7 @@ final class ConduitAPI_releeph_getbranches_Method
'branch' => $branch->getBasename(),
'fullBranchName' => $full_branch_name,
'symbolicName' => $branch->getSymbolicName(),
'cutPoint' => $branch->getCutPointCommitIdentifier(),
'cutPoint' => $cut_point_commit->getCommitIdentifier(),
);
}
}

View file

@ -26,8 +26,11 @@ final class ConduitAPI_releephwork_getbranch_Method
}
protected function execute(ConduitAPIRequest $request) {
$branch = id(new ReleephBranch())
->loadOneWhere('phid = %s', $request->getValue('branchPHID'));
$branch = id(new ReleephBranchQuery())
->setViewer($request->getUser())
->withPHIDs(array($request->getValue('branchPHID')))
->needCutPointCommits(true)
->executeOne();
$cut_phid = $branch->getCutPointCommitPHID();
$phids = array($cut_phid);
@ -35,14 +38,15 @@ final class ConduitAPI_releephwork_getbranch_Method
->setViewer($request->getUser())
->loadHandles();
$project = $branch->loadReleephProject();
$repo = $project->loadPhabricatorRepository();
$project = $branch->getProject();
$repo = $project->getRepository();
$commit = $branch->getCutPointCommit();
return array(
'branchName' => $branch->getName(),
'branchPHID' => $branch->getPHID(),
'vcsType' => $repo->getVersionControlSystem(),
'cutCommitID' => $branch->getCutPointCommitIdentifier(),
'cutCommitID' => $commit->getCommitIdentifier(),
'cutCommitName' => $handles[$cut_phid]->getName(),
'creatorPHID' => $branch->getCreatedByUserPHID(),
'trunk' => $project->getTrunkBranch(),

View file

@ -46,7 +46,6 @@ final class ReleephBranchEditor extends PhabricatorEditor {
->setBasename($basename)
->setReleephProjectID($this->releephProject->getID())
->setCreatedByUserPHID($this->requireActor()->getPHID())
->setCutPointCommitIdentifier($cut_point->getCommitIdentifier())
->setCutPointCommitPHID($cut_point->getPHID())
->setIsActive(1)
->setDetail('branchDate', $branch_date)

View file

@ -6,6 +6,8 @@ final class ReleephBranchQuery
private $ids;
private $phids;
private $needCutPointCommits;
public function withIDs(array $ids) {
$this->ids = $ids;
return $this;
@ -16,6 +18,11 @@ final class ReleephBranchQuery
return $this;
}
public function needCutPointCommits($need_commits) {
$this->needCutPointCommits = $need_commits;
return $this;
}
public function loadPage() {
$table = new ReleephBranch();
$conn_r = $table->establishConnection('r');
@ -48,6 +55,20 @@ final class ReleephBranchQuery
}
}
if ($this->needCutPointCommits) {
$commit_phids = mpull($branches, 'getCutPointCommitPHID');
$commits = id(new DiffusionCommitQuery())
->setViewer($this->getViewer())
->withPHIDs($commit_phids)
->execute();
$commits = mpull($commits, null, 'getPHID');
foreach ($branches as $branch) {
$commit = idx($commits, $branch->getCutPointCommitPHID());
$branch->attachCutPointCommit($commit);
}
}
return $branches;
}

View file

@ -17,12 +17,12 @@ final class ReleephBranch extends ReleephDAO
protected $symbolicName;
// Where to cut the branch
protected $cutPointCommitIdentifier;
protected $cutPointCommitPHID;
protected $details = array();
private $project = self::ATTACHABLE;
private $cutPointCommit = self::ATTACHABLE;
public function getConfiguration() {
return array(
@ -162,6 +162,16 @@ final class ReleephBranch extends ReleephDAO
return $this->assertAttached($this->project);
}
public function attachCutPointCommit(
PhabricatorRepositoryCommit $commit = null) {
$this->cutPointCommit = $commit;
return $this;
}
public function getCutPointCommit() {
return $this->assertAttached($this->cutPointCommit);
}
/* -( PhabricatorPolicyInterface )----------------------------------------- */

View file

@ -1543,6 +1543,10 @@ final class PhabricatorBuiltinPatchList extends PhabricatorSQLPatchList {
'type' => 'sql',
'name' => $this->getPatchPath('20130731.releephproject.sql'),
),
'20130731.releephcutpointidentifier.sql' => array(
'type' => 'sql',
'name' => $this->getPatchPath('20130731.releephcutpointidentifier.sql'),
),
);
}
}