1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-11-10 00:42:41 +01:00

Move various other callsites away from callsigns

Summary: Ref T4245. These mostly relate to building URIs.

Test Plan: Tried to hunt down as many of these in the UI as I could. Some are a bit tricky but they should be low-risk.

Reviewers: chad

Reviewed By: chad

Maniphest Tasks: T4245

Differential Revision: https://secure.phabricator.com/D14933
This commit is contained in:
epriestley 2016-01-02 12:21:13 -08:00
parent 9febfb26a0
commit bcfd6bdd81
15 changed files with 45 additions and 36 deletions

View file

@ -33,7 +33,6 @@ final class DiffusionChangeController extends DiffusionController {
}
$repository = $drequest->getRepository();
$callsign = $repository->getCallsign();
$changesets = array(
0 => $changeset,
);
@ -59,7 +58,8 @@ final class DiffusionChangeController extends DiffusionController {
$left_uri = $drequest->generateURI($raw_params);
$changeset_view->setRawFileURIs($left_uri, $right_uri);
$changeset_view->setRenderURI('/diffusion/'.$callsign.'/diff/');
$changeset_view->setRenderURI($repository->getPathURI('diff/'));
$changeset_view->setWhitespace(
DifferentialChangesetParser::WHITESPACE_SHOW_ALL);
$changeset_view->setUser($viewer);

View file

@ -36,7 +36,6 @@ final class DiffusionCommitController extends DiffusionController {
}
$repository = $drequest->getRepository();
$callsign = $repository->getCallsign();
$content = array();
$commit = id(new DiffusionCommitQuery())
@ -321,19 +320,21 @@ final class DiffusionCommitController extends DiffusionController {
$change_list->setChangesets($changesets);
$change_list->setVisibleChangesets($visible_changesets);
$change_list->setRenderingReferences($references);
$change_list->setRenderURI('/diffusion/'.$callsign.'/diff/');
$change_list->setRenderURI(
$repository->getPathURI('diff/'));
$change_list->setRepository($repository);
$change_list->setUser($user);
// TODO: Try to setBranch() to something reasonable here?
$change_list->setStandaloneURI(
'/diffusion/'.$callsign.'/diff/');
$repository->getPathURI('diff/'));
$change_list->setRawFileURIs(
// TODO: Implement this, somewhat tricky if there's an octopus merge
// or whatever?
null,
'/diffusion/'.$callsign.'/diff/?view=r');
$repository->getPathURI('diff/?view=r'));
$change_list->setInlineCommentControllerURI(
'/diffusion/inline/edit/'.phutil_escape_uri($commit->getPHID()).'/');
@ -567,8 +568,8 @@ final class DiffusionCommitController extends DiffusionController {
),
pht('Unknown'));
$callsign = $repository->getCallsign();
$root = '/diffusion/'.$callsign.'/commit/'.$commit->getCommitIdentifier();
$identifier = $commit->getCommitIdentifier();
$root = $repository->getPathURI("commit/{$identifier}");
Javelin::initBehavior(
'diffusion-commit-branches',
array(
@ -904,8 +905,8 @@ final class DiffusionCommitController extends DiffusionController {
$commit,
PhabricatorPolicyCapability::CAN_EDIT);
$uri = '/diffusion/'.$repository->getCallsign().'/commit/'.
$commit->getCommitIdentifier().'/edit/';
$identifier = $commit->getCommitIdentifier();
$uri = $repository->getPathURI("commit/{$identifier}/edit/");
$action = id(new PhabricatorActionView())
->setName(pht('Edit Commit'))

View file

@ -86,7 +86,6 @@ abstract class DiffusionController extends PhabricatorController {
return $crumb_list;
}
$callsign = $repository->getCallsign();
$repository_name = $repository->getName();
if (!$spec['commit'] && !$spec['tags'] && !$spec['branches']) {
@ -112,17 +111,14 @@ abstract class DiffusionController extends PhabricatorController {
$crumb_list[] = $crumb;
$stable_commit = $drequest->getStableCommit();
$commit_name = $repository->formatCommitName($stable_commit);
$commit_uri = $repository->getCommitURI($stable_commit);
if ($spec['tags']) {
$crumb = new PHUICrumbView();
if ($spec['commit']) {
$crumb->setName(
pht('Tags for %s', 'r'.$callsign.$stable_commit));
$crumb->setHref($drequest->generateURI(
array(
'action' => 'commit',
'commit' => $drequest->getStableCommit(),
)));
$crumb->setName(pht('Tags for %s', $commit_name));
$crumb->setHref($commit_uri);
} else {
$crumb->setName(pht('Tags'));
}
@ -139,8 +135,8 @@ abstract class DiffusionController extends PhabricatorController {
if ($spec['commit']) {
$crumb = id(new PHUICrumbView())
->setName("r{$callsign}{$stable_commit}")
->setHref("r{$callsign}{$stable_commit}");
->setName($commit_name)
->setHref($commit_uri);
$crumb_list[] = $crumb;
return $crumb_list;
}
@ -187,7 +183,7 @@ abstract class DiffusionController extends PhabricatorController {
protected function getRepositoryControllerURI(
PhabricatorRepository $repository,
$path) {
return $this->getApplicationURI($repository->getCallsign().'/'.$path);
return $repository->getPathURI($path);
}
protected function renderPathLinks(DiffusionRequest $drequest, $action) {

View file

@ -48,7 +48,7 @@ final class DiffusionExternalController extends DiffusionController {
$redirect = DiffusionRequest::generateDiffusionURI(
array(
'action' => 'browse',
'callsign' => $repository->getCallsign(),
'repository' => $repository,
'branch' => $repository->getDefaultBranch(),
'commit' => $id,
));
@ -86,7 +86,7 @@ final class DiffusionExternalController extends DiffusionController {
$redirect = DiffusionRequest::generateDiffusionURI(
array(
'action' => 'browse',
'callsign' => $repo->getCallsign(),
'repository' => $repo,
'branch' => $repo->getDefaultBranch(),
'commit' => $commit->getCommitIdentifier(),
));
@ -99,7 +99,7 @@ final class DiffusionExternalController extends DiffusionController {
$href = DiffusionRequest::generateDiffusionURI(
array(
'action' => 'browse',
'callsign' => $repo->getCallsign(),
'repository' => $repo,
'branch' => $repo->getDefaultBranch(),
'commit' => $commit->getCommitIdentifier(),
));

View file

@ -480,7 +480,7 @@ final class DiffusionRepositoryController extends DiffusionController {
private function buildActionList(PhabricatorRepository $repository) {
$viewer = $this->getRequest()->getUser();
$edit_uri = $this->getApplicationURI($repository->getCallsign().'/edit/');
$edit_uri = $repository->getPathURI('edit/');
$view = id(new PhabricatorActionListView())
->setUser($viewer)

View file

@ -14,7 +14,7 @@ final class DiffusionCommitBranchesHeraldField
$repository = $object->getRepository();
$params = array(
'callsign' => $repository->getCallsign(),
'repository' => $repository->getPHID(),
'contains' => $commit->getCommitIdentifier(),
);

View file

@ -53,7 +53,7 @@ abstract class DiffusionQuery extends PhabricatorQuery {
$repository = $drequest->getRepository();
$core_params = array(
'callsign' => $repository->getCallsign(),
'repository' => $repository->getPHID(),
);
if ($drequest->getBranch() !== null) {

View file

@ -465,7 +465,7 @@ abstract class DiffusionRequest extends Phobject {
}
$defaults = array(
'callsign' => $this->getCallsign(),
'repository' => $this->getRepository(),
'path' => $this->getPath(),
'branch' => $this->getBranch(),
'commit' => $default_commit,
@ -487,6 +487,7 @@ abstract class DiffusionRequest extends Phobject {
* - `action` One of `history`, `browse`, `change`, `lastmodified`,
* `branch`, `tags`, `branches`, or `revision-ref`. The action specified
* by the URI.
* - `repository` Repository.
* - `callsign` Repository callsign.
* - `branch` Optional if action is not `branch`, branch name.
* - `path` Optional, path to file.
@ -504,7 +505,14 @@ abstract class DiffusionRequest extends Phobject {
public static function generateDiffusionURI(array $params) {
$action = idx($params, 'action');
$callsign = idx($params, 'callsign');
$repository = idx($params, 'repository');
if ($repository) {
$callsign = $repository->getCallsign();
} else {
$callsign = idx($params, 'callsign');
}
$path = idx($params, 'path');
$branch = idx($params, 'branch');
$commit = idx($params, 'commit');

View file

@ -63,8 +63,8 @@ final class HarbormasterWaitForPreviousBuildStepImplementation
$call = new ConduitCall(
'diffusion.commitparentsquery',
array(
'commit' => $commit->getCommitIdentifier(),
'callsign' => $commit->getRepository()->getCallsign(),
'commit' => $commit->getCommitIdentifier(),
'repository' => $commit->getRepository()->getPHID(),
));
$call->setUser(PhabricatorUser::getOmnipotentUser());
$parents = $call->execute();

View file

@ -270,7 +270,7 @@ final class PhabricatorOwnersDetailController
}
$href = DiffusionRequest::generateDiffusionURI(
array(
'callsign' => $repo->getCallsign(),
'repository' => $repo,
'branch' => $repo->getDefaultBranch(),
'path' => $path->getPath(),
'action' => 'browse',

View file

@ -26,7 +26,7 @@ final class PhabricatorCommitBranchesField
$params = array(
'contains' => $this->getObject()->getCommitIdentifier(),
'callsign' => $this->getObject()->getRepository()->getCallsign(),
'repository' => $this->getObject()->getRepository()->getPHID(),
);
try {

View file

@ -39,7 +39,7 @@ final class PhabricatorCommitMergedCommitsField
id(new ConduitCall('diffusion.mergedcommitsquery', array(
'commit' => $commit->getCommitIdentifier(),
'limit' => $limit + 1,
'callsign' => $commit->getRepository()->getCallsign(),
'repository' => $commit->getRepository()->getPHID(),
)))
->setUser($this->getViewer())
->execute());

View file

@ -26,7 +26,7 @@ final class PhabricatorCommitTagsField
$params = array(
'commit' => $this->getObject()->getCommitIdentifier(),
'callsign' => $this->getObject()->getRepository()->getCallsign(),
'repository' => $this->getObject()->getRepository()->getPHID(),
);
try {

View file

@ -177,7 +177,7 @@ final class PhabricatorRepositorySearchEngine
if ($size) {
$history_uri = DiffusionRequest::generateDiffusionURI(
array(
'callsign' => $repository->getCallsign(),
'repository' => $repository,
'action' => 'history',
));

View file

@ -601,6 +601,10 @@ final class PhabricatorRepository extends PhabricatorRepositoryDAO
return '/diffusion/'.$this->getCallsign().'/';
}
public function getPathURI($path) {
return $this->getURI().$path;
}
public function getCommitURI($identifier) {
$callsign = $this->getCallsign();
return "/r{$callsign}{$identifier}";