mirror of
https://we.phorge.it/source/phorge.git
synced 2024-11-30 02:32:42 +01:00
Disable Herald and enormous change protection for repository initial imports
Summary: See PHI514. Ref T13114. Ref T8951. When a push is an "initial import" (a push of at least 7 commits to an empty repository) don't run Herald or enormous change protection. Test Plan: Pushed some non-initial changes to a repository, and some initial changes. Maniphest Tasks: T13114, T8951 Differential Revision: https://secure.phabricator.com/D19265
This commit is contained in:
parent
5cb6832572
commit
74216ea8e0
1 changed files with 25 additions and 24 deletions
|
@ -126,7 +126,6 @@ final class DiffusionCommitHookEngine extends Phobject {
|
||||||
|
|
||||||
public function execute() {
|
public function execute() {
|
||||||
$ref_updates = $this->findRefUpdates();
|
$ref_updates = $this->findRefUpdates();
|
||||||
$all_updates = $ref_updates;
|
|
||||||
|
|
||||||
$caught = null;
|
$caught = null;
|
||||||
try {
|
try {
|
||||||
|
@ -140,21 +139,32 @@ final class DiffusionCommitHookEngine extends Phobject {
|
||||||
throw $ex;
|
throw $ex;
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->applyHeraldRefRules($ref_updates, $all_updates);
|
|
||||||
|
|
||||||
$content_updates = $this->findContentUpdates($ref_updates);
|
$content_updates = $this->findContentUpdates($ref_updates);
|
||||||
|
$all_updates = array_merge($ref_updates, $content_updates);
|
||||||
|
|
||||||
|
// If this is an "initial import" (a sizable push to a previously empty
|
||||||
|
// repository) we'll allow enormous changes and disable Herald rules.
|
||||||
|
// These rulesets can consume a large amount of time and memory and are
|
||||||
|
// generally not relevant when importing repository history.
|
||||||
|
$is_initial_import = $this->isInitialImport($all_updates);
|
||||||
|
|
||||||
|
if (!$is_initial_import) {
|
||||||
|
$this->applyHeraldRefRules($ref_updates);
|
||||||
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
if (!$is_initial_import) {
|
||||||
$this->rejectEnormousChanges($content_updates);
|
$this->rejectEnormousChanges($content_updates);
|
||||||
|
}
|
||||||
} catch (DiffusionCommitHookRejectException $ex) {
|
} catch (DiffusionCommitHookRejectException $ex) {
|
||||||
// If we're rejecting enormous changes, flag everything.
|
// If we're rejecting enormous changes, flag everything.
|
||||||
$this->rejectCode = PhabricatorRepositoryPushLog::REJECT_ENORMOUS;
|
$this->rejectCode = PhabricatorRepositoryPushLog::REJECT_ENORMOUS;
|
||||||
throw $ex;
|
throw $ex;
|
||||||
}
|
}
|
||||||
|
|
||||||
$all_updates = array_merge($all_updates, $content_updates);
|
if (!$is_initial_import) {
|
||||||
|
$this->applyHeraldContentRules($content_updates);
|
||||||
$this->applyHeraldContentRules($content_updates, $all_updates);
|
}
|
||||||
|
|
||||||
// Run custom scripts in `hook.d/` directories.
|
// Run custom scripts in `hook.d/` directories.
|
||||||
$this->applyCustomHooks($all_updates);
|
$this->applyCustomHooks($all_updates);
|
||||||
|
@ -186,12 +196,10 @@ final class DiffusionCommitHookEngine extends Phobject {
|
||||||
throw $caught;
|
throw $caught;
|
||||||
}
|
}
|
||||||
|
|
||||||
// If this went through cleanly, detect pushes which are actually imports
|
// If this went through cleanly and was an import, set the importing flag
|
||||||
// of an existing repository rather than an addition of new commits. If
|
// on the repository. It will be cleared once we fully process everything.
|
||||||
// this push is importing a bunch of stuff, set the importing flag on
|
|
||||||
// the repository. It will be cleared once we fully process everything.
|
|
||||||
|
|
||||||
if ($this->isInitialImport($all_updates)) {
|
if ($is_initial_import) {
|
||||||
$repository = $this->getRepository();
|
$repository = $this->getRepository();
|
||||||
$repository->markImporting();
|
$repository->markImporting();
|
||||||
}
|
}
|
||||||
|
@ -281,28 +289,21 @@ final class DiffusionCommitHookEngine extends Phobject {
|
||||||
|
|
||||||
/* -( Herald )------------------------------------------------------------- */
|
/* -( Herald )------------------------------------------------------------- */
|
||||||
|
|
||||||
private function applyHeraldRefRules(
|
private function applyHeraldRefRules(array $ref_updates) {
|
||||||
array $ref_updates,
|
|
||||||
array $all_updates) {
|
|
||||||
$this->applyHeraldRules(
|
$this->applyHeraldRules(
|
||||||
$ref_updates,
|
$ref_updates,
|
||||||
new HeraldPreCommitRefAdapter(),
|
new HeraldPreCommitRefAdapter());
|
||||||
$all_updates);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private function applyHeraldContentRules(
|
private function applyHeraldContentRules(array $content_updates) {
|
||||||
array $content_updates,
|
|
||||||
array $all_updates) {
|
|
||||||
$this->applyHeraldRules(
|
$this->applyHeraldRules(
|
||||||
$content_updates,
|
$content_updates,
|
||||||
new HeraldPreCommitContentAdapter(),
|
new HeraldPreCommitContentAdapter());
|
||||||
$all_updates);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private function applyHeraldRules(
|
private function applyHeraldRules(
|
||||||
array $updates,
|
array $updates,
|
||||||
HeraldAdapter $adapter_template,
|
HeraldAdapter $adapter_template) {
|
||||||
array $all_updates) {
|
|
||||||
|
|
||||||
if (!$updates) {
|
if (!$updates) {
|
||||||
return;
|
return;
|
||||||
|
|
Loading…
Reference in a new issue