1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-12-19 12:00:55 +01:00

Differential - tighten up access of Differential data from other applications

Summary: Fixes T6790. Turn the old method into "new" (old signature) and "newEphemeral". Deploy "newEphemeral" as many places as possible; basically places we are not in the Differential application *and* have no intentions of ever saving the diff. These callsites are also all places we are just trying to get some changesets at the end of the day.

Test Plan: set differential application policy to 'administrators only'. viewed a commit in diffusion and it worked without any errors! i'm just using my thinkin' noodle on the other code paths.

Reviewers: epriestley

Reviewed By: epriestley

Subscribers: Korvin, epriestley

Maniphest Tasks: T6790

Differential Revision: https://secure.phabricator.com/D11020
This commit is contained in:
Bob Trahan 2014-12-19 14:54:15 -08:00
parent fe0c1adf0e
commit 8ac73b2bf3
7 changed files with 21 additions and 11 deletions

View file

@ -159,6 +159,20 @@ final class DifferentialDiff
assert_instances_of($changes, 'ArcanistDiffChange'); assert_instances_of($changes, 'ArcanistDiffChange');
$diff = self::initializeNewDiff($actor); $diff = self::initializeNewDiff($actor);
return self::buildChangesetsFromRawChanges($diff, $changes);
}
public static function newEphemeralFromRawChanges(array $changes) {
assert_instances_of($changes, 'ArcanistDiffChange');
$diff = id(new DifferentialDiff())->makeEphemeral();
return self::buildChangesetsFromRawChanges($diff, $changes);
}
private static function buildChangesetsFromRawChanges(
DifferentialDiff $diff,
array $changes) {
// There may not be any changes; initialize the changesets list so that // There may not be any changes; initialize the changesets list so that
// we don't throw later when accessing it. // we don't throw later when accessing it.
$diff->attachChangesets(array()); $diff->attachChangesets(array());

View file

@ -22,8 +22,7 @@ final class DiffusionChangeController extends DiffusionController {
$drequest->updateSymbolicCommit($data['effectiveCommit']); $drequest->updateSymbolicCommit($data['effectiveCommit']);
$raw_changes = ArcanistDiffChange::newFromConduit($data['changes']); $raw_changes = ArcanistDiffChange::newFromConduit($data['changes']);
$diff = DifferentialDiff::newFromRawChanges( $diff = DifferentialDiff::newEphemeralFromRawChanges(
$viewer,
$raw_changes); $raw_changes);
$changesets = $diff->getChangesets(); $changesets = $diff->getChangesets();
$changeset = reset($changesets); $changeset = reset($changesets);

View file

@ -54,8 +54,7 @@ final class DiffusionDiffController extends DiffusionController {
)); ));
$drequest->updateSymbolicCommit($data['effectiveCommit']); $drequest->updateSymbolicCommit($data['effectiveCommit']);
$raw_changes = ArcanistDiffChange::newFromConduit($data['changes']); $raw_changes = ArcanistDiffChange::newFromConduit($data['changes']);
$diff = DifferentialDiff::newFromRawChanges( $diff = DifferentialDiff::newEphemeralFromRawChanges(
$user,
$raw_changes); $raw_changes);
$changesets = $diff->getChangesets(); $changesets = $diff->getChangesets();
$changeset = reset($changesets); $changeset = reset($changesets);

View file

@ -147,7 +147,8 @@ final class DiffusionPathChange {
array $changes) { array $changes) {
assert_instances_of($changes, 'DiffusionPathChange'); assert_instances_of($changes, 'DiffusionPathChange');
$arcanist_changes = self::convertToArcanistChanges($changes); $arcanist_changes = self::convertToArcanistChanges($changes);
$diff = DifferentialDiff::newFromRawChanges($user, $arcanist_changes); $diff = DifferentialDiff::newEphemeralFromRawChanges(
$arcanist_changes);
return $diff->getChangesets(); return $diff->getChangesets();
} }

View file

@ -1115,8 +1115,7 @@ final class DiffusionCommitHookEngine extends Phobject {
$parser = new ArcanistDiffParser(); $parser = new ArcanistDiffParser();
$changes = $parser->parseDiff($raw_diff); $changes = $parser->parseDiff($raw_diff);
$diff = DifferentialDiff::newFromRawChanges( $diff = DifferentialDiff::newEphemeralFromRawChanges(
$this->getViewer(),
$changes); $changes);
return $diff->getChangesets(); return $diff->getChangesets();
} }

View file

@ -346,8 +346,7 @@ final class HeraldCommitAdapter extends HeraldAdapter {
$parser = new ArcanistDiffParser(); $parser = new ArcanistDiffParser();
$changes = $parser->parseDiff($raw); $changes = $parser->parseDiff($raw);
$diff = DifferentialDiff::newFromRawChanges( $diff = DifferentialDiff::newEphemeralFromRawChanges(
PhabricatorUser::getOmnipotentUser(),
$changes); $changes);
return $diff; return $diff;
} }

View file

@ -163,8 +163,7 @@ final class PhabricatorDifferenceEngine {
$diff = $this->generateRawDiffFromFileContent($old, $new); $diff = $this->generateRawDiffFromFileContent($old, $new);
$changes = id(new ArcanistDiffParser())->parseDiff($diff); $changes = id(new ArcanistDiffParser())->parseDiff($diff);
$diff = DifferentialDiff::newFromRawChanges( $diff = DifferentialDiff::newEphemeralFromRawChanges(
PhabricatorUser::getOmnipotentUser(),
$changes); $changes);
return head($diff->getChangesets()); return head($diff->getChangesets());
} }