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

Reduce the total number of calls to getCallsign()

Summary: Ref T4245. Before doing any hard work here, we can dramatically reduce the number of things that make calls to `getCallsign()` to make navigating things easier. Almost all of them only care about a monogram, URI, or display name.

Test Plan:
- Searched for `r uniquename` in jump nav.
- Ran `bin/repository reparse --change rXXXyyyyy --trace`, observed query against bad commit table.
- Ran `bin/search index rXXXyyyy --trace --force`, observed proper title when indexing commit.
- Browed repository list, saw proper `rXXX` and appropriate link targets.
- Mentioned `rXXX` in Remarkup, got a link to the right place.

Reviewers: chad

Reviewed By: chad

Maniphest Tasks: T4245

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

+35 -35
+2 -1
src/applications/repository/phid/PhabricatorRepositoryRepositoryPHIDType.php
··· 40 40 $monogram = $repository->getMonogram(); 41 41 $callsign = $repository->getCallsign(); 42 42 $name = $repository->getName(); 43 + $uri = $repository->getURI(); 43 44 44 45 $handle->setName($monogram); 45 46 $handle->setFullName("{$monogram} {$name}"); 46 - $handle->setURI("/diffusion/{$callsign}/"); 47 + $handle->setURI($uri); 47 48 } 48 49 } 49 50
+5 -5
src/applications/repository/query/PhabricatorRepositorySearchEngine.php
··· 155 155 ->setUser($viewer) 156 156 ->setObject($repository) 157 157 ->setHeader($repository->getName()) 158 - ->setObjectName('r'.$repository->getCallsign()) 159 - ->setHref($this->getApplicationURI($repository->getCallsign().'/')); 158 + ->setObjectName($repository->getMonogram()) 159 + ->setHref($repository->getURI()); 160 160 161 161 $commit = $repository->getMostRecentCommit(); 162 162 if ($commit) { 163 163 $commit_link = DiffusionView::linkCommit( 164 - $repository, 165 - $commit->getCommitIdentifier(), 166 - $commit->getSummary()); 164 + $repository, 165 + $commit->getCommitIdentifier(), 166 + $commit->getSummary()); 167 167 $item->setSubhead($commit_link); 168 168 $item->setEpoch($commit->getEpoch()); 169 169 }
+4 -2
src/applications/repository/search/DiffusionCommitFulltextEngine.php
··· 20 20 $commit_message = $commit_data->getCommitMessage(); 21 21 $author_phid = $commit_data->getCommitDetail('authorPHID'); 22 22 23 - $title = 'r'.$repository->getCallsign().$commit->getCommitIdentifier(). 24 - ' '.$commit_data->getSummary(); 23 + $monogram = $commit->getMonogram(); 24 + $summary = $commit_data->getSummary(); 25 + 26 + $title = "{$monogram} {$summary}"; 25 27 26 28 $document 27 29 ->setDocumentCreated($date_created)
+9 -4
src/applications/repository/storage/PhabricatorRepositoryCommit.php
··· 203 203 } 204 204 205 205 public function getURI() { 206 - $repository = $this->getRepository(); 207 - $callsign = $repository->getCallsign(); 208 - $commit_identifier = $this->getCommitIdentifier(); 209 - return '/r'.$callsign.$commit_identifier; 206 + return '/'.$this->getMonogram(); 210 207 } 211 208 212 209 /** ··· 249 246 } 250 247 251 248 return $this->setAuditStatus($status); 249 + } 250 + 251 + public function getMonogram() { 252 + $repository = $this->getRepository(); 253 + $callsign = $repository->getCallsign(); 254 + $identifier = $this->getCommitIdentifier(); 255 + 256 + return "r{$callsign}{$identifier}"; 252 257 } 253 258 254 259
+12 -16
src/applications/repository/worker/PhabricatorRepositoryCommitParserWorker.php
··· 17 17 pht('No "%s" in task data.', 'commitID')); 18 18 } 19 19 20 - $commit = id(new PhabricatorRepositoryCommit())->load($commit_id); 21 - 20 + $commit = id(new DiffusionCommitQuery()) 21 + ->setViewer(PhabricatorUser::getOmnipotentUser()) 22 + ->withIDs(array($commit_id)) 23 + ->executeOne(); 22 24 if (!$commit) { 23 25 throw new PhabricatorWorkerPermanentFailureException( 24 26 pht('Commit "%s" does not exist.', $commit_id)); 25 27 } 26 28 27 - return $this->commit = $commit; 29 + $this->commit = $commit; 30 + 31 + return $commit; 28 32 } 29 33 30 34 final protected function doWork() { 31 - if (!$this->loadCommit()) { 32 - return; 33 - } 34 - 35 - $repository = id(new PhabricatorRepositoryQuery()) 36 - ->setViewer(PhabricatorUser::getOmnipotentUser()) 37 - ->withIDs(array($this->commit->getRepositoryID())) 38 - ->executeOne(); 39 - if (!$repository) { 40 - return; 41 - } 35 + $commit = $this->loadCommit(); 36 + $repository = $commit->getRepository(); 42 37 43 38 $this->repository = $repository; 39 + 44 40 $this->parseCommit($repository, $this->commit); 45 41 } 46 42 ··· 52 48 PhabricatorRepository $repository, 53 49 PhabricatorRepositoryCommit $commit); 54 50 55 - protected function isBadCommit($full_commit_name) { 51 + protected function isBadCommit(PhabricatorRepositoryCommit $commit) { 56 52 $repository = new PhabricatorRepository(); 57 53 58 54 $bad_commit = queryfx_one( 59 55 $repository->establishConnection('w'), 60 56 'SELECT * FROM %T WHERE fullCommitName = %s', 61 57 PhabricatorRepository::TABLE_BADCOMMIT, 62 - $full_commit_name); 58 + $commit->getMonogram()); 63 59 64 60 return (bool)$bad_commit; 65 61 }
+2 -6
src/applications/repository/worker/commitchangeparser/PhabricatorRepositoryCommitChangeParserWorker.php
··· 17 17 PhabricatorRepository $repository, 18 18 PhabricatorRepositoryCommit $commit) { 19 19 20 - $identifier = $commit->getCommitIdentifier(); 21 - $callsign = $repository->getCallsign(); 22 - $full_name = 'r'.$callsign.$identifier; 23 - 24 - $this->log("%s\n", pht('Parsing %s...', $full_name)); 25 - if ($this->isBadCommit($full_name)) { 20 + $this->log("%s\n", pht('Parsing "%s"...', $commit->getMonogram())); 21 + if ($this->isBadCommit($commit)) { 26 22 $this->log(pht('This commit is marked bad!')); 27 23 return; 28 24 }
+1 -1
src/applications/search/engine/PhabricatorJumpNavHandler.php
··· 57 57 ->execute(); 58 58 if (count($repositories) == 1) { 59 59 // Just one match, jump to repository. 60 - $uri = '/diffusion/'.head($repositories)->getCallsign().'/'; 60 + $uri = head($repositories)->getURI(); 61 61 } else { 62 62 // More than one match, jump to search. 63 63 $uri = urisprintf('/diffusion/?order=name&name=%s', $name);