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

Remove nonfunctional/obsolete 'reconcile.php'

Summary: Ref T4780. This no longer works and barely ever worked. T4237 is now the relevant task.

Test Plan: Grepped for `reconcile.php`

Reviewers: btrahan

Reviewed By: btrahan

Subscribers: epriestley

Maniphest Tasks: T4780

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

-152
-152
scripts/repository/reconcile.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->setTagline('reconcile Phabricator state after repository changes'); 9 - $args->setSynopsis(<<<EOSYNOPSIS 10 - **reconcile.php** __repository_callsign__ 11 - Reconcile the state of Phabricator's caches with the actual state 12 - of the repository. 13 - 14 - This is an administrative/maintenace operation and not generally 15 - necessary, but if repository history has changed or been rewritten 16 - (for example, if the repository was stored from a backup) 17 - Phabricator may think commits which are no longer present in the 18 - repository still exist. 19 - 20 - This will delete all evidence of commits which Phabricator can't 21 - find in the actual repository. 22 - 23 - EOSYNOPSIS 24 - ); 25 - $args->parseStandardArguments(); 26 - $args->parse( 27 - array( 28 - array( 29 - 'name' => 'more', 30 - 'wildcard' => true, 31 - ), 32 - )); 33 - 34 - $more = $args->getArg('more'); 35 - if (count($more) !== 1) { 36 - $args->printHelpAndExit(); 37 - } 38 - $callsign = reset($more); 39 - 40 - 41 - $repository = id(new PhabricatorRepository())->loadOneWhere( 42 - 'callsign = %s', 43 - $callsign); 44 - if (!$repository) { 45 - throw new Exception("No repository exists with callsign '{$callsign}'!"); 46 - } 47 - 48 - switch ($repository->getVersionControlSystem()) { 49 - case PhabricatorRepositoryType::REPOSITORY_TYPE_GIT: 50 - break; 51 - case PhabricatorRepositoryType::REPOSITORY_TYPE_SVN: 52 - case PhabricatorRepositoryType::REPOSITORY_TYPE_MERCURIAL: 53 - default: 54 - throw new Exception("For now, you can only reconcile git repositories."); 55 - } 56 - 57 - echo "Loading commits...\n"; 58 - $all_commits = id(new PhabricatorRepositoryCommit())->loadAllWhere( 59 - 'repositoryID = %d', 60 - $repository->getID()); 61 - 62 - echo "Updating repository..\n"; 63 - try { 64 - // Sanity-check the repository working copy and make sure we're up to date. 65 - $repository->execxLocalCommand('fetch --all'); 66 - } catch (Exception $ex) { 67 - echo "Unable to `git fetch` the working copy to update it. Reconciliation ". 68 - "requires an up-to-date working copy.\n"; 69 - throw $ex; 70 - } 71 - 72 - echo "Verifying commits (this may take some time if the repository is large)"; 73 - $futures = array(); 74 - foreach ($all_commits as $id => $commit) { 75 - // NOTE: We use "cat-file -t", not "rev-parse --verify", because 76 - // "rev-parse --verify" does not verify that the object actually exists, only 77 - // that the name is properly formatted. 78 - $futures[$id] = $repository->getLocalCommandFuture( 79 - 'cat-file -t %s', 80 - $commit->getCommitIdentifier()); 81 - } 82 - 83 - $bad = array(); 84 - foreach (Futures($futures)->limit(8) as $id => $future) { 85 - list($err) = $future->resolve(); 86 - if ($err) { 87 - $bad[$id] = $all_commits[$id]; 88 - echo "#"; 89 - } else { 90 - echo "."; 91 - } 92 - } 93 - echo "\nDone.\n"; 94 - 95 - if (!count($bad)) { 96 - echo "No bad commits found!\n"; 97 - } else { 98 - echo "Found ".count($bad)." bad commits:\n\n"; 99 - echo ' '.implode("\n ", mpull($bad, 'getCommitIdentifier')); 100 - $ok = phutil_console_confirm("Do you want to delete these commits?"); 101 - if (!$ok) { 102 - echo "OK, aborting.\n"; 103 - exit(1); 104 - } 105 - 106 - echo "Deleting commits"; 107 - foreach ($bad as $commit) { 108 - echo "."; 109 - $commit->delete(); 110 - } 111 - echo "\nDone.\n"; 112 - } 113 - 114 - //// Clean Up Links //////////////////////////////////////////////////////// 115 - 116 - $table = new PhabricatorRepositoryCommit(); 117 - 118 - $valid_phids = queryfx_all( 119 - $table->establishConnection('r'), 120 - 'SELECT phid FROM %T', 121 - $table->getTableName()); 122 - $valid_phids = ipull($valid_phids, null, 'phid'); 123 - 124 - //////// Differential <-> Diffusion Links ////////////////////////////////// 125 - 126 - $dx_conn = id(new DifferentialRevision())->establishConnection('w'); 127 - $dx_table = DifferentialRevision::TABLE_COMMIT; 128 - $dx_phids = queryfx_all( 129 - $dx_conn, 130 - 'SELECT commitPHID FROM %T', 131 - $dx_table); 132 - 133 - $bad_phids = array(); 134 - foreach ($dx_phids as $dx_phid) { 135 - if (empty($valid_phids[$dx_phid['commitPHID']])) { 136 - $bad_phids[] = $dx_phid['commitPHID']; 137 - } 138 - } 139 - 140 - if ($bad_phids) { 141 - echo "Deleting ".count($bad_phids)." bad Diffusion links...\n"; 142 - queryfx( 143 - $dx_conn, 144 - 'DELETE FROM %T WHERE commitPHID IN (%Ls)', 145 - $dx_table, 146 - $bad_phids); 147 - echo "Done.\n"; 148 - } else { 149 - echo "Diffusion links are clean.\n"; 150 - } 151 - 152 - // TODO: There are some links in owners that we should probably clean up too.