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

Make Herald less ambitious about resolving repositories for revisions

Summary:
Fixes T4636. If a user manually deletes a "repository" setting from a revision, Herald attempts to resolve it. Instead, Herald should now just trust Differential. Generally, the new logic is:

- When diffs are created, figure out repository information.
- When revisions are updated, copy info from diffs.
- Everywhere else, just trust the revision field.

Test Plan:
- Created revisions.
- Used Herald to dry-run revisions before and after a manual edit to remove the repository setting.

Reviewers: btrahan

Reviewed By: btrahan

Subscribers: epriestley

Maniphest Tasks: T4636

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

+22 -22
+19 -2
src/applications/differential/conduit/ConduitAPI_differential_creatediff_Method.php
··· 40 40 } 41 41 42 42 protected function execute(ConduitAPIRequest $request) { 43 + $viewer = $request->getUser(); 43 44 $change_data = $request->getValue('changes'); 44 45 45 46 $changes = array(); ··· 53 54 54 55 $diff->setBranch($request->getValue('branch')); 55 56 $diff->setCreationMethod($request->getValue('creationMethod')); 56 - $diff->setAuthorPHID($request->getUser()->getPHID()); 57 + $diff->setAuthorPHID($viewer->getPHID()); 57 58 $diff->setBookmark($request->getValue('bookmark')); 58 59 59 60 // TODO: Remove this eventually; for now continue writing the UUID. Note ··· 64 65 $repository_phid = $request->getValue('repositoryPHID'); 65 66 if ($repository_phid) { 66 67 $repository = id(new PhabricatorRepositoryQuery()) 67 - ->setViewer($request->getUser()) 68 + ->setViewer($viewer) 68 69 ->withPHIDs(array($repository_phid)) 69 70 ->executeOne(); 70 71 if ($repository) { ··· 141 142 } 142 143 143 144 $diff->save(); 145 + 146 + // If we didn't get an explicit `repositoryPHID` (which means the client is 147 + // old, or couldn't figure out which repository the working copy belongs 148 + // to), apply heuristics to try to figure it out. 149 + 150 + if (!$repository_phid) { 151 + $repository = id(new DifferentialRepositoryLookup()) 152 + ->setDiff($diff) 153 + ->setViewer($viewer) 154 + ->lookupRepository(); 155 + if ($repository) { 156 + $diff->setRepositoryPHID($repository->getPHID()); 157 + $diff->setRepositoryUUID($repository->getUUID()); 158 + $diff->save(); 159 + } 160 + } 144 161 145 162 $path = '/differential/diff/'.$diff->getID().'/'; 146 163 $uri = PhabricatorEnv::getURI($path);
+1
src/applications/differential/editor/DifferentialTransactionEditor.php
··· 498 498 499 499 $object->setLineCount($diff->getLineCount()); 500 500 $object->setRepositoryPHID($diff->getRepositoryPHID()); 501 + $object->setArcanistProjectPHID($diff->getArcanistProjectPHID()); 501 502 502 503 return; 503 504 }
+2 -20
src/applications/herald/adapter/HeraldDifferentialRevisionAdapter.php
··· 157 157 public function loadRepository() { 158 158 if ($this->repository === null) { 159 159 $this->repository = false; 160 - 161 - $viewer = PhabricatorUser::getOmnipotentUser(); 162 - $repository_phid = null; 163 - 164 - $revision = $this->revision; 165 - if ($revision->getRepositoryPHID()) { 166 - $repository_phid = $revision->getRepositoryPHID(); 167 - } else { 168 - $repository = id(new DifferentialRepositoryLookup()) 169 - ->setViewer($viewer) 170 - ->setDiff($this->diff) 171 - ->lookupRepository(); 172 - if ($repository) { 173 - // We want to get the projects for this repository too, so run a 174 - // full query for it below. 175 - $repository_phid = $repository->getPHID(); 176 - } 177 - } 178 - 160 + $repository_phid = $this->getObject()->getRepositoryPHID(); 179 161 if ($repository_phid) { 180 162 $repository = id(new PhabricatorRepositoryQuery()) 181 - ->setViewer($viewer) 163 + ->setViewer(PhabricatorUser::getOmnipotentUser()) 182 164 ->withPHIDs(array($repository_phid)) 183 165 ->needProjectPHIDs(true) 184 166 ->executeOne();