1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-11-23 23:32:40 +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(); $repository = $drequest->getRepository();
$callsign = $repository->getCallsign();
$changesets = array( $changesets = array(
0 => $changeset, 0 => $changeset,
); );
@ -59,7 +58,8 @@ final class DiffusionChangeController extends DiffusionController {
$left_uri = $drequest->generateURI($raw_params); $left_uri = $drequest->generateURI($raw_params);
$changeset_view->setRawFileURIs($left_uri, $right_uri); $changeset_view->setRawFileURIs($left_uri, $right_uri);
$changeset_view->setRenderURI('/diffusion/'.$callsign.'/diff/'); $changeset_view->setRenderURI($repository->getPathURI('diff/'));
$changeset_view->setWhitespace( $changeset_view->setWhitespace(
DifferentialChangesetParser::WHITESPACE_SHOW_ALL); DifferentialChangesetParser::WHITESPACE_SHOW_ALL);
$changeset_view->setUser($viewer); $changeset_view->setUser($viewer);

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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