Changeset View
Changeset View
Standalone View
Standalone View
src/applications/diffusion/editor/DiffusionURIEditor.php
Show First 20 Lines • Show All 456 Lines • ▼ Show 20 Lines | protected function applyFinalEffects( | ||||
// URI. | // URI. | ||||
$repository = $object->getRepository(); | $repository = $object->getRepository(); | ||||
$uris = id(new PhabricatorRepositoryURIQuery()) | $uris = id(new PhabricatorRepositoryURIQuery()) | ||||
->setViewer(PhabricatorUser::getOmnipotentUser()) | ->setViewer(PhabricatorUser::getOmnipotentUser()) | ||||
->withRepositories(array($repository)) | ->withRepositories(array($repository)) | ||||
->execute(); | ->execute(); | ||||
// Reattach the current URIs to the repository: we're going to rebuild | |||||
// the index explicitly below, and want to include any changes made to | |||||
// this URI in the index update. | |||||
$repository->attachURIs($uris); | |||||
$observe_uri = null; | $observe_uri = null; | ||||
foreach ($uris as $uri) { | foreach ($uris as $uri) { | ||||
if ($uri->getIoType() != PhabricatorRepositoryURI::IO_OBSERVE) { | if ($uri->getIoType() != PhabricatorRepositoryURI::IO_OBSERVE) { | ||||
continue; | continue; | ||||
} | } | ||||
$observe_uri = $uri; | $observe_uri = $uri; | ||||
break; | break; | ||||
Show All 10 Lines | if ($observe_uri) { | ||||
$repository | $repository | ||||
->setHosted(true) | ->setHosted(true) | ||||
->setDetail('remote-uri', null) | ->setDetail('remote-uri', null) | ||||
->setCredentialPHID(null); | ->setCredentialPHID(null); | ||||
} | } | ||||
$repository->save(); | $repository->save(); | ||||
// Explicitly update the URI index. | |||||
$repository->updateURIIndex(); | |||||
$is_hosted = $repository->isHosted(); | $is_hosted = $repository->isHosted(); | ||||
// If we've swapped the repository from hosted to observed or vice versa, | // If we've swapped the repository from hosted to observed or vice versa, | ||||
// reset all the cluster version clocks. | // reset all the cluster version clocks. | ||||
if ($was_hosted != $is_hosted) { | if ($was_hosted != $is_hosted) { | ||||
$cluster_engine = id(new DiffusionRepositoryClusterEngine()) | $cluster_engine = id(new DiffusionRepositoryClusterEngine()) | ||||
->setViewer($this->getActor()) | ->setViewer($this->getActor()) | ||||
->setRepository($repository) | ->setRepository($repository) | ||||
->synchronizeWorkingCopyAfterHostingChange(); | ->synchronizeWorkingCopyAfterHostingChange(); | ||||
} | } | ||||
return $xactions; | return $xactions; | ||||
} | } | ||||
} | } |