Differential D14967 Diff 36168 src/applications/repository/worker/commitmessageparser/PhabricatorRepositoryCommitMessageParserWorker.php
Changeset View
Changeset View
Standalone View
Standalone View
src/applications/repository/worker/commitmessageparser/PhabricatorRepositoryCommitMessageParserWorker.php
| Show First 20 Lines • Show All 210 Lines • ▼ Show 20 Lines | if ($revision_id) { | ||||
| $commit_close_xaction->setMetadataValue( | $commit_close_xaction->setMetadataValue( | ||||
| 'revisionMatchData', | 'revisionMatchData', | ||||
| $low_level_query->getRevisionMatchData()); | $low_level_query->getRevisionMatchData()); | ||||
| $data->setCommitDetail( | $data->setCommitDetail( | ||||
| 'revisionMatchData', | 'revisionMatchData', | ||||
| $low_level_query->getRevisionMatchData()); | $low_level_query->getRevisionMatchData()); | ||||
| } | } | ||||
| $diff = $this->generateFinalDiff($revision, $acting_as_phid); | $diff = id(new DifferentialDiffExtractionEngine()) | ||||
| ->setViewer($actor) | |||||
| ->setAuthorPHID($acting_as_phid) | |||||
| ->newDiffFromCommit($commit); | |||||
| $vs_diff = $this->loadChangedByCommit($revision, $diff); | $vs_diff = $this->loadChangedByCommit($revision, $diff); | ||||
| $changed_uri = null; | $changed_uri = null; | ||||
| if ($vs_diff) { | if ($vs_diff) { | ||||
| $data->setCommitDetail('vsDiff', $vs_diff->getID()); | $data->setCommitDetail('vsDiff', $vs_diff->getID()); | ||||
| $changed_uri = PhabricatorEnv::getProductionURI( | $changed_uri = PhabricatorEnv::getProductionURI( | ||||
| '/D'.$revision->getID(). | '/D'.$revision->getID(). | ||||
| ▲ Show 20 Lines • Show All 44 Lines • ▼ Show 20 Lines | final protected function updateCommitData(DiffusionCommitRef $ref) { | ||||
| } | } | ||||
| $data->save(); | $data->save(); | ||||
| $commit->writeImportStatusFlag( | $commit->writeImportStatusFlag( | ||||
| PhabricatorRepositoryCommit::IMPORTED_MESSAGE); | PhabricatorRepositoryCommit::IMPORTED_MESSAGE); | ||||
| } | } | ||||
| private function generateFinalDiff( | |||||
| DifferentialRevision $revision, | |||||
| $actor_phid) { | |||||
| $viewer = PhabricatorUser::getOmnipotentUser(); | |||||
| $drequest = DiffusionRequest::newFromDictionary(array( | |||||
| 'user' => $viewer, | |||||
| 'repository' => $this->repository, | |||||
| )); | |||||
| $raw_diff = DiffusionQuery::callConduitWithDiffusionRequest( | |||||
| $viewer, | |||||
| $drequest, | |||||
| 'diffusion.rawdiffquery', | |||||
| array( | |||||
| 'commit' => $this->commit->getCommitIdentifier(), | |||||
| )); | |||||
| // TODO: Support adds, deletes and moves under SVN. | |||||
| if (strlen($raw_diff)) { | |||||
| $changes = id(new ArcanistDiffParser())->parseDiff($raw_diff); | |||||
| } else { | |||||
| // This is an empty diff, maybe made with `git commit --allow-empty`. | |||||
| // NOTE: These diffs have the same tree hash as their ancestors, so | |||||
| // they may attach to revisions in an unexpected way. Just let this | |||||
| // happen for now, although it might make sense to special case it | |||||
| // eventually. | |||||
| $changes = array(); | |||||
| } | |||||
| $diff = DifferentialDiff::newFromRawChanges($viewer, $changes) | |||||
| ->setRepositoryPHID($this->repository->getPHID()) | |||||
| ->setAuthorPHID($actor_phid) | |||||
| ->setCreationMethod('commit') | |||||
| ->setSourceControlSystem($this->repository->getVersionControlSystem()) | |||||
| ->setLintStatus(DifferentialLintStatus::LINT_AUTO_SKIP) | |||||
| ->setUnitStatus(DifferentialUnitStatus::UNIT_AUTO_SKIP) | |||||
| ->setDateCreated($this->commit->getEpoch()) | |||||
| ->setDescription( | |||||
| pht( | |||||
| 'Commit %s', | |||||
| $this->commit->getMonogram())); | |||||
| $parents = DiffusionQuery::callConduitWithDiffusionRequest( | |||||
| $viewer, | |||||
| $drequest, | |||||
| 'diffusion.commitparentsquery', | |||||
| array( | |||||
| 'commit' => $this->commit->getCommitIdentifier(), | |||||
| )); | |||||
| if ($parents) { | |||||
| $diff->setSourceControlBaseRevision(head($parents)); | |||||
| } | |||||
| // TODO: Attach binary files. | |||||
| return $diff->save(); | |||||
| } | |||||
| private function loadChangedByCommit( | private function loadChangedByCommit( | ||||
| DifferentialRevision $revision, | DifferentialRevision $revision, | ||||
| DifferentialDiff $diff) { | DifferentialDiff $diff) { | ||||
| $repository = $this->repository; | $repository = $this->repository; | ||||
| $vs_diff = id(new DifferentialDiffQuery()) | $vs_diff = id(new DifferentialDiffQuery()) | ||||
| ▲ Show 20 Lines • Show All 198 Lines • Show Last 20 Lines | |||||