@recaptime-dev's working patches + fork for Phorge, a community fork of Phabricator. (Upstream dev and stable branches are at upstream/main and upstream/stable respectively.) hq.recaptime.dev/wiki/Phorge
phorge phabricator
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

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

+25 -24
+25 -24
src/applications/diffusion/engine/DiffusionCommitHookEngine.php
··· 126 126 127 127 public function execute() { 128 128 $ref_updates = $this->findRefUpdates(); 129 - $all_updates = $ref_updates; 130 129 131 130 $caught = null; 132 131 try { ··· 140 139 throw $ex; 141 140 } 142 141 143 - $this->applyHeraldRefRules($ref_updates, $all_updates); 144 - 145 142 $content_updates = $this->findContentUpdates($ref_updates); 143 + $all_updates = array_merge($ref_updates, $content_updates); 144 + 145 + // If this is an "initial import" (a sizable push to a previously empty 146 + // repository) we'll allow enormous changes and disable Herald rules. 147 + // These rulesets can consume a large amount of time and memory and are 148 + // generally not relevant when importing repository history. 149 + $is_initial_import = $this->isInitialImport($all_updates); 150 + 151 + if (!$is_initial_import) { 152 + $this->applyHeraldRefRules($ref_updates); 153 + } 146 154 147 155 try { 148 - $this->rejectEnormousChanges($content_updates); 156 + if (!$is_initial_import) { 157 + $this->rejectEnormousChanges($content_updates); 158 + } 149 159 } catch (DiffusionCommitHookRejectException $ex) { 150 160 // If we're rejecting enormous changes, flag everything. 151 161 $this->rejectCode = PhabricatorRepositoryPushLog::REJECT_ENORMOUS; 152 162 throw $ex; 153 163 } 154 164 155 - $all_updates = array_merge($all_updates, $content_updates); 156 - 157 - $this->applyHeraldContentRules($content_updates, $all_updates); 165 + if (!$is_initial_import) { 166 + $this->applyHeraldContentRules($content_updates); 167 + } 158 168 159 169 // Run custom scripts in `hook.d/` directories. 160 170 $this->applyCustomHooks($all_updates); ··· 186 196 throw $caught; 187 197 } 188 198 189 - // If this went through cleanly, detect pushes which are actually imports 190 - // of an existing repository rather than an addition of new commits. If 191 - // this push is importing a bunch of stuff, set the importing flag on 192 - // the repository. It will be cleared once we fully process everything. 199 + // If this went through cleanly and was an import, set the importing flag 200 + // on the repository. It will be cleared once we fully process everything. 193 201 194 - if ($this->isInitialImport($all_updates)) { 202 + if ($is_initial_import) { 195 203 $repository = $this->getRepository(); 196 204 $repository->markImporting(); 197 205 } ··· 281 289 282 290 /* -( Herald )------------------------------------------------------------- */ 283 291 284 - private function applyHeraldRefRules( 285 - array $ref_updates, 286 - array $all_updates) { 292 + private function applyHeraldRefRules(array $ref_updates) { 287 293 $this->applyHeraldRules( 288 294 $ref_updates, 289 - new HeraldPreCommitRefAdapter(), 290 - $all_updates); 295 + new HeraldPreCommitRefAdapter()); 291 296 } 292 297 293 - private function applyHeraldContentRules( 294 - array $content_updates, 295 - array $all_updates) { 298 + private function applyHeraldContentRules(array $content_updates) { 296 299 $this->applyHeraldRules( 297 300 $content_updates, 298 - new HeraldPreCommitContentAdapter(), 299 - $all_updates); 301 + new HeraldPreCommitContentAdapter()); 300 302 } 301 303 302 304 private function applyHeraldRules( 303 305 array $updates, 304 - HeraldAdapter $adapter_template, 305 - array $all_updates) { 306 + HeraldAdapter $adapter_template) { 306 307 307 308 if (!$updates) { 308 309 return;