@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.

Add an "--importing" flag to bin/repository reparse

Summary: Fixes T6839. Sometimes, worker tasks go astray for whatever reason. This automates the step of `bin/repository importing | xargs | mangle mangle | bin/repostiory reparse`.

Test Plan: Ran various flavors of the command, got good looking results.

Reviewers: btrahan

Reviewed By: btrahan

Subscribers: epriestley

Maniphest Tasks: T6839

Differential Revision: https://secure.phabricator.com/D13362

+114 -24
+44
src/applications/diffusion/query/DiffusionCommitQuery.php
··· 17 17 private $auditorPHIDs; 18 18 private $auditAwaitingUser; 19 19 private $auditStatus; 20 + private $epochMin; 21 + private $epochMax; 22 + private $importing; 20 23 21 24 const AUDIT_STATUS_ANY = 'audit-status-any'; 22 25 const AUDIT_STATUS_OPEN = 'audit-status-open'; ··· 138 141 139 142 public function withAuditStatus($status) { 140 143 $this->auditStatus = $status; 144 + return $this; 145 + } 146 + 147 + public function withEpochRange($min, $max) { 148 + $this->epochMin = $min; 149 + $this->epochMax = $max; 150 + return $this; 151 + } 152 + 153 + public function withImporting($importing) { 154 + $this->importing = $importing; 141 155 return $this; 142 156 } 143 157 ··· 327 341 $conn_r, 328 342 'commit.authorPHID IN (%Ls)', 329 343 $this->authorPHIDs); 344 + } 345 + 346 + if ($this->epochMin !== null) { 347 + $where[] = qsprintf( 348 + $conn_r, 349 + 'commit.epoch >= %d', 350 + $this->epochMin); 351 + } 352 + 353 + if ($this->epochMax !== null) { 354 + $where[] = qsprintf( 355 + $conn_r, 356 + 'commit.epoch <= %d', 357 + $this->epochMax); 358 + } 359 + 360 + if ($this->importing !== null) { 361 + if ($this->importing) { 362 + $where[] = qsprintf( 363 + $conn_r, 364 + '(commit.importStatus & %d) != %d', 365 + PhabricatorRepositoryCommit::IMPORTED_ALL, 366 + PhabricatorRepositoryCommit::IMPORTED_ALL); 367 + } else { 368 + $where[] = qsprintf( 369 + $conn_r, 370 + '(commit.importStatus & %d) = %d', 371 + PhabricatorRepositoryCommit::IMPORTED_ALL, 372 + PhabricatorRepositoryCommit::IMPORTED_ALL); 373 + } 330 374 } 331 375 332 376 if ($this->identifiers !== null) {
+70 -24
src/applications/repository/management/PhabricatorRepositoryManagementReparseWorkflow.php
··· 84 84 '--all'), 85 85 ), 86 86 array( 87 + 'name' => 'importing', 88 + 'help' => pht( 89 + 'Reparse all steps which have not yet completed.'), 90 + ), 91 + array( 87 92 'name' => 'force-autoclose', 88 93 'help' => pht( 89 - 'Only used with __%s, use this to make sure any '. 94 + 'Only used with __%s__, use this to make sure any '. 90 95 'pertinent diffs are closed regardless of configuration.', 91 - '--message__'), 96 + '--message'), 92 97 ), 93 98 )); 94 99 ··· 106 111 $force = $args->getArg('force'); 107 112 $force_local = $args->getArg('force-local'); 108 113 $min_date = $args->getArg('min-date'); 114 + $importing = $args->getArg('importing'); 109 115 110 116 if (!$all_from_repo && !$reparse_what) { 111 117 throw new PhutilArgumentUsageException( ··· 123 129 $commits)); 124 130 } 125 131 126 - if (!$reparse_message && !$reparse_change && !$reparse_herald && 127 - !$reparse_owners) { 132 + $any_step = ($reparse_message || 133 + $reparse_change || 134 + $reparse_herald || 135 + $reparse_owners); 136 + 137 + if ($any_step && $importing) { 138 + throw new PhutilArgumentUsageException( 139 + pht( 140 + 'Choosing steps with %s conflicts with flags which select '. 141 + 'specific steps.', 142 + '--importing')); 143 + } else if ($any_step) { 144 + // OK. 145 + } else if ($importing) { 146 + // OK. 147 + } else if (!$any_step && !$importing) { 128 148 throw new PhutilArgumentUsageException( 129 149 pht( 130 - 'Specify what information to reparse with %s, %s, %s, and/or %s.', 150 + 'Specify which steps to reparse with %s, or %s, %s, %s, or %s.', 151 + '--importing', 131 152 '--message', 132 153 '--change', 133 154 '--herald', 134 155 '--owners')); 135 - } 156 + } 136 157 137 158 $min_timestamp = false; 138 159 if ($min_date) { ··· 179 200 throw new PhutilArgumentUsageException( 180 201 pht('Unknown repository %s!', $all_from_repo)); 181 202 } 182 - $constraint = ''; 203 + 204 + 205 + $query = id(new DiffusionCommitQuery()) 206 + ->setViewer(PhabricatorUser::getOmnipotentUser()) 207 + ->withRepository($repository); 208 + 183 209 if ($min_timestamp) { 184 - $console->writeOut("%s\n", pht( 185 - 'Excluding entries before UNIX timestamp: %s', 186 - $min_timestamp)); 187 - $table = new PhabricatorRepositoryCommit(); 188 - $conn_r = $table->establishConnection('r'); 189 - $constraint = qsprintf( 190 - $conn_r, 191 - 'AND epoch >= %d', 192 - $min_timestamp); 210 + $query->withEpochRange($min_timestamp, null); 211 + } 212 + 213 + if ($importing) { 214 + $query->withImporting(true); 193 215 } 194 - $commits = id(new PhabricatorRepositoryCommit())->loadAllWhere( 195 - 'repositoryID = %d %Q', 196 - $repository->getID(), 197 - $constraint); 216 + 217 + $commits = $query->execute(); 218 + 198 219 $callsign = $repository->getCallsign(); 199 220 if (!$commits) { 200 - throw new PhutilArgumentUsageException(pht( 201 - "No commits have been discovered in %s repository!\n", 202 - $callsign)); 221 + throw new PhutilArgumentUsageException( 222 + pht( 223 + 'No commits have been discovered in %s repository!', 224 + $callsign)); 203 225 } 204 226 } else { 205 227 $commits = array(); ··· 250 272 251 273 $tasks = array(); 252 274 foreach ($commits as $commit) { 275 + if ($importing) { 276 + $status = $commit->getImportStatus(); 277 + // Find the first missing import step and queue that up. 278 + $reparse_message = false; 279 + $reparse_change = false; 280 + $reparse_owners = false; 281 + $reparse_herald = false; 282 + if (!($status & PhabricatorRepositoryCommit::IMPORTED_MESSAGE)) { 283 + $reparse_message = true; 284 + } else if (!($status & PhabricatorRepositoryCommit::IMPORTED_CHANGE)) { 285 + $reparse_change = true; 286 + } else if (!($status & PhabricatorRepositoryCommit::IMPORTED_OWNERS)) { 287 + $reparse_owners = true; 288 + } else if (!($status & PhabricatorRepositoryCommit::IMPORTED_HERALD)) { 289 + $reparse_herald = true; 290 + } else { 291 + continue; 292 + } 293 + } 294 + 253 295 $classes = array(); 254 296 switch ($repository->getVersionControlSystem()) { 255 297 case PhabricatorRepositoryType::REPOSITORY_TYPE_GIT: ··· 287 329 $classes[] = 'PhabricatorRepositoryCommitOwnersWorker'; 288 330 } 289 331 332 + // NOTE: With "--importing", we queue the first unparsed step and let 333 + // it queue the other ones normally. Without "--importing", we queue 334 + // all the requested steps explicitly. 335 + 290 336 $spec = array( 291 337 'commitID' => $commit->getID(), 292 - 'only' => true, 338 + 'only' => !$importing, 293 339 'forceAutoclose' => $args->getArg('force-autoclose'), 294 340 ); 295 341