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

Continue reducing callers to getCallsign()

Summary: Ref T4245. More of the same, just narrowing down the easy cases.

Test Plan:
- Called `diffusion.querycommit`.
- Browsed branches.
- Browsed repository.
- Browsed directory.
- Searched for stuff.
- Viewed a commit.
- Viewed a file diff.
- Edited a commit.
- Viewed history.
- Viewed tags.
- Viewed push log.

Reviewers: chad

Reviewed By: chad

Maniphest Tasks: T4245

Differential Revision: https://secure.phabricator.com/D14929
This commit is contained in:
epriestley 2016-01-02 11:28:31 -08:00
parent 9d84eb4c74
commit 35e7a1f3c0
23 changed files with 54 additions and 74 deletions

View file

@ -70,16 +70,14 @@ final class DiffusionQueryCommitsConduitAPIMethod
foreach ($commits as $commit) {
$commit_data = $commit->getCommitData();
$callsign = $commit->getRepository()->getCallsign();
$identifier = $commit->getCommitIdentifier();
$uri = '/r'.$callsign.$identifier;
$uri = $commit->getURI();
$uri = PhabricatorEnv::getProductionURI($uri);
$dict = array(
'id' => $commit->getID(),
'phid' => $commit->getPHID(),
'repositoryPHID' => $commit->getRepository()->getPHID(),
'identifier' => $identifier,
'identifier' => $commit->getCommitIdentifier(),
'epoch' => $commit->getEpoch(),
'uri' => $uri,
'isImporting' => !$commit->isImported(),

View file

@ -66,7 +66,7 @@ final class DiffusionBranchTableController extends DiffusionController {
array(
'title' => array(
pht('Branches'),
'r'.$repository->getCallsign(),
$repository->getDisplayName(),
),
));
}

View file

@ -125,7 +125,6 @@ abstract class DiffusionBrowseController extends DiffusionController {
->setActionList($actions);
$stable_commit = $drequest->getStableCommit();
$callsign = $drequest->getRepository()->getCallsign();
$view->addProperty(
pht('Commit'),

View file

@ -98,9 +98,7 @@ final class DiffusionBrowseDirectoryController
array(
'title' => array(
nonempty(basename($drequest->getPath()), '/'),
pht(
'%s Repository',
$drequest->getRepository()->getCallsign()),
$drequest->getRepository()->getDisplayName(),
),
));
}

View file

@ -33,9 +33,7 @@ final class DiffusionBrowseSearchController extends DiffusionBrowseController {
array(
'title' => array(
nonempty(basename($drequest->getPath()), '/'),
pht(
'%s Repository',
$drequest->getRepository()->getCallsign()),
$drequest->getRepository()->getDisplayName(),
),
));
}

View file

@ -142,7 +142,6 @@ final class DiffusionChangeController extends DiffusionController {
->setActionList($actions);
$stable_commit = $drequest->getStableCommit();
$callsign = $drequest->getRepository()->getCallsign();
$view->addProperty(
pht('Commit'),

View file

@ -181,7 +181,7 @@ final class DiffusionCommitController extends DiffusionController {
id(new PhabricatorRepository())->establishConnection('r'),
'SELECT * FROM %T WHERE fullCommitName = %s',
PhabricatorRepository::TABLE_BADCOMMIT,
'r'.$callsign.$commit->getCommitIdentifier());
$commit->getMonogram());
}
$show_changesets = false;
@ -314,9 +314,8 @@ final class DiffusionCommitController extends DiffusionController {
}
}
$change_list_title = DiffusionView::nameCommit(
$repository,
$commit->getCommitIdentifier());
$change_list_title = $commit->getDisplayName();
$change_list = new DifferentialChangesetListView();
$change_list->setTitle($change_list_title);
$change_list->setChangesets($changesets);
@ -344,11 +343,6 @@ final class DiffusionCommitController extends DiffusionController {
$content[] = $this->renderAddCommentPanel($commit, $audit_requests);
$commit_id = 'r'.$callsign.$commit->getCommitIdentifier();
$short_name = DiffusionView::nameCommit(
$repository,
$commit->getCommitIdentifier());
$prefs = $user->loadPreferences();
$pref_filetree = PhabricatorUserPreferences::PREFERENCE_DIFF_FILETREE;
$pref_collapse = PhabricatorUserPreferences::PREFERENCE_NAV_COLLAPSED;
@ -357,8 +351,8 @@ final class DiffusionCommitController extends DiffusionController {
if ($show_changesets && $show_filetree) {
$nav = id(new DifferentialChangesetFileTreeSideNavBuilder())
->setTitle($short_name)
->setBaseURI(new PhutilURI('/'.$commit_id))
->setTitle($commit->getDisplayName())
->setBaseURI(new PhutilURI($commit->getURI()))
->build($changesets)
->setCrumbs($crumbs)
->setCollapsed((bool)$collapsed)
@ -371,7 +365,7 @@ final class DiffusionCommitController extends DiffusionController {
return $this->buildApplicationPage(
$content,
array(
'title' => $commit_id,
'title' => $commit->getDisplayName(),
'pageObjects' => array($commit->getPHID()),
));
}

View file

@ -5,7 +5,6 @@ final class DiffusionCommitEditController extends DiffusionController {
protected function processDiffusionRequest(AphrontRequest $request) {
$user = $request->getUser();
$drequest = $this->getDiffusionRequest();
$callsign = $drequest->getRepository()->getCallsign();
$repository = $drequest->getRepository();
$commit = $drequest->loadCommit();
$data = $commit->loadCommitData();
@ -34,7 +33,7 @@ final class DiffusionCommitEditController extends DiffusionController {
->setContentSourceFromRequest($request);
$xactions = $editor->applyTransactions($commit, $xactions);
return id(new AphrontRedirectResponse())
->setURI('/r'.$callsign.$commit->getCommitIdentifier());
->setURI($commit->getURI());
}
$tokenizer_id = celerity_generate_unique_node_id();
@ -95,8 +94,8 @@ final class DiffusionCommitEditController extends DiffusionController {
$submit = id(new AphrontFormSubmitControl())
->setValue(pht('Save'))
->addCancelButton('/r'.$callsign.$commit->getCommitIdentifier());
$form->appendChild($submit);
->addCancelButton($commit->getURI());
$form->appendChild($submit);
$crumbs = $this->buildCrumbs(array(
'commit' => true,

View file

@ -235,7 +235,7 @@ abstract class DiffusionController extends PhabricatorController {
}
}
} else {
$links[] = 'r'.$drequest->getRepository()->getCallsign();
$links[] = $drequest->getRepository()->getDisplayName();
$links[] = $divider;
}

View file

@ -109,7 +109,7 @@ final class DiffusionExternalController extends DiffusionController {
array(
'href' => $href,
),
'r'.$repo->getCallsign().$commit->getCommitIdentifier()),
$commit->getMonogram()),
$commit->loadCommitData()->getSummary(),
);
}

View file

@ -93,7 +93,7 @@ final class DiffusionHistoryController extends DiffusionController {
array(
'title' => array(
pht('History'),
pht('%s Repository', $drequest->getRepository()->getCallsign()),
$drequest->getRepository()->getDisplayName(),
),
));
}
@ -151,7 +151,6 @@ final class DiffusionHistoryController extends DiffusionController {
->setActionList($actions);
$stable_commit = $drequest->getStableCommit();
$callsign = $drequest->getRepository()->getCallsign();
$view->addProperty(
pht('Commit'),

View file

@ -80,7 +80,12 @@ final class DiffusionLintController extends DiffusionController {
$rows[] = array(
phutil_tag('a', array('href' => $href_lint), $code['n']),
phutil_tag('a', array('href' => $href_browse), $code['files']),
phutil_tag('a', array('href' => $href_repo), $drequest->getCallsign()),
phutil_tag(
'a',
array(
'href' => $href_repo,
),
$drequest->getRepository()->getDisplayName()),
ArcanistLintSeverity::getStringForSeverity($code['maxSeverity']),
$code['code'],
$code['maxName'],
@ -133,7 +138,7 @@ final class DiffusionLintController extends DiffusionController {
));
if ($this->diffusionRequest) {
$title[] = $drequest->getCallsign();
$title[] = $drequest->getRepository()->getDisplayName();
} else {
$crumbs->addTextCrumb(pht('All Lint'));
}
@ -314,7 +319,6 @@ final class DiffusionLintController extends DiffusionController {
->setUser($viewer)
->setActionList($actions);
$callsign = $drequest->getRepository()->getCallsign();
$lint_commit = $branch->getLintCommit();
$view->addProperty(

View file

@ -90,11 +90,10 @@ final class DiffusionLintDetailsController extends DiffusionController {
$pager,
),
array(
'title' =>
array(
pht('Lint'),
$drequest->getRepository()->getCallsign(),
),
'title' => array(
pht('Lint'),
$drequest->getRepository()->getDisplayName(),
),
));
}

View file

@ -25,7 +25,8 @@ final class DiffusionPushEventViewController
$crumbs = $this->buildApplicationCrumbs();
$crumbs->addTextCrumb(
$repository->getName(),
$this->getApplicationURI($repository->getCallsign().'/'));
$repository->getURI());
$crumbs->addTextCrumb(
pht('Push Logs'),
$this->getApplicationURI(

View file

@ -500,9 +500,8 @@ final class DiffusionRepositoryController extends DiffusionController {
->setDisabled(!$can_edit));
if ($repository->isHosted()) {
$callsign = $repository->getCallsign();
$push_uri = $this->getApplicationURI(
'pushlog/?repositories=r'.$callsign);
'pushlog/?repositories='.$repository->getMonogram());
$view->addAction(
id(new PhabricatorActionView())
@ -551,7 +550,6 @@ final class DiffusionRepositoryController extends DiffusionController {
}
$history_table->setIsHead(true);
$callsign = $drequest->getRepository()->getCallsign();
$icon = id(new PHUIIconView())
->setIconFont('fa-list-alt');

View file

@ -8,10 +8,10 @@ abstract class DiffusionRepositoryEditController
if ($this->diffusionRequest) {
$repository = $this->getDiffusionRequest()->getRepository();
$repo_uri = $this->getRepositoryControllerURI($repository, '');
$repo_uri = $repository->getURI();
$edit_uri = $this->getRepositoryControllerURI($repository, 'edit/');
$crumbs->addTextCrumb('r'.$repository->getCallsign(), $repo_uri);
$crumbs->addTextCrumb($repository->getDisplayname(), $repo_uri);
if ($is_main) {
$crumbs->addTextCrumb(pht('Edit Repository'));

View file

@ -60,7 +60,7 @@ final class DiffusionRepositoryEditStorageController
"web interface. To edit it, run this command:\n\n %s",
sprintf(
'phabricator/ $ ./bin/repository edit %s --as %s --local-path ...',
$repository->getCallsign(),
$repository->getMonogram(),
$user->getUsername())))
->appendChild(
id(new AphrontFormSubmitControl())

View file

@ -88,7 +88,7 @@ final class DiffusionTagListController extends DiffusionController {
array(
'title' => array(
pht('Tags'),
pht('%s Repository', $repository->getCallsign()),
$repository->getDisplayName(),
),
));
}

View file

@ -28,7 +28,7 @@ final class DiffusionRepositoryDatasource
foreach ($repos as $repo) {
$results[] = id(new PhabricatorTypeaheadResult())
->setName($repo->getMonogram().' '.$repo->getName())
->setURI('/diffusion/'.$repo->getCallsign().'/')
->setURI($repo->getURI())
->setPHID($repo->getPHID())
->setPriorityString($repo->getMonogram());
}

View file

@ -39,6 +39,7 @@ final class DiffusionPushLogListView extends AphrontView {
$rows = array();
foreach ($logs as $log) {
$repository = $log->getRepository();
// Reveal this if it's valid and the user can edit the repository.
$remote_addr = '-';
@ -51,16 +52,16 @@ final class DiffusionPushLogListView extends AphrontView {
$event_id = $log->getPushEvent()->getID();
$callsign = $log->getRepository()->getCallsign();
$old_ref_link = null;
if ($log->getRefOld() != DiffusionCommitHookEngine::EMPTY_HASH) {
$old_ref_link = phutil_tag(
'a',
array(
'href' => '/r'.$callsign.$log->getRefOld(),
'href' => $repository->getCommitURI($log->getRefOld()),
),
$log->getRefOldShort());
}
$rows[] = array(
phutil_tag(
'a',
@ -71,9 +72,9 @@ final class DiffusionPushLogListView extends AphrontView {
phutil_tag(
'a',
array(
'href' => '/diffusion/'.$callsign.'/',
'href' => $repository->getURI(),
),
$callsign),
$repository->getDisplayName()),
$handles[$log->getPusherPHID()]->renderLink(),
$remote_addr,
$log->getPushEvent()->getRemoteProtocol(),
@ -83,7 +84,7 @@ final class DiffusionPushLogListView extends AphrontView {
phutil_tag(
'a',
array(
'href' => '/r'.$callsign.$log->getRefNew(),
'href' => $repository->getCommitURI($log->getRefNew()),
),
$log->getRefNewShort()),

View file

@ -123,30 +123,12 @@ abstract class DiffusionView extends AphrontView {
));
}
final public static function nameCommit(
PhabricatorRepository $repository,
$commit) {
switch ($repository->getVersionControlSystem()) {
case PhabricatorRepositoryType::REPOSITORY_TYPE_GIT:
case PhabricatorRepositoryType::REPOSITORY_TYPE_MERCURIAL:
$commit_name = substr($commit, 0, 12);
break;
default:
$commit_name = $commit;
break;
}
$callsign = $repository->getCallsign();
return "r{$callsign}{$commit_name}";
}
final public static function linkCommit(
PhabricatorRepository $repository,
$commit,
$summary = '') {
$commit_name = self::nameCommit($repository, $commit);
$commit_name = $repository->formatCommitName($commit);
$callsign = $repository->getCallsign();
if (strlen($summary)) {

View file

@ -601,6 +601,11 @@ final class PhabricatorRepository extends PhabricatorRepositoryDAO
return '/diffusion/'.$this->getCallsign().'/';
}
public function getCommitURI($identifier) {
$callsign = $this->getCallsign();
return "/r{$callsign}{$identifier}";
}
public function getNormalizedPath() {
$uri = (string)$this->getCloneURIObject();

View file

@ -256,6 +256,12 @@ final class PhabricatorRepositoryCommit
return "r{$callsign}{$identifier}";
}
public function getDisplayName() {
$repository = $this->getRepository();
$identifier = $this->getCommitIdentifier();
return $repository->formatCommitName($identifier);
}
/* -( PhabricatorPolicyInterface )----------------------------------------- */