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

When a commit has a "rewritten" hint, show it in the UI instead of the generic "deleted" message

Summary:
Ref T11522. When a commit is no longer reachable from any branch/tag, we currently show a "this has been deleted" message.

Instead, go further: check if there is a "rewritten" hint pointing at a commit the current commit was rewritten into. If we find one, show a message about that instead.

(This isn't super pretty, just getting it working for now. I expect to revisit this UI in T9713 if we don't get to it before that.)

Test Plan: {F1780703}

Reviewers: chad

Reviewed By: chad

Maniphest Tasks: T11522

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

+71 -33
+67 -33
src/applications/diffusion/controller/DiffusionCommitController.php
··· 73 73 $commit_data = $commit->getCommitData(); 74 74 $is_foreign = $commit_data->getCommitDetail('foreign-svn-stub'); 75 75 $error_panel = null; 76 + 77 + $hard_limit = 1000; 78 + 79 + if ($commit->isImported()) { 80 + $change_query = DiffusionPathChangeQuery::newFromDiffusionRequest( 81 + $drequest); 82 + $change_query->setLimit($hard_limit + 1); 83 + $changes = $change_query->loadChanges(); 84 + } else { 85 + $changes = array(); 86 + } 87 + 88 + $was_limited = (count($changes) > $hard_limit); 89 + if ($was_limited) { 90 + $changes = array_slice($changes, 0, $hard_limit); 91 + } 92 + 93 + $count = count($changes); 94 + 95 + $is_unreadable = false; 96 + $hint = null; 97 + if (!$count || $commit->isUnreachable()) { 98 + $hint = id(new DiffusionCommitHintQuery()) 99 + ->setViewer($viewer) 100 + ->withRepositoryPHIDs(array($repository->getPHID())) 101 + ->withOldCommitIdentifiers(array($commit->getCommitIdentifier())) 102 + ->executeOne(); 103 + if ($hint) { 104 + $is_unreadable = $hint->isUnreadable(); 105 + } 106 + } 107 + 76 108 if ($is_foreign) { 77 109 $subpath = $commit_data->getCommitDetail('svn-subpath'); 78 110 ··· 130 162 $message)); 131 163 132 164 if ($commit->isUnreachable()) { 133 - $this->commitErrors[] = pht( 134 - 'This commit has been deleted in the repository: it is no longer '. 135 - 'reachable from any branch, tag, or ref.'); 165 + $did_rewrite = false; 166 + if ($hint) { 167 + if ($hint->isRewritten()) { 168 + $rewritten = id(new DiffusionCommitQuery()) 169 + ->setViewer($viewer) 170 + ->withRepository($repository) 171 + ->withIdentifiers(array($hint->getNewCommitIdentifier())) 172 + ->executeOne(); 173 + if ($rewritten) { 174 + $did_rewrite = true; 175 + $rewritten_uri = $rewritten->getURI(); 176 + $rewritten_name = $rewritten->getLocalName(); 177 + 178 + $rewritten_link = phutil_tag( 179 + 'a', 180 + array( 181 + 'href' => $rewritten_uri, 182 + ), 183 + $rewritten_name); 184 + 185 + $this->commitErrors[] = pht( 186 + 'This commit was rewritten after it was published, which '. 187 + 'changed the commit hash. This old version of the commit is '. 188 + 'no longer reachable from any branch, tag or ref. The new '. 189 + 'version of this commit is %s.', 190 + $rewritten_link); 191 + } 192 + } 193 + } 194 + 195 + if (!$did_rewrite) { 196 + $this->commitErrors[] = pht( 197 + 'This commit has been deleted in the repository: it is no longer '. 198 + 'reachable from any branch, tag, or ref.'); 199 + } 136 200 } 137 201 138 202 if ($this->getCommitErrors()) { ··· 143 207 } 144 208 145 209 $timeline = $this->buildComments($commit); 146 - $hard_limit = 1000; 147 - 148 - if ($commit->isImported()) { 149 - $change_query = DiffusionPathChangeQuery::newFromDiffusionRequest( 150 - $drequest); 151 - $change_query->setLimit($hard_limit + 1); 152 - $changes = $change_query->loadChanges(); 153 - } else { 154 - $changes = array(); 155 - } 156 - 157 - $was_limited = (count($changes) > $hard_limit); 158 - if ($was_limited) { 159 - $changes = array_slice($changes, 0, $hard_limit); 160 - } 161 - 162 210 $merge_table = $this->buildMergesTable($commit); 163 211 164 212 $highlighted_audits = $commit->getAuthorityAudits( 165 213 $viewer, 166 214 $this->auditAuthorityPHIDs); 167 - 168 - $count = count($changes); 169 - 170 - $is_unreadable = false; 171 - if (!$count) { 172 - $hint = id(new DiffusionCommitHintQuery()) 173 - ->setViewer($viewer) 174 - ->withRepositoryPHIDs(array($repository->getPHID())) 175 - ->withOldCommitIdentifiers(array($commit->getCommitIdentifier())) 176 - ->executeOne(); 177 - if ($hint) { 178 - $is_unreadable = $hint->isUnreadable(); 179 - } 180 - } 181 215 182 216 $show_changesets = false; 183 217 $info_panel = null;
+4
src/applications/repository/storage/PhabricatorRepositoryCommitHint.php
··· 105 105 return ($this->getHintType() == self::HINT_UNREADABLE); 106 106 } 107 107 108 + public function isRewritten() { 109 + return ($this->getHintType() == self::HINT_REWRITTEN); 110 + } 111 + 108 112 109 113 /* -( PhabricatorPolicyInterface )----------------------------------------- */ 110 114