1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-09-20 01:08:50 +02:00

Remove calls to getCallsign() from repository daemons

Summary: Ref T4245. These are all descriptive or UI-facing.

Test Plan:
- Ran `bin/repository pull ...` with various identifiers.
- Ran `bin/repository mirror ...` with various identifiers.
- Ran `bin/repository discover ...` with various identifiers.
- Ran `bin/phd debug pull X Y --not Z` with various identifiers.

Reviewers: chad

Reviewed By: chad

Maniphest Tasks: T4245

Differential Revision: https://secure.phabricator.com/D14926
This commit is contained in:
epriestley 2016-01-02 05:53:55 -08:00
parent 1b4f5e38ce
commit d9e034f02c
4 changed files with 44 additions and 30 deletions

View file

@ -6,7 +6,7 @@
*
* By default, the daemon pulls **every** repository. If you want it to be
* responsible for only some repositories, you can launch it with a list of
* PHIDs or callsigns:
* repositories:
*
* ./phd launch repositorypulllocal -- X Q Z
*
@ -228,9 +228,8 @@ final class PhabricatorRepositoryPullLocalDaemon
$flags[] = '--no-discovery';
}
$callsign = $repository->getCallsign();
$future = new ExecFuture('%s update %Ls -- %s', $bin, $flags, $callsign);
$monogram = $repository->getMonogram();
$future = new ExecFuture('%s update %Ls -- %s', $bin, $flags, $monogram);
// Sometimes, the underlying VCS commands will hang indefinitely. We've
// observed this occasionally with GitHub, and other users have observed
@ -303,30 +302,44 @@ final class PhabricatorRepositoryPullLocalDaemon
->setViewer($this->getViewer());
if ($include) {
$query->withCallsigns($include);
$query->withIdentifiers($include);
}
$repositories = $query->execute();
$repositories = mpull($repositories, null, 'getPHID');
if ($include) {
$by_callsign = mpull($repositories, null, 'getCallsign');
foreach ($include as $name) {
if (empty($by_callsign[$name])) {
$map = $query->getIdentifierMap();
foreach ($include as $identifier) {
if (empty($map[$identifier])) {
throw new Exception(
pht(
"No repository exists with callsign '%s'!",
$name));
'No repository "%s" exists!',
$identifier));
}
}
}
if ($exclude) {
$exclude = array_fuse($exclude);
foreach ($repositories as $key => $repository) {
if (isset($exclude[$repository->getCallsign()])) {
unset($repositories[$key]);
$xquery = id(new PhabricatorRepositoryQuery())
->setViewer($this->getViewer())
->withIdentifiers($exclude);
$excluded_repos = $xquery->execute();
$xmap = $xquery->getIdentifierMap();
foreach ($exclude as $identifier) {
if (empty($xmap[$identifier])) {
throw new Exception(
pht(
'No repository "%s" exists!',
$identifier));
}
}
foreach ($excluded_repos as $excluded_repo) {
unset($repositories[$excluded_repo->getPHID()]);
}
}
foreach ($repositories as $key => $repository) {

View file

@ -100,8 +100,8 @@ final class PhabricatorRepositoryDiscoveryEngine
$this->log(
pht(
'Discovering commits in repository %s.',
$repository->getCallsign()));
'Discovering commits in repository "%s".',
$repository->getDisplayName()));
$this->fillCommitCache(array_values($branches));
@ -244,7 +244,7 @@ final class PhabricatorRepositoryDiscoveryEngine
'configured URI is "%s". To resolve this error, set the remote URI '.
'to point at the repository root. If you want to import only part '.
'of a Subversion repository, use the "Import Only" option.',
$repository->getCallsign(),
$repository->getDisplayName(),
$remote_root,
$expect_root));
}

View file

@ -37,7 +37,7 @@ final class PhabricatorRepositoryMirrorEngine
throw new PhutilAggregateException(
pht(
'Exceptions occurred while mirroring the "%s" repository.',
$repository->getCallsign()),
$repository->getDisplayName()),
$exceptions);
}
}

View file

@ -29,7 +29,6 @@ final class PhabricatorRepositoryPullEngine
$is_svn = false;
$vcs = $repository->getVersionControlSystem();
$callsign = $repository->getCallsign();
switch ($vcs) {
case PhabricatorRepositoryType::REPOSITORY_TYPE_SVN:
@ -37,9 +36,9 @@ final class PhabricatorRepositoryPullEngine
if (!$repository->isHosted()) {
$this->skipPull(
pht(
"Repository '%s' is a non-hosted Subversion repository, which ".
"does not require a local working copy to be pulled.",
$callsign));
'Repository "%s" is a non-hosted Subversion repository, which '.
'does not require a local working copy to be pulled.',
$repository->getDisplayName()));
return;
}
$is_svn = true;
@ -55,13 +54,12 @@ final class PhabricatorRepositoryPullEngine
break;
}
$callsign = $repository->getCallsign();
$local_path = $repository->getLocalPath();
if ($local_path === null) {
$this->abortPull(
pht(
"No local path is configured for repository '%s'.",
$callsign));
'No local path is configured for repository "%s".',
$repository->getDisplayName()));
}
try {
@ -73,8 +71,8 @@ final class PhabricatorRepositoryPullEngine
if (!Filesystem::pathExists($local_path)) {
$this->logPull(
pht(
"Creating a new working copy for repository '%s'.",
$callsign));
'Creating a new working copy for repository "%s".',
$repository->getDisplayName()));
if ($is_git) {
$this->executeGitCreate();
} else if ($is_hg) {
@ -86,8 +84,8 @@ final class PhabricatorRepositoryPullEngine
if (!$repository->isHosted()) {
$this->logPull(
pht(
"Updating the working copy for repository '%s'.",
$callsign));
'Updating the working copy for repository "%s".',
$repository->getDisplayName()));
if ($is_git) {
$this->verifyGitOrigin($repository);
$this->executeGitUpdate();
@ -113,7 +111,10 @@ final class PhabricatorRepositoryPullEngine
} catch (Exception $ex) {
$this->abortPull(
pht('Pull of "%s" failed: %s', $callsign, $ex->getMessage()),
pht(
"Pull of '%s' failed: %s",
$repository->getDisplayName(),
$ex->getMessage()),
$ex);
}