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

Repositories - Move scripts/repository/reparse.php to bin/repository reparse

Summary:
Fixes T5966. Accomplishes a few things

- see title
- adds a force-autoclose flag and the plumbing for it
- removes references to some HarborMaster thing that used to key off commits and seems long dead, but forgotten :/

Test Plan:
ran a few commands. These first three had great success:

`./repository reparse --all FIRSTREPO --message --change --herald --owners`
`./repository reparse --all FIRSTREPO --message --change --herald --owners --min-date yesterday`
`./repository reparse --all FIRSTREPO --message --change --herald --owners --min-date yesterday --force-autoclose`

...and these next two showed me some errors as expected:

`./repository reparse --all FIRSTREPO --message --change --herald --owners --min-date garbagedata`
`./repository reparse --all GARBAGEREPO --message --change --herald --owners`

Also, made a diff in a repository with autoclose disabled and commited the diff. Later, reparse the diff with force-autoclose. Verified the diff closed and that the reason "why" had the proper message text.

Reviewers: epriestley

Reviewed By: epriestley

Subscribers: joshuaspence, epriestley, Korvin

Maniphest Tasks: T5966

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

+324 -299
-297
scripts/repository/reparse.php
··· 1 - #!/usr/bin/env php 2 - <?php 3 - 4 - $root = dirname(dirname(dirname(__FILE__))); 5 - require_once $root.'/scripts/__init_script__.php'; 6 - 7 - $args = new PhutilArgumentParser($argv); 8 - $args->setSynopsis(<<<EOHELP 9 - **reparse.php** __what__ __which_parts__ [--trace] [--force] 10 - 11 - Rerun the Diffusion parser on specific commits and repositories. Mostly 12 - useful for debugging changes to Diffusion. 13 - 14 - e.g. enqueue reparse owners in the TEST repo for all commits: 15 - ./reparse.php --all TEST --owners 16 - 17 - e.g. do same but exclude before yesterday (local time): 18 - ./reparse.php --all TEST --owners --min-date yesterday 19 - ./reparse.php --all TEST --owners --min-date "today -1 day" 20 - 21 - e.g. do same but exclude before 03/31/2013 (local time): 22 - ./reparse.php --all TEST --owners --min-date "03/31/2013" 23 - EOHELP 24 - ); 25 - 26 - $min_date_usage_examples = 27 - "Valid examples:\n". 28 - " 'today', 'today 2pm', '-1 hour', '-2 hours', '-24 hours',\n". 29 - " 'yesterday', 'today -1 day', 'yesterday 2pm', '2pm -1 day',\n". 30 - " 'last Monday', 'last Monday 14:00', 'last Monday 2pm',\n". 31 - " '31 March 2013', '31 Mar', '03/31', '03/31/2013',\n". 32 - "See __http://www.php.net/manual/en/datetime.formats.php__ for more.\n"; 33 - 34 - $args->parseStandardArguments(); 35 - $args->parse( 36 - array( 37 - // what 38 - array( 39 - 'name' => 'revision', 40 - 'wildcard' => true, 41 - ), 42 - array( 43 - 'name' => 'all', 44 - 'param' => 'callsign or phid', 45 - 'help' => 'Reparse all commits in the specified repository. This '. 46 - 'mode queues parsers into the task queue; you must run '. 47 - 'taskmasters to actually do the parses. Use with '. 48 - '__--force-local__ to run the tasks locally instead of '. 49 - 'with taskmasters.', 50 - ), 51 - array( 52 - 'name' => 'min-date', 53 - 'param' => 'date', 54 - 'help' => 'Must be used with __--all__, this will exclude commits '. 55 - 'which are earlier than __date__.'. 56 - "\n".$min_date_usage_examples, 57 - ), 58 - // which parts 59 - array( 60 - 'name' => 'message', 61 - 'help' => 'Reparse commit messages.', 62 - ), 63 - array( 64 - 'name' => 'change', 65 - 'help' => 'Reparse changes.', 66 - ), 67 - array( 68 - 'name' => 'herald', 69 - 'help' => 'Reevaluate Herald rules (may send huge amounts of email!)', 70 - ), 71 - array( 72 - 'name' => 'owners', 73 - 'help' => 'Reevaluate related commits for owners packages (may '. 74 - 'delete existing relationship entries between your '. 75 - 'package and some old commits!)', 76 - ), 77 - array( 78 - 'name' => 'harbormaster', 79 - 'help' => 'EXPERIMENTAL. Execute Harbormaster.', 80 - ), 81 - // misc options 82 - array( 83 - 'name' => 'force', 84 - 'short' => 'f', 85 - 'help' => 'Act noninteractively, without prompting.', 86 - ), 87 - array( 88 - 'name' => 'force-local', 89 - 'help' => 'Only used with __--all__, use this to run the tasks '. 90 - 'locally instead of deferring them to taskmaster daemons.', 91 - ), 92 - )); 93 - 94 - $all_from_repo = $args->getArg('all'); 95 - $reparse_message = $args->getArg('message'); 96 - $reparse_change = $args->getArg('change'); 97 - $reparse_herald = $args->getArg('herald'); 98 - $reparse_owners = $args->getArg('owners'); 99 - $reparse_harbormaster = $args->getArg('harbormaster'); 100 - $reparse_what = $args->getArg('revision'); 101 - $force = $args->getArg('force'); 102 - $force_local = $args->getArg('force-local'); 103 - $min_date = $args->getArg('min-date'); 104 - 105 - if (!$all_from_repo && !$reparse_what) { 106 - usage('Specify a commit or repository to reparse.'); 107 - } 108 - 109 - if ($all_from_repo && $reparse_what) { 110 - $commits = implode(', ', $reparse_what); 111 - usage( 112 - "Specify a commit or repository to reparse, not both:\n". 113 - "All from repo: ".$all_from_repo."\n". 114 - "Commit(s) to reparse: ".$commits); 115 - } 116 - 117 - if (!$reparse_message && !$reparse_change && !$reparse_herald && 118 - !$reparse_owners && !$reparse_harbormaster) { 119 - usage('Specify what information to reparse with --message, --change, '. 120 - '--herald, --harbormaster, and/or --owners'); 121 - } 122 - 123 - $min_timestamp = false; 124 - if ($min_date) { 125 - $min_timestamp = strtotime($min_date); 126 - 127 - if (!$all_from_repo) { 128 - usage( 129 - "You must use --all if you specify --min-date\n". 130 - "e.g.\n". 131 - " ./reparse.php --all TEST --owners --min-date yesterday"); 132 - } 133 - 134 - // previous to PHP 5.1.0 you would compare with -1, instead of false 135 - if (false === $min_timestamp) { 136 - usage( 137 - "Supplied --min-date is not valid\n". 138 - "Supplied value: '".$min_date."'\n". 139 - $min_date_usage_examples); 140 - } 141 - } 142 - 143 - if ($reparse_owners && !$force) { 144 - echo phutil_console_wrap( 145 - 'You are about to recreate the relationship entries between the commits '. 146 - 'and the packages they touch. This might delete some existing '. 147 - 'relationship entries for some old commits.'); 148 - 149 - if (!phutil_console_confirm('Are you ready to continue?')) { 150 - echo "Cancelled.\n"; 151 - exit(1); 152 - } 153 - } 154 - 155 - $commits = array(); 156 - if ($all_from_repo) { 157 - $repository = id(new PhabricatorRepository())->loadOneWhere( 158 - 'callsign = %s OR phid = %s', 159 - $all_from_repo, 160 - $all_from_repo); 161 - if (!$repository) { 162 - throw new Exception("Unknown repository {$all_from_repo}!"); 163 - } 164 - $constraint = ''; 165 - if ($min_timestamp) { 166 - echo "Excluding entries before UNIX timestamp: ".$min_timestamp."\n"; 167 - $table = new PhabricatorRepositoryCommit(); 168 - $conn_r = $table->establishConnection('r'); 169 - $constraint = qsprintf( 170 - $conn_r, 171 - 'AND epoch >= %d', 172 - $min_timestamp); 173 - } 174 - $commits = id(new PhabricatorRepositoryCommit())->loadAllWhere( 175 - 'repositoryID = %d %Q', 176 - $repository->getID(), 177 - $constraint); 178 - $callsign = $repository->getCallsign(); 179 - if (!$commits) { 180 - echo "No commits have been discovered in {$callsign} repository!\n"; 181 - exit; 182 - } 183 - } else { 184 - $commits = array(); 185 - foreach ($reparse_what as $identifier) { 186 - $matches = null; 187 - if (!preg_match('/r([A-Z]+)([a-z0-9]+)/', $identifier, $matches)) { 188 - throw new Exception("Can't parse commit identifier!"); 189 - } 190 - $callsign = $matches[1]; 191 - $commit_identifier = $matches[2]; 192 - $repository = id(new PhabricatorRepository())->loadOneWhere( 193 - 'callsign = %s', 194 - $callsign); 195 - if (!$repository) { 196 - throw new Exception("No repository with callsign '{$callsign}'!"); 197 - } 198 - $commit = id(new PhabricatorRepositoryCommit())->loadOneWhere( 199 - 'repositoryID = %d AND commitIdentifier = %s', 200 - $repository->getID(), 201 - $commit_identifier); 202 - if (!$commit) { 203 - throw new Exception( 204 - "No matching commit '{$commit_identifier}' in repository ". 205 - "'{$callsign}'. (For git and mercurial repositories, you must specify ". 206 - "the entire commit hash.)"); 207 - } 208 - $commits[] = $commit; 209 - } 210 - } 211 - 212 - if ($all_from_repo && !$force_local) { 213 - echo phutil_console_format( 214 - '**NOTE**: This script will queue tasks to reparse the data. Once the '. 215 - 'tasks have been queued, you need to run Taskmaster daemons to execute '. 216 - 'them.'); 217 - echo "\n\n"; 218 - echo "QUEUEING TASKS (".number_format(count($commits))." Commits):\n"; 219 - } 220 - 221 - $progress = new PhutilConsoleProgressBar(); 222 - $progress->setTotal(count($commits)); 223 - 224 - $tasks = array(); 225 - foreach ($commits as $commit) { 226 - $classes = array(); 227 - switch ($repository->getVersionControlSystem()) { 228 - case PhabricatorRepositoryType::REPOSITORY_TYPE_GIT: 229 - if ($reparse_message) { 230 - $classes[] = 'PhabricatorRepositoryGitCommitMessageParserWorker'; 231 - } 232 - if ($reparse_change) { 233 - $classes[] = 'PhabricatorRepositoryGitCommitChangeParserWorker'; 234 - } 235 - break; 236 - case PhabricatorRepositoryType::REPOSITORY_TYPE_MERCURIAL: 237 - if ($reparse_message) { 238 - $classes[] = 'PhabricatorRepositoryMercurialCommitMessageParserWorker'; 239 - } 240 - if ($reparse_change) { 241 - $classes[] = 'PhabricatorRepositoryMercurialCommitChangeParserWorker'; 242 - } 243 - break; 244 - case PhabricatorRepositoryType::REPOSITORY_TYPE_SVN: 245 - if ($reparse_message) { 246 - $classes[] = 'PhabricatorRepositorySvnCommitMessageParserWorker'; 247 - } 248 - if ($reparse_change) { 249 - $classes[] = 'PhabricatorRepositorySvnCommitChangeParserWorker'; 250 - } 251 - break; 252 - } 253 - 254 - if ($reparse_herald) { 255 - $classes[] = 'PhabricatorRepositoryCommitHeraldWorker'; 256 - } 257 - 258 - if ($reparse_owners) { 259 - $classes[] = 'PhabricatorRepositoryCommitOwnersWorker'; 260 - } 261 - 262 - if ($reparse_harbormaster) { 263 - $classes[] = 'HarbormasterRunnerWorker'; 264 - } 265 - 266 - $spec = array( 267 - 'commitID' => $commit->getID(), 268 - 'only' => true, 269 - ); 270 - 271 - if ($all_from_repo && !$force_local) { 272 - foreach ($classes as $class) { 273 - PhabricatorWorker::scheduleTask( 274 - $class, 275 - $spec, 276 - array( 277 - 'priority' => PhabricatorWorker::PRIORITY_IMPORT, 278 - )); 279 - } 280 - } else { 281 - foreach ($classes as $class) { 282 - $worker = newv($class, array($spec)); 283 - $worker->executeTask(); 284 - } 285 - } 286 - 287 - $progress->update(1); 288 - } 289 - 290 - $progress->done(); 291 - 292 - function usage($message) { 293 - echo phutil_console_format( 294 - '**Usage Exception:** '.$message."\n". 295 - "Use __--help__ to display full help\n"); 296 - exit(1); 297 - }
+2
src/__phutil_library_map__.php
··· 2284 2284 'PhabricatorRepositoryManagementParentsWorkflow' => 'applications/repository/management/PhabricatorRepositoryManagementParentsWorkflow.php', 2285 2285 'PhabricatorRepositoryManagementPullWorkflow' => 'applications/repository/management/PhabricatorRepositoryManagementPullWorkflow.php', 2286 2286 'PhabricatorRepositoryManagementRefsWorkflow' => 'applications/repository/management/PhabricatorRepositoryManagementRefsWorkflow.php', 2287 + 'PhabricatorRepositoryManagementReparseWorkflow' => 'applications/repository/management/PhabricatorRepositoryManagementReparseWorkflow.php', 2287 2288 'PhabricatorRepositoryManagementUpdateWorkflow' => 'applications/repository/management/PhabricatorRepositoryManagementUpdateWorkflow.php', 2288 2289 'PhabricatorRepositoryManagementWorkflow' => 'applications/repository/management/PhabricatorRepositoryManagementWorkflow.php', 2289 2290 'PhabricatorRepositoryMercurialCommitChangeParserWorker' => 'applications/repository/worker/commitchangeparser/PhabricatorRepositoryMercurialCommitChangeParserWorker.php', ··· 5524 5525 'PhabricatorRepositoryManagementParentsWorkflow' => 'PhabricatorRepositoryManagementWorkflow', 5525 5526 'PhabricatorRepositoryManagementPullWorkflow' => 'PhabricatorRepositoryManagementWorkflow', 5526 5527 'PhabricatorRepositoryManagementRefsWorkflow' => 'PhabricatorRepositoryManagementWorkflow', 5528 + 'PhabricatorRepositoryManagementReparseWorkflow' => 'PhabricatorRepositoryManagementWorkflow', 5527 5529 'PhabricatorRepositoryManagementUpdateWorkflow' => 'PhabricatorRepositoryManagementWorkflow', 5528 5530 'PhabricatorRepositoryManagementWorkflow' => 'PhabricatorManagementWorkflow', 5529 5531 'PhabricatorRepositoryMercurialCommitChangeParserWorker' => 'PhabricatorRepositoryCommitChangeParserWorker',
+4
src/applications/diffusion/controller/DiffusionCommitEditController.php
··· 67 67 ->setDatasource(new PhabricatorProjectDatasource())); 68 68 69 69 $reason = $data->getCommitDetail('autocloseReason', false); 70 + $reason = PhabricatorRepository::BECAUSE_AUTOCLOSE_FORCED; 70 71 if ($reason !== false) { 71 72 switch ($reason) { 72 73 case PhabricatorRepository::BECAUSE_REPOSITORY_IMPORTING: ··· 77 78 break; 78 79 case PhabricatorRepository::BECAUSE_NOT_ON_AUTOCLOSE_BRANCH: 79 80 $desc = pht('No, Not On Autoclose Branch'); 81 + break; 82 + case PhabricatorRepository::BECAUSE_AUTOCLOSE_FORCED: 83 + $desc = pht('Yes, Forced Via bin/repository CLI Tool.'); 80 84 break; 81 85 case null: 82 86 $desc = pht('Yes');
+309
src/applications/repository/management/PhabricatorRepositoryManagementReparseWorkflow.php
··· 1 + <?php 2 + 3 + final class PhabricatorRepositoryManagementReparseWorkflow 4 + extends PhabricatorRepositoryManagementWorkflow { 5 + 6 + public function didConstruct() { 7 + $this 8 + ->setName('reparse') 9 + ->setExamples('**reparse** [options] __repository__') 10 + ->setSynopsis(pht( 11 + '**reparse** __what__ __which_parts__ [--trace] [--force]'."\n\n". 12 + 'Rerun the Diffusion parser on specific commits and repositories. '. 13 + 'Mostly useful for debugging changes to Diffusion.'."\n\n". 14 + 'e.g. enqueue reparse owners in the TEST repo for all commits:'."\n". 15 + 'repository reparse --all TEST --owners'."\n\n". 16 + 'e.g. do same but exclude before yesterday (local time):'."\n". 17 + 'repository reparse --all TEST --owners --min-date yesterday'."\n". 18 + 'repository reparse --all TEST --owners --min-date "today -1 day".'. 19 + "\n\n". 20 + 'e.g. do same but exclude before 03/31/2013 (local time):'."\n". 21 + 'repository reparse --all TEST --owners --min-date "03/31/2013"')) 22 + ->setArguments( 23 + array( 24 + array( 25 + 'name' => 'revision', 26 + 'wildcard' => true, 27 + ), 28 + array( 29 + 'name' => 'all', 30 + 'param' => 'callsign or phid', 31 + 'help' => pht( 32 + 'Reparse all commits in the specified repository. This mode '. 33 + 'queues parsers into the task queue; you must run taskmasters '. 34 + 'to actually do the parses. Use with __--force-local__ to run '. 35 + 'the tasks locally instead of with taskmasters.'), 36 + ), 37 + array( 38 + 'name' => 'min-date', 39 + 'param' => 'date', 40 + 'help' => pht( 41 + 'Must be used with __--all__, this will exclude commits which '. 42 + 'are earlier than __date__.'."\n". 43 + "Valid examples:\n". 44 + " 'today', 'today 2pm', '-1 hour', '-2 hours', '-24 hours',\n". 45 + " 'yesterday', 'today -1 day', 'yesterday 2pm', '2pm -1 day',\n". 46 + " 'last Monday', 'last Monday 14:00', 'last Monday 2pm',\n". 47 + " '31 March 2013', '31 Mar', '03/31', '03/31/2013',\n". 48 + 'See __http://www.php.net/manual/en/datetime.formats.php__ for '. 49 + 'more.'), 50 + ), 51 + array( 52 + 'name' => 'message', 53 + 'help' => pht('Reparse commit messages.'), 54 + ), 55 + array( 56 + 'name' => 'change', 57 + 'help' => pht('Reparse changes.'), 58 + ), 59 + array( 60 + 'name' => 'herald', 61 + 'help' => pht( 62 + 'Reevaluate Herald rules (may send huge amounts of email!)'), 63 + ), 64 + array( 65 + 'name' => 'owners', 66 + 'help' => pht( 67 + 'Reevaluate related commits for owners packages (may delete '. 68 + 'existing relationship entries between your package and some '. 69 + 'old commits!)'), 70 + ), 71 + array( 72 + 'name' => 'force', 73 + 'short' => 'f', 74 + 'help' => pht('Act noninteractively, without prompting.'), 75 + ), 76 + array( 77 + 'name' => 'force-local', 78 + 'help' => pht( 79 + 'Only used with __--all__, use this to run the tasks locally '. 80 + 'instead of deferring them to taskmaster daemons.'), 81 + ), 82 + array( 83 + 'name' => 'force-autoclose', 84 + 'help' => pht( 85 + 'Only used with __--message__, use this to make sure any '. 86 + 'pertinent diffs are closed regardless of configuration.'), 87 + ), 88 + )); 89 + 90 + } 91 + 92 + public function execute(PhutilArgumentParser $args) { 93 + $console = PhutilConsole::getConsole(); 94 + 95 + $all_from_repo = $args->getArg('all'); 96 + $reparse_message = $args->getArg('message'); 97 + $reparse_change = $args->getArg('change'); 98 + $reparse_herald = $args->getArg('herald'); 99 + $reparse_owners = $args->getArg('owners'); 100 + $reparse_what = $args->getArg('revision'); 101 + $force = $args->getArg('force'); 102 + $force_local = $args->getArg('force-local'); 103 + $min_date = $args->getArg('min-date'); 104 + 105 + if (!$all_from_repo && !$reparse_what) { 106 + throw new PhutilArgumentUsageException( 107 + pht('Specify a commit or repository to reparse.')); 108 + } 109 + 110 + if ($all_from_repo && $reparse_what) { 111 + $commits = implode(', ', $reparse_what); 112 + throw new PhutilArgumentUsageException( 113 + pht( 114 + "Specify a commit or repository to reparse, not both:\n". 115 + "All from repo: %s\n". 116 + "Commit(s) to reparse: %s", 117 + $all_from_repo, 118 + $commits)); 119 + } 120 + 121 + if (!$reparse_message && !$reparse_change && !$reparse_herald && 122 + !$reparse_owners) { 123 + throw new PhutilArgumentUsageException( 124 + pht('Specify what information to reparse with --message, --change, '. 125 + '--herald, and/or --owners')); 126 + } 127 + 128 + $min_timestamp = false; 129 + if ($min_date) { 130 + $min_timestamp = strtotime($min_date); 131 + 132 + if (!$all_from_repo) { 133 + throw new PhutilArgumentUsageException( 134 + pht( 135 + "You must use --all if you specify --min-date\n". 136 + "e.g.\n". 137 + " repository reparse --all TEST --owners --min-date yesterday")); 138 + } 139 + 140 + // previous to PHP 5.1.0 you would compare with -1, instead of false 141 + if (false === $min_timestamp) { 142 + throw new PhutilArgumentUsageException( 143 + pht( 144 + "Supplied --min-date is not valid. See help for valid examples.\n". 145 + "Supplied value: '%s'\n", 146 + $min_date)); 147 + } 148 + } 149 + 150 + if ($reparse_owners && !$force) { 151 + $console->writeOut("%s\n", pht( 152 + 'You are about to recreate the relationship entries between the '. 153 + 'commits and the packages they touch. This might delete some existing '. 154 + 'relationship entries for some old commits.')); 155 + 156 + if (!phutil_console_confirm('Are you ready to continue?')) { 157 + throw new PhutilArgumentUsageException(pht('Cancelled.')); 158 + } 159 + } 160 + 161 + $commits = array(); 162 + if ($all_from_repo) { 163 + $repository = id(new PhabricatorRepository())->loadOneWhere( 164 + 'callsign = %s OR phid = %s', 165 + $all_from_repo, 166 + $all_from_repo); 167 + if (!$repository) { 168 + throw new PhutilArgumentUsageException( 169 + pht('Unknown repository %s!', $all_from_repo)); 170 + } 171 + $constraint = ''; 172 + if ($min_timestamp) { 173 + $console->writeOut("%s\n", pht( 174 + 'Excluding entries before UNIX timestamp: %s', 175 + $min_timestamp)); 176 + $table = new PhabricatorRepositoryCommit(); 177 + $conn_r = $table->establishConnection('r'); 178 + $constraint = qsprintf( 179 + $conn_r, 180 + 'AND epoch >= %d', 181 + $min_timestamp); 182 + } 183 + $commits = id(new PhabricatorRepositoryCommit())->loadAllWhere( 184 + 'repositoryID = %d %Q', 185 + $repository->getID(), 186 + $constraint); 187 + $callsign = $repository->getCallsign(); 188 + if (!$commits) { 189 + throw new PhutilArgumentUsageException(pht( 190 + "No commits have been discovered in %s repository!\n", 191 + $callsign)); 192 + } 193 + } else { 194 + $commits = array(); 195 + foreach ($reparse_what as $identifier) { 196 + $matches = null; 197 + if (!preg_match('/r([A-Z]+)([a-z0-9]+)/', $identifier, $matches)) { 198 + throw new PhutilArgumentUsageException(pht( 199 + "Can't parse commit identifier: %s", 200 + $identifier)); 201 + } 202 + $callsign = $matches[1]; 203 + $commit_identifier = $matches[2]; 204 + $repository = id(new PhabricatorRepository())->loadOneWhere( 205 + 'callsign = %s', 206 + $callsign); 207 + if (!$repository) { 208 + throw new PhutilArgumentUsageException(pht( 209 + "No repository with callsign '%s'!", 210 + $callsign)); 211 + } 212 + $commit = id(new PhabricatorRepositoryCommit())->loadOneWhere( 213 + 'repositoryID = %d AND commitIdentifier = %s', 214 + $repository->getID(), 215 + $commit_identifier); 216 + if (!$commit) { 217 + throw new PhutilArgumentUsageException(pht( 218 + "No matching commit '%s' in repository '%s'. ". 219 + "(For git and mercurial repositories, you must specify the entire ". 220 + "commit hash.)", 221 + $commit_identifier, 222 + $callsign)); 223 + } 224 + $commits[] = $commit; 225 + } 226 + } 227 + 228 + if ($all_from_repo && !$force_local) { 229 + $console->writeOut("%s\n", pht( 230 + '**NOTE**: This script will queue tasks to reparse the data. Once the '. 231 + 'tasks have been queued, you need to run Taskmaster daemons to '. 232 + 'execute them.'."\n\n". 233 + "QUEUEING TASKS (%d Commits):", 234 + number_format(count($commits)))); 235 + } 236 + 237 + $progress = new PhutilConsoleProgressBar(); 238 + $progress->setTotal(count($commits)); 239 + 240 + $tasks = array(); 241 + foreach ($commits as $commit) { 242 + $classes = array(); 243 + switch ($repository->getVersionControlSystem()) { 244 + case PhabricatorRepositoryType::REPOSITORY_TYPE_GIT: 245 + if ($reparse_message) { 246 + $classes[] = 'PhabricatorRepositoryGitCommitMessageParserWorker'; 247 + } 248 + if ($reparse_change) { 249 + $classes[] = 'PhabricatorRepositoryGitCommitChangeParserWorker'; 250 + } 251 + break; 252 + case PhabricatorRepositoryType::REPOSITORY_TYPE_MERCURIAL: 253 + if ($reparse_message) { 254 + $classes[] = 255 + 'PhabricatorRepositoryMercurialCommitMessageParserWorker'; 256 + } 257 + if ($reparse_change) { 258 + $classes[] = 'PhabricatorRepositoryMercurialCommitChangeParserWorker'; 259 + } 260 + break; 261 + case PhabricatorRepositoryType::REPOSITORY_TYPE_SVN: 262 + if ($reparse_message) { 263 + $classes[] = 'PhabricatorRepositorySvnCommitMessageParserWorker'; 264 + } 265 + if ($reparse_change) { 266 + $classes[] = 'PhabricatorRepositorySvnCommitChangeParserWorker'; 267 + } 268 + break; 269 + } 270 + 271 + if ($reparse_herald) { 272 + $classes[] = 'PhabricatorRepositoryCommitHeraldWorker'; 273 + } 274 + 275 + if ($reparse_owners) { 276 + $classes[] = 'PhabricatorRepositoryCommitOwnersWorker'; 277 + } 278 + 279 + $spec = array( 280 + 'commitID' => $commit->getID(), 281 + 'only' => true, 282 + 'forceAutoclose' => $args->getArg('force-autoclose'), 283 + ); 284 + 285 + if ($all_from_repo && !$force_local) { 286 + foreach ($classes as $class) { 287 + PhabricatorWorker::scheduleTask( 288 + $class, 289 + $spec, 290 + array( 291 + 'priority' => PhabricatorWorker::PRIORITY_IMPORT, 292 + )); 293 + } 294 + } else { 295 + foreach ($classes as $class) { 296 + $worker = newv($class, array($spec)); 297 + $worker->executeTask(); 298 + } 299 + } 300 + 301 + $progress->update(1); 302 + } 303 + 304 + $progress->done(); 305 + 306 + return 0; 307 + } 308 + 309 + }
+1
src/applications/repository/storage/PhabricatorRepository.php
··· 41 41 const BECAUSE_NOT_ON_AUTOCLOSE_BRANCH = 'auto/nobranch'; 42 42 const BECAUSE_BRANCH_UNTRACKED = 'auto/notrack'; 43 43 const BECAUSE_BRANCH_NOT_AUTOCLOSE = 'auto/noclose'; 44 + const BECAUSE_AUTOCLOSE_FORCED = 'auto/forced'; 44 45 45 46 protected $name; 46 47 protected $callsign;
+8 -2
src/applications/repository/worker/commitmessageparser/PhabricatorRepositoryCommitMessageParserWorker.php
··· 84 84 // aren't. Autoclose can be disabled for various reasons at the repository 85 85 // or commit levels. 86 86 87 - $autoclose_reason = $repository->shouldSkipAutocloseCommit($commit); 87 + $force_autoclose = idx($this->getTaskData(), 'forceAutoclose', false); 88 + if ($force_autoclose) { 89 + $autoclose_reason = $repository::BECAUSE_AUTOCLOSE_FORCED; 90 + } else { 91 + $autoclose_reason = $repository->shouldSkipAutocloseCommit($commit); 92 + } 88 93 $data->setCommitDetail('autocloseReason', $autoclose_reason); 89 - $should_autoclose = $repository->shouldAutocloseCommit($commit); 94 + $should_autoclose = $force_autoclose || 95 + $repository->shouldAutocloseCommit($commit); 90 96 91 97 92 98 // When updating related objects, we'll act under an omnipotent user to