Page MenuHomePhabricator

D19265.id46121.diff
No OneTemporary

D19265.id46121.diff

diff --git a/src/applications/diffusion/engine/DiffusionCommitHookEngine.php b/src/applications/diffusion/engine/DiffusionCommitHookEngine.php
--- a/src/applications/diffusion/engine/DiffusionCommitHookEngine.php
+++ b/src/applications/diffusion/engine/DiffusionCommitHookEngine.php
@@ -126,7 +126,6 @@
public function execute() {
$ref_updates = $this->findRefUpdates();
- $all_updates = $ref_updates;
$caught = null;
try {
@@ -140,21 +139,32 @@
throw $ex;
}
- $this->applyHeraldRefRules($ref_updates, $all_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 {
- $this->rejectEnormousChanges($content_updates);
+ if (!$is_initial_import) {
+ $this->rejectEnormousChanges($content_updates);
+ }
} catch (DiffusionCommitHookRejectException $ex) {
// If we're rejecting enormous changes, flag everything.
$this->rejectCode = PhabricatorRepositoryPushLog::REJECT_ENORMOUS;
throw $ex;
}
- $all_updates = array_merge($all_updates, $content_updates);
-
- $this->applyHeraldContentRules($content_updates, $all_updates);
+ if (!$is_initial_import) {
+ $this->applyHeraldContentRules($content_updates);
+ }
// Run custom scripts in `hook.d/` directories.
$this->applyCustomHooks($all_updates);
@@ -186,12 +196,10 @@
throw $caught;
}
- // If this went through cleanly, detect pushes which are actually imports
- // of an existing repository rather than an addition of new commits. If
- // 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 went through cleanly and was an import, 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->markImporting();
}
@@ -281,28 +289,21 @@
/* -( Herald )------------------------------------------------------------- */
- private function applyHeraldRefRules(
- array $ref_updates,
- array $all_updates) {
+ private function applyHeraldRefRules(array $ref_updates) {
$this->applyHeraldRules(
$ref_updates,
- new HeraldPreCommitRefAdapter(),
- $all_updates);
+ new HeraldPreCommitRefAdapter());
}
- private function applyHeraldContentRules(
- array $content_updates,
- array $all_updates) {
+ private function applyHeraldContentRules(array $content_updates) {
$this->applyHeraldRules(
$content_updates,
- new HeraldPreCommitContentAdapter(),
- $all_updates);
+ new HeraldPreCommitContentAdapter());
}
private function applyHeraldRules(
array $updates,
- HeraldAdapter $adapter_template,
- array $all_updates) {
+ HeraldAdapter $adapter_template) {
if (!$updates) {
return;

File Metadata

Mime Type
text/plain
Expires
Sun, Feb 2, 5:12 PM (2 h, 37 m)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
7084830
Default Alt Text
D19265.id46121.diff (3 KB)

Event Timeline