2011-03-08 02:25:47 +01:00
|
|
|
<?php
|
|
|
|
|
2016-01-05 14:18:59 +01:00
|
|
|
final class DiffusionBrowseController extends DiffusionController {
|
|
|
|
|
|
|
|
private $lintCommit;
|
|
|
|
private $lintMessages;
|
|
|
|
private $coverage;
|
2013-09-19 20:57:33 +02:00
|
|
|
|
2013-09-23 21:53:41 +02:00
|
|
|
public function shouldAllowPublic() {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2016-01-05 14:18:59 +01:00
|
|
|
public function handleRequest(AphrontRequest $request) {
|
|
|
|
$response = $this->loadDiffusionContext();
|
|
|
|
if ($response) {
|
|
|
|
return $response;
|
|
|
|
}
|
|
|
|
|
|
|
|
$drequest = $this->getDiffusionRequest();
|
|
|
|
|
|
|
|
// Figure out if we're browsing a directory, a file, or a search result
|
|
|
|
// list.
|
|
|
|
|
|
|
|
$grep = $request->getStr('grep');
|
|
|
|
$find = $request->getStr('find');
|
|
|
|
if (strlen($grep) || strlen($find)) {
|
|
|
|
return $this->browseSearch();
|
|
|
|
}
|
|
|
|
|
|
|
|
$results = DiffusionBrowseResultSet::newFromConduit(
|
|
|
|
$this->callConduitWithDiffusionRequest(
|
|
|
|
'diffusion.browsequery',
|
|
|
|
array(
|
|
|
|
'path' => $drequest->getPath(),
|
|
|
|
'commit' => $drequest->getStableCommit(),
|
|
|
|
)));
|
|
|
|
$reason = $results->getReasonForEmptyResultSet();
|
|
|
|
$is_file = ($reason == DiffusionBrowseResultSet::REASON_IS_FILE);
|
|
|
|
|
|
|
|
if ($is_file) {
|
|
|
|
return $this->browseFile($results);
|
|
|
|
} else {
|
|
|
|
return $this->browseDirectory($results);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
private function browseSearch() {
|
|
|
|
$drequest = $this->getDiffusionRequest();
|
|
|
|
|
|
|
|
$actions = $this->buildActionView($drequest);
|
|
|
|
$properties = $this->buildPropertyView($drequest, $actions);
|
|
|
|
|
|
|
|
$object_box = id(new PHUIObjectBoxView())
|
|
|
|
->setHeader($this->buildHeaderView($drequest))
|
|
|
|
->addPropertyList($properties);
|
|
|
|
|
|
|
|
$content = array();
|
|
|
|
|
|
|
|
$content[] = $object_box;
|
|
|
|
$content[] = $this->renderSearchForm($collapsed = false);
|
|
|
|
$content[] = $this->renderSearchResults();
|
|
|
|
|
|
|
|
$crumbs = $this->buildCrumbs(
|
|
|
|
array(
|
|
|
|
'branch' => true,
|
|
|
|
'path' => true,
|
|
|
|
'view' => 'browse',
|
|
|
|
));
|
|
|
|
|
|
|
|
return $this->newPage()
|
|
|
|
->setTitle(
|
|
|
|
array(
|
|
|
|
nonempty(basename($drequest->getPath()), '/'),
|
|
|
|
$drequest->getRepository()->getDisplayName(),
|
|
|
|
))
|
|
|
|
->setCrumbs($crumbs)
|
|
|
|
->appendChild($content);
|
|
|
|
}
|
|
|
|
|
|
|
|
private function browseFile() {
|
|
|
|
$viewer = $this->getViewer();
|
|
|
|
$request = $this->getRequest();
|
|
|
|
$drequest = $this->getDiffusionRequest();
|
|
|
|
$repository = $drequest->getRepository();
|
|
|
|
|
|
|
|
$before = $request->getStr('before');
|
|
|
|
if ($before) {
|
|
|
|
return $this->buildBeforeResponse($before);
|
|
|
|
}
|
|
|
|
|
|
|
|
$path = $drequest->getPath();
|
|
|
|
|
|
|
|
$preferences = $viewer->loadPreferences();
|
|
|
|
|
|
|
|
$show_blame = $request->getBool(
|
|
|
|
'blame',
|
|
|
|
$preferences->getPreference(
|
|
|
|
PhabricatorUserPreferences::PREFERENCE_DIFFUSION_BLAME,
|
|
|
|
false));
|
|
|
|
$show_color = $request->getBool(
|
|
|
|
'color',
|
|
|
|
$preferences->getPreference(
|
|
|
|
PhabricatorUserPreferences::PREFERENCE_DIFFUSION_COLOR,
|
|
|
|
true));
|
|
|
|
|
|
|
|
$view = $request->getStr('view');
|
|
|
|
if ($request->isFormPost() && $view != 'raw' && $viewer->isLoggedIn()) {
|
|
|
|
$preferences->setPreference(
|
|
|
|
PhabricatorUserPreferences::PREFERENCE_DIFFUSION_BLAME,
|
|
|
|
$show_blame);
|
|
|
|
$preferences->setPreference(
|
|
|
|
PhabricatorUserPreferences::PREFERENCE_DIFFUSION_COLOR,
|
|
|
|
$show_color);
|
|
|
|
$preferences->save();
|
|
|
|
|
|
|
|
$uri = $request->getRequestURI()
|
|
|
|
->alter('blame', null)
|
|
|
|
->alter('color', null);
|
|
|
|
|
|
|
|
return id(new AphrontRedirectResponse())->setURI($uri);
|
|
|
|
}
|
|
|
|
|
|
|
|
// We need the blame information if blame is on and we're building plain
|
|
|
|
// text, or blame is on and this is an Ajax request. If blame is on and
|
|
|
|
// this is a colorized request, we don't show blame at first (we ajax it
|
|
|
|
// in afterward) so we don't need to query for it.
|
|
|
|
$needs_blame = ($show_blame && !$show_color) ||
|
|
|
|
($show_blame && $request->isAjax());
|
|
|
|
|
|
|
|
$params = array(
|
|
|
|
'commit' => $drequest->getCommit(),
|
|
|
|
'path' => $drequest->getPath(),
|
|
|
|
);
|
|
|
|
|
|
|
|
$byte_limit = null;
|
|
|
|
if ($view !== 'raw') {
|
|
|
|
$byte_limit = PhabricatorFileStorageEngine::getChunkThreshold();
|
|
|
|
$time_limit = 10;
|
|
|
|
|
|
|
|
$params += array(
|
|
|
|
'timeout' => $time_limit,
|
|
|
|
'byteLimit' => $byte_limit,
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
$file_content = DiffusionFileContent::newFromConduit(
|
|
|
|
$this->callConduitWithDiffusionRequest(
|
|
|
|
'diffusion.filecontentquery',
|
|
|
|
$params));
|
|
|
|
$data = $file_content->getCorpus();
|
|
|
|
|
|
|
|
if ($view === 'raw') {
|
|
|
|
return $this->buildRawResponse($path, $data);
|
|
|
|
}
|
|
|
|
|
|
|
|
$this->loadLintMessages();
|
|
|
|
$this->coverage = $drequest->loadCoverage();
|
|
|
|
|
|
|
|
if ($byte_limit && (strlen($data) == $byte_limit)) {
|
|
|
|
$corpus = $this->buildErrorCorpus(
|
|
|
|
pht(
|
|
|
|
'This file is larger than %s byte(s), and too large to display '.
|
|
|
|
'in the web UI.',
|
|
|
|
$byte_limit));
|
|
|
|
} else if (ArcanistDiffUtils::isHeuristicBinaryFile($data)) {
|
|
|
|
$file = $this->loadFileForData($path, $data);
|
|
|
|
$file_uri = $file->getBestURI();
|
|
|
|
|
|
|
|
if ($file->isViewableImage()) {
|
|
|
|
$corpus = $this->buildImageCorpus($file_uri);
|
|
|
|
} else {
|
|
|
|
$corpus = $this->buildBinaryCorpus($file_uri, $data);
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
// Build the content of the file.
|
|
|
|
$corpus = $this->buildCorpus(
|
|
|
|
$show_blame,
|
|
|
|
$show_color,
|
|
|
|
$file_content,
|
|
|
|
$needs_blame,
|
|
|
|
$drequest,
|
|
|
|
$path,
|
|
|
|
$data);
|
|
|
|
}
|
|
|
|
|
|
|
|
if ($request->isAjax()) {
|
|
|
|
return id(new AphrontAjaxResponse())->setContent($corpus);
|
|
|
|
}
|
|
|
|
|
|
|
|
require_celerity_resource('diffusion-source-css');
|
|
|
|
|
|
|
|
// Render the page.
|
|
|
|
$view = $this->buildActionView($drequest);
|
|
|
|
$action_list = $this->enrichActionView(
|
|
|
|
$view,
|
|
|
|
$drequest,
|
|
|
|
$show_blame,
|
|
|
|
$show_color);
|
|
|
|
|
|
|
|
$properties = $this->buildPropertyView($drequest, $action_list);
|
|
|
|
$object_box = id(new PHUIObjectBoxView())
|
|
|
|
->setHeader($this->buildHeaderView($drequest))
|
|
|
|
->addPropertyList($properties);
|
|
|
|
|
|
|
|
$content = array();
|
|
|
|
$content[] = $object_box;
|
|
|
|
|
|
|
|
$follow = $request->getStr('follow');
|
|
|
|
if ($follow) {
|
|
|
|
$notice = new PHUIInfoView();
|
|
|
|
$notice->setSeverity(PHUIInfoView::SEVERITY_WARNING);
|
|
|
|
$notice->setTitle(pht('Unable to Continue'));
|
|
|
|
switch ($follow) {
|
|
|
|
case 'first':
|
|
|
|
$notice->appendChild(
|
|
|
|
pht(
|
|
|
|
'Unable to continue tracing the history of this file because '.
|
|
|
|
'this commit is the first commit in the repository.'));
|
|
|
|
break;
|
|
|
|
case 'created':
|
|
|
|
$notice->appendChild(
|
|
|
|
pht(
|
|
|
|
'Unable to continue tracing the history of this file because '.
|
|
|
|
'this commit created the file.'));
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
$content[] = $notice;
|
|
|
|
}
|
|
|
|
|
|
|
|
$renamed = $request->getStr('renamed');
|
|
|
|
if ($renamed) {
|
|
|
|
$notice = new PHUIInfoView();
|
|
|
|
$notice->setSeverity(PHUIInfoView::SEVERITY_NOTICE);
|
|
|
|
$notice->setTitle(pht('File Renamed'));
|
|
|
|
$notice->appendChild(
|
|
|
|
pht(
|
|
|
|
'File history passes through a rename from "%s" to "%s".',
|
|
|
|
$drequest->getPath(),
|
|
|
|
$renamed));
|
|
|
|
$content[] = $notice;
|
|
|
|
}
|
|
|
|
|
|
|
|
$content[] = $corpus;
|
|
|
|
$content[] = $this->buildOpenRevisions();
|
|
|
|
|
|
|
|
$crumbs = $this->buildCrumbs(
|
|
|
|
array(
|
|
|
|
'branch' => true,
|
|
|
|
'path' => true,
|
|
|
|
'view' => 'browse',
|
|
|
|
));
|
|
|
|
|
|
|
|
$basename = basename($this->getDiffusionRequest()->getPath());
|
|
|
|
|
|
|
|
return $this->newPage()
|
|
|
|
->setTitle(
|
|
|
|
array(
|
|
|
|
$basename,
|
|
|
|
$repository->getDisplayName(),
|
|
|
|
))
|
|
|
|
->setCrumbs($crumbs)
|
|
|
|
->appendChild($content);
|
|
|
|
}
|
|
|
|
|
|
|
|
public function browseDirectory(DiffusionBrowseResultSet $results) {
|
|
|
|
$request = $this->getRequest();
|
|
|
|
$drequest = $this->getDiffusionRequest();
|
|
|
|
$repository = $drequest->getRepository();
|
|
|
|
|
|
|
|
$reason = $results->getReasonForEmptyResultSet();
|
|
|
|
|
|
|
|
$content = array();
|
|
|
|
$actions = $this->buildActionView($drequest);
|
|
|
|
$properties = $this->buildPropertyView($drequest, $actions);
|
|
|
|
|
|
|
|
$object_box = id(new PHUIObjectBoxView())
|
|
|
|
->setHeader($this->buildHeaderView($drequest))
|
|
|
|
->addPropertyList($properties);
|
|
|
|
|
|
|
|
$content[] = $object_box;
|
|
|
|
$content[] = $this->renderSearchForm($collapsed = true);
|
|
|
|
|
|
|
|
if (!$results->isValidResults()) {
|
|
|
|
$empty_result = new DiffusionEmptyResultView();
|
|
|
|
$empty_result->setDiffusionRequest($drequest);
|
|
|
|
$empty_result->setDiffusionBrowseResultSet($results);
|
|
|
|
$empty_result->setView($request->getStr('view'));
|
|
|
|
$content[] = $empty_result;
|
|
|
|
} else {
|
|
|
|
$phids = array();
|
|
|
|
foreach ($results->getPaths() as $result) {
|
|
|
|
$data = $result->getLastCommitData();
|
|
|
|
if ($data) {
|
|
|
|
if ($data->getCommitDetail('authorPHID')) {
|
|
|
|
$phids[$data->getCommitDetail('authorPHID')] = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
$phids = array_keys($phids);
|
|
|
|
$handles = $this->loadViewerHandles($phids);
|
|
|
|
|
|
|
|
$browse_table = new DiffusionBrowseTableView();
|
|
|
|
$browse_table->setDiffusionRequest($drequest);
|
|
|
|
$browse_table->setHandles($handles);
|
|
|
|
$browse_table->setPaths($results->getPaths());
|
|
|
|
$browse_table->setUser($request->getUser());
|
|
|
|
|
|
|
|
$browse_panel = new PHUIObjectBoxView();
|
|
|
|
$browse_panel->setHeaderText($drequest->getPath(), '/');
|
|
|
|
$browse_panel->setTable($browse_table);
|
|
|
|
|
|
|
|
$content[] = $browse_panel;
|
|
|
|
}
|
|
|
|
|
|
|
|
$content[] = $this->buildOpenRevisions();
|
|
|
|
|
|
|
|
|
|
|
|
$readme_path = $results->getReadmePath();
|
|
|
|
if ($readme_path) {
|
|
|
|
$readme_content = $this->callConduitWithDiffusionRequest(
|
|
|
|
'diffusion.filecontentquery',
|
|
|
|
array(
|
|
|
|
'path' => $readme_path,
|
|
|
|
'commit' => $drequest->getStableCommit(),
|
|
|
|
));
|
|
|
|
if ($readme_content) {
|
|
|
|
$content[] = id(new DiffusionReadmeView())
|
|
|
|
->setUser($this->getViewer())
|
|
|
|
->setPath($readme_path)
|
|
|
|
->setContent($readme_content['corpus']);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
$crumbs = $this->buildCrumbs(
|
|
|
|
array(
|
|
|
|
'branch' => true,
|
|
|
|
'path' => true,
|
|
|
|
'view' => 'browse',
|
|
|
|
));
|
|
|
|
|
|
|
|
return $this->newPage()
|
|
|
|
->setTitle(
|
|
|
|
array(
|
|
|
|
nonempty(basename($drequest->getPath()), '/'),
|
|
|
|
$repository->getDisplayName(),
|
|
|
|
))
|
|
|
|
->setCrumbs($crumbs)
|
|
|
|
->appendChild($content);
|
|
|
|
}
|
|
|
|
|
|
|
|
private function renderSearchResults() {
|
2016-01-05 14:56:35 +01:00
|
|
|
$request = $this->getRequest();
|
|
|
|
|
2016-01-05 14:18:59 +01:00
|
|
|
$drequest = $this->getDiffusionRequest();
|
|
|
|
$repository = $drequest->getRepository();
|
|
|
|
$results = array();
|
|
|
|
|
2016-01-05 14:56:35 +01:00
|
|
|
$pager = id(new PHUIPagerView())
|
|
|
|
->readFromRequest($request);
|
2016-01-05 14:18:59 +01:00
|
|
|
|
|
|
|
$search_mode = null;
|
|
|
|
switch ($repository->getVersionControlSystem()) {
|
|
|
|
case PhabricatorRepositoryType::REPOSITORY_TYPE_SVN:
|
|
|
|
$results = array();
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
if (strlen($this->getRequest()->getStr('grep'))) {
|
|
|
|
$search_mode = 'grep';
|
2016-01-05 14:56:35 +01:00
|
|
|
$query_string = $request->getStr('grep');
|
2016-01-05 14:18:59 +01:00
|
|
|
$results = $this->callConduitWithDiffusionRequest(
|
|
|
|
'diffusion.searchquery',
|
|
|
|
array(
|
|
|
|
'grep' => $query_string,
|
|
|
|
'commit' => $drequest->getStableCommit(),
|
|
|
|
'path' => $drequest->getPath(),
|
2016-01-05 14:56:35 +01:00
|
|
|
'limit' => $pager->getPageSize() + 1,
|
|
|
|
'offset' => $pager->getOffset(),
|
2016-01-05 14:18:59 +01:00
|
|
|
));
|
|
|
|
} else { // Filename search.
|
|
|
|
$search_mode = 'find';
|
2016-01-05 14:56:35 +01:00
|
|
|
$query_string = $request->getStr('find');
|
2016-01-05 14:18:59 +01:00
|
|
|
$results = $this->callConduitWithDiffusionRequest(
|
|
|
|
'diffusion.querypaths',
|
|
|
|
array(
|
|
|
|
'pattern' => $query_string,
|
|
|
|
'commit' => $drequest->getStableCommit(),
|
|
|
|
'path' => $drequest->getPath(),
|
2016-01-05 14:56:35 +01:00
|
|
|
'limit' => $pager->getPageSize() + 1,
|
|
|
|
'offset' => $pager->getOffset(),
|
2016-01-05 14:18:59 +01:00
|
|
|
));
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
$results = $pager->sliceResults($results);
|
|
|
|
|
|
|
|
if ($search_mode == 'grep') {
|
|
|
|
$table = $this->renderGrepResults($results, $query_string);
|
|
|
|
$header = pht(
|
|
|
|
'File content matching "%s" under "%s"',
|
|
|
|
$query_string,
|
|
|
|
nonempty($drequest->getPath(), '/'));
|
|
|
|
} else {
|
|
|
|
$table = $this->renderFindResults($results);
|
|
|
|
$header = pht(
|
|
|
|
'Paths matching "%s" under "%s"',
|
|
|
|
$query_string,
|
|
|
|
nonempty($drequest->getPath(), '/'));
|
|
|
|
}
|
|
|
|
|
|
|
|
$box = id(new PHUIObjectBoxView())
|
|
|
|
->setHeaderText($header)
|
|
|
|
->setTable($table);
|
|
|
|
|
|
|
|
$pager_box = $this->renderTablePagerBox($pager);
|
|
|
|
|
|
|
|
return array($box, $pager_box);
|
|
|
|
}
|
|
|
|
|
|
|
|
private function renderGrepResults(array $results, $pattern) {
|
|
|
|
$drequest = $this->getDiffusionRequest();
|
|
|
|
|
|
|
|
require_celerity_resource('phabricator-search-results-css');
|
|
|
|
|
|
|
|
$rows = array();
|
|
|
|
foreach ($results as $result) {
|
|
|
|
list($path, $line, $string) = $result;
|
|
|
|
|
|
|
|
$href = $drequest->generateURI(array(
|
|
|
|
'action' => 'browse',
|
|
|
|
'path' => $path,
|
|
|
|
'line' => $line,
|
|
|
|
));
|
|
|
|
|
|
|
|
$matches = null;
|
|
|
|
$count = @preg_match_all(
|
|
|
|
'('.$pattern.')u',
|
|
|
|
$string,
|
|
|
|
$matches,
|
|
|
|
PREG_OFFSET_CAPTURE);
|
|
|
|
|
|
|
|
if (!$count) {
|
|
|
|
$output = ltrim($string);
|
|
|
|
} else {
|
|
|
|
$output = array();
|
|
|
|
$cursor = 0;
|
|
|
|
$length = strlen($string);
|
|
|
|
foreach ($matches[0] as $match) {
|
|
|
|
$offset = $match[1];
|
|
|
|
if ($cursor != $offset) {
|
|
|
|
$output[] = array(
|
|
|
|
'text' => substr($string, $cursor, $offset),
|
|
|
|
'highlight' => false,
|
|
|
|
);
|
|
|
|
}
|
|
|
|
$output[] = array(
|
|
|
|
'text' => $match[0],
|
|
|
|
'highlight' => true,
|
|
|
|
);
|
|
|
|
$cursor = $offset + strlen($match[0]);
|
|
|
|
}
|
|
|
|
if ($cursor != $length) {
|
|
|
|
$output[] = array(
|
|
|
|
'text' => substr($string, $cursor),
|
|
|
|
'highlight' => false,
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
if ($output) {
|
|
|
|
$output[0]['text'] = ltrim($output[0]['text']);
|
|
|
|
}
|
|
|
|
|
|
|
|
foreach ($output as $key => $segment) {
|
|
|
|
if ($segment['highlight']) {
|
|
|
|
$output[$key] = phutil_tag('strong', array(), $segment['text']);
|
|
|
|
} else {
|
|
|
|
$output[$key] = $segment['text'];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
$string = phutil_tag(
|
|
|
|
'pre',
|
|
|
|
array('class' => 'PhabricatorMonospaced phui-source-fragment'),
|
|
|
|
$output);
|
|
|
|
|
|
|
|
$path = Filesystem::readablePath($path, $drequest->getPath());
|
|
|
|
|
|
|
|
$rows[] = array(
|
|
|
|
phutil_tag('a', array('href' => $href), $path),
|
|
|
|
$line,
|
|
|
|
$string,
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
$table = id(new AphrontTableView($rows))
|
|
|
|
->setClassName('remarkup-code')
|
|
|
|
->setHeaders(array(pht('Path'), pht('Line'), pht('String')))
|
|
|
|
->setColumnClasses(array('', 'n', 'wide'))
|
|
|
|
->setNoDataString(
|
|
|
|
pht(
|
|
|
|
'The pattern you searched for was not found in the content of any '.
|
|
|
|
'files.'));
|
|
|
|
|
|
|
|
return $table;
|
|
|
|
}
|
|
|
|
|
|
|
|
private function renderFindResults(array $results) {
|
|
|
|
$drequest = $this->getDiffusionRequest();
|
|
|
|
|
|
|
|
$rows = array();
|
|
|
|
foreach ($results as $result) {
|
|
|
|
$href = $drequest->generateURI(array(
|
|
|
|
'action' => 'browse',
|
|
|
|
'path' => $result,
|
|
|
|
));
|
|
|
|
|
|
|
|
$readable = Filesystem::readablePath($result, $drequest->getPath());
|
|
|
|
|
|
|
|
$rows[] = array(
|
|
|
|
phutil_tag('a', array('href' => $href), $readable),
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
$table = id(new AphrontTableView($rows))
|
|
|
|
->setHeaders(array(pht('Path')))
|
|
|
|
->setColumnClasses(array('wide'))
|
|
|
|
->setNoDataString(
|
|
|
|
pht(
|
|
|
|
'The pattern you searched for did not match the names of any '.
|
|
|
|
'files.'));
|
|
|
|
|
|
|
|
return $table;
|
|
|
|
}
|
|
|
|
|
|
|
|
private function loadLintMessages() {
|
|
|
|
$drequest = $this->getDiffusionRequest();
|
|
|
|
$branch = $drequest->loadBranch();
|
|
|
|
|
|
|
|
if (!$branch || !$branch->getLintCommit()) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
$this->lintCommit = $branch->getLintCommit();
|
|
|
|
|
|
|
|
$conn = id(new PhabricatorRepository())->establishConnection('r');
|
|
|
|
|
|
|
|
$where = '';
|
|
|
|
if ($drequest->getLint()) {
|
|
|
|
$where = qsprintf(
|
|
|
|
$conn,
|
|
|
|
'AND code = %s',
|
|
|
|
$drequest->getLint());
|
|
|
|
}
|
|
|
|
|
|
|
|
$this->lintMessages = queryfx_all(
|
|
|
|
$conn,
|
|
|
|
'SELECT * FROM %T WHERE branchID = %d %Q AND path = %s',
|
|
|
|
PhabricatorRepository::TABLE_LINTMESSAGE,
|
|
|
|
$branch->getID(),
|
|
|
|
$where,
|
|
|
|
'/'.$drequest->getPath());
|
|
|
|
}
|
|
|
|
|
|
|
|
private function buildCorpus(
|
|
|
|
$show_blame,
|
|
|
|
$show_color,
|
|
|
|
DiffusionFileContent $file_content,
|
|
|
|
$needs_blame,
|
|
|
|
DiffusionRequest $drequest,
|
|
|
|
$path,
|
|
|
|
$data) {
|
|
|
|
|
2016-01-06 15:15:25 +01:00
|
|
|
$viewer = $this->getViewer();
|
|
|
|
|
|
|
|
$blame_handles = array();
|
|
|
|
if ($needs_blame) {
|
|
|
|
$blame = $this->loadBlame($path, $drequest->getCommit());
|
|
|
|
if ($blame) {
|
|
|
|
$author_phids = mpull($blame, 'getAuthorPHID');
|
|
|
|
$blame_handles = $viewer->loadHandles($author_phids);
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
$blame = array();
|
|
|
|
}
|
|
|
|
|
|
|
|
$file_corpus = $file_content->getCorpus();
|
2016-01-06 15:41:38 +01:00
|
|
|
$highlight_limit = DifferentialChangesetParser::HIGHLIGHT_BYTE_LIMIT;
|
|
|
|
$can_highlight = (strlen($file_corpus) <= $highlight_limit);
|
2016-01-06 15:15:25 +01:00
|
|
|
|
2016-01-05 14:18:59 +01:00
|
|
|
if (!$show_color) {
|
2016-01-06 15:15:25 +01:00
|
|
|
$lines = phutil_split_lines($file_corpus);
|
|
|
|
|
2016-01-05 14:18:59 +01:00
|
|
|
$style =
|
|
|
|
'border: none; width: 100%; height: 80em; font-family: monospace';
|
|
|
|
if (!$show_blame) {
|
|
|
|
$corpus = phutil_tag(
|
|
|
|
'textarea',
|
|
|
|
array(
|
|
|
|
'style' => $style,
|
|
|
|
),
|
2016-01-06 15:15:25 +01:00
|
|
|
$file_corpus);
|
2016-01-05 14:18:59 +01:00
|
|
|
} else {
|
|
|
|
$rows = array();
|
2016-01-06 15:15:25 +01:00
|
|
|
foreach ($lines as $line_number => $line) {
|
|
|
|
$commit = idx($blame, $line_number);
|
|
|
|
if ($commit) {
|
|
|
|
$author = $commit->renderAuthorShortName($blame_handles);
|
|
|
|
$commit_name = $commit->getShortName();
|
|
|
|
} else {
|
|
|
|
$author = null;
|
|
|
|
$commit_name = null;
|
|
|
|
}
|
|
|
|
|
|
|
|
$rows[] = sprintf(
|
|
|
|
'%-10s %-20s %s',
|
|
|
|
$commit_name,
|
|
|
|
$author,
|
|
|
|
$line);
|
2016-01-05 14:18:59 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
$corpus = phutil_tag(
|
|
|
|
'textarea',
|
|
|
|
array(
|
|
|
|
'style' => $style,
|
|
|
|
),
|
2016-01-06 15:15:25 +01:00
|
|
|
implode('', $rows));
|
2016-01-05 14:18:59 +01:00
|
|
|
}
|
|
|
|
} else {
|
2016-01-06 15:41:38 +01:00
|
|
|
if ($can_highlight) {
|
|
|
|
require_celerity_resource('syntax-highlighting-css');
|
2016-01-05 14:18:59 +01:00
|
|
|
|
2016-01-06 15:41:38 +01:00
|
|
|
$highlighted = PhabricatorSyntaxHighlighter::highlightWithFilename(
|
|
|
|
$path,
|
|
|
|
$file_corpus);
|
|
|
|
$lines = phutil_split_lines($highlighted);
|
|
|
|
} else {
|
|
|
|
$lines = phutil_split_lines($file_corpus);
|
|
|
|
}
|
2016-01-05 14:18:59 +01:00
|
|
|
|
2016-01-06 15:15:25 +01:00
|
|
|
$rows = $this->buildDisplayRows(
|
|
|
|
$lines,
|
|
|
|
$blame,
|
|
|
|
$show_blame,
|
|
|
|
$show_color);
|
2016-01-05 14:18:59 +01:00
|
|
|
|
|
|
|
$corpus_table = javelin_tag(
|
|
|
|
'table',
|
|
|
|
array(
|
|
|
|
'class' => 'diffusion-source remarkup-code PhabricatorMonospaced',
|
|
|
|
'sigil' => 'phabricator-source',
|
|
|
|
),
|
|
|
|
$rows);
|
|
|
|
|
|
|
|
if ($this->getRequest()->isAjax()) {
|
|
|
|
return $corpus_table;
|
|
|
|
}
|
|
|
|
|
|
|
|
$id = celerity_generate_unique_node_id();
|
|
|
|
|
|
|
|
$repo = $drequest->getRepository();
|
|
|
|
$symbol_repos = nonempty($repo->getSymbolSources(), array());
|
|
|
|
$symbol_repos[] = $repo->getPHID();
|
|
|
|
|
|
|
|
$lang = last(explode('.', $drequest->getPath()));
|
|
|
|
$repo_languages = $repo->getSymbolLanguages();
|
|
|
|
$repo_languages = nonempty($repo_languages, array());
|
|
|
|
$repo_languages = array_fill_keys($repo_languages, true);
|
|
|
|
|
|
|
|
$needs_symbols = true;
|
|
|
|
if ($repo_languages && $symbol_repos) {
|
|
|
|
$have_symbols = id(new DiffusionSymbolQuery())
|
|
|
|
->existsSymbolsInRepository($repo->getPHID());
|
|
|
|
if (!$have_symbols) {
|
|
|
|
$needs_symbols = false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if ($needs_symbols && $repo_languages) {
|
|
|
|
$needs_symbols = isset($repo_languages[$lang]);
|
|
|
|
}
|
|
|
|
|
|
|
|
if ($needs_symbols) {
|
|
|
|
Javelin::initBehavior(
|
|
|
|
'repository-crossreference',
|
|
|
|
array(
|
|
|
|
'container' => $id,
|
|
|
|
'lang' => $lang,
|
|
|
|
'repositories' => $symbol_repos,
|
|
|
|
));
|
|
|
|
}
|
|
|
|
|
|
|
|
$corpus = phutil_tag(
|
|
|
|
'div',
|
|
|
|
array(
|
|
|
|
'id' => $id,
|
|
|
|
),
|
|
|
|
$corpus_table);
|
|
|
|
|
|
|
|
Javelin::initBehavior('load-blame', array('id' => $id));
|
|
|
|
}
|
|
|
|
|
|
|
|
$edit = $this->renderEditButton();
|
|
|
|
$file = $this->renderFileButton();
|
|
|
|
$header = id(new PHUIHeaderView())
|
|
|
|
->setHeader(pht('File Contents'))
|
|
|
|
->addActionLink($edit)
|
|
|
|
->addActionLink($file);
|
|
|
|
|
|
|
|
$corpus = id(new PHUIObjectBoxView())
|
|
|
|
->setHeader($header)
|
|
|
|
->appendChild($corpus)
|
|
|
|
->setCollapsed(true);
|
|
|
|
|
2016-01-06 15:41:38 +01:00
|
|
|
if (!$can_highlight) {
|
|
|
|
$message = pht(
|
|
|
|
'This file is larger than %s, so syntax highlighting is disabled '.
|
|
|
|
'by default.',
|
|
|
|
phutil_format_bytes($highlight_limit));
|
|
|
|
|
|
|
|
$corpus->setInfoView(
|
|
|
|
id(new PHUIInfoView())
|
|
|
|
->setSeverity(PHUIInfoView::SEVERITY_WARNING)
|
|
|
|
->setErrors(array($message)));
|
|
|
|
}
|
|
|
|
|
2016-01-05 14:18:59 +01:00
|
|
|
return $corpus;
|
|
|
|
}
|
|
|
|
|
|
|
|
private function enrichActionView(
|
|
|
|
PhabricatorActionListView $view,
|
|
|
|
DiffusionRequest $drequest,
|
|
|
|
$show_blame,
|
|
|
|
$show_color) {
|
|
|
|
|
|
|
|
$viewer = $this->getRequest()->getUser();
|
|
|
|
$base_uri = $this->getRequest()->getRequestURI();
|
|
|
|
|
|
|
|
$view->addAction(
|
|
|
|
id(new PhabricatorActionView())
|
|
|
|
->setName(pht('Show Last Change'))
|
|
|
|
->setHref(
|
|
|
|
$drequest->generateURI(
|
|
|
|
array(
|
|
|
|
'action' => 'change',
|
|
|
|
)))
|
|
|
|
->setIcon('fa-backward'));
|
|
|
|
|
|
|
|
if ($show_blame) {
|
|
|
|
$blame_text = pht('Disable Blame');
|
|
|
|
$blame_icon = 'fa-exclamation-circle lightgreytext';
|
|
|
|
$blame_value = 0;
|
|
|
|
} else {
|
|
|
|
$blame_text = pht('Enable Blame');
|
|
|
|
$blame_icon = 'fa-exclamation-circle';
|
|
|
|
$blame_value = 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
$view->addAction(
|
|
|
|
id(new PhabricatorActionView())
|
|
|
|
->setName($blame_text)
|
|
|
|
->setHref($base_uri->alter('blame', $blame_value))
|
|
|
|
->setIcon($blame_icon)
|
|
|
|
->setUser($viewer)
|
|
|
|
->setRenderAsForm($viewer->isLoggedIn()));
|
|
|
|
|
|
|
|
if ($show_color) {
|
|
|
|
$highlight_text = pht('Disable Highlighting');
|
|
|
|
$highlight_icon = 'fa-star-o grey';
|
|
|
|
$highlight_value = 0;
|
|
|
|
} else {
|
|
|
|
$highlight_text = pht('Enable Highlighting');
|
|
|
|
$highlight_icon = 'fa-star';
|
|
|
|
$highlight_value = 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
$view->addAction(
|
|
|
|
id(new PhabricatorActionView())
|
|
|
|
->setName($highlight_text)
|
|
|
|
->setHref($base_uri->alter('color', $highlight_value))
|
|
|
|
->setIcon($highlight_icon)
|
|
|
|
->setUser($viewer)
|
|
|
|
->setRenderAsForm($viewer->isLoggedIn()));
|
|
|
|
|
|
|
|
$href = null;
|
|
|
|
if ($this->getRequest()->getStr('lint') !== null) {
|
|
|
|
$lint_text = pht('Hide %d Lint Message(s)', count($this->lintMessages));
|
|
|
|
$href = $base_uri->alter('lint', null);
|
|
|
|
|
|
|
|
} else if ($this->lintCommit === null) {
|
|
|
|
$lint_text = pht('Lint not Available');
|
|
|
|
} else {
|
|
|
|
$lint_text = pht(
|
|
|
|
'Show %d Lint Message(s)',
|
|
|
|
count($this->lintMessages));
|
|
|
|
$href = $this->getDiffusionRequest()->generateURI(array(
|
|
|
|
'action' => 'browse',
|
|
|
|
'commit' => $this->lintCommit,
|
|
|
|
))->alter('lint', '');
|
|
|
|
}
|
|
|
|
|
|
|
|
$view->addAction(
|
|
|
|
id(new PhabricatorActionView())
|
|
|
|
->setName($lint_text)
|
|
|
|
->setHref($href)
|
|
|
|
->setIcon('fa-exclamation-triangle')
|
|
|
|
->setDisabled(!$href));
|
|
|
|
|
|
|
|
return $view;
|
|
|
|
}
|
|
|
|
|
|
|
|
private function renderEditButton() {
|
|
|
|
$request = $this->getRequest();
|
|
|
|
$user = $request->getUser();
|
|
|
|
|
|
|
|
$drequest = $this->getDiffusionRequest();
|
|
|
|
|
|
|
|
$repository = $drequest->getRepository();
|
|
|
|
$path = $drequest->getPath();
|
|
|
|
$line = nonempty((int)$drequest->getLine(), 1);
|
|
|
|
|
|
|
|
$editor_link = $user->loadEditorLink($path, $line, $repository);
|
|
|
|
$template = $user->loadEditorLink($path, '%l', $repository);
|
|
|
|
|
|
|
|
$icon_edit = id(new PHUIIconView())
|
|
|
|
->setIconFont('fa-pencil');
|
|
|
|
$button = id(new PHUIButtonView())
|
|
|
|
->setTag('a')
|
|
|
|
->setText(pht('Open in Editor'))
|
|
|
|
->setHref($editor_link)
|
|
|
|
->setIcon($icon_edit)
|
|
|
|
->setID('editor_link')
|
|
|
|
->setMetadata(array('link_template' => $template))
|
|
|
|
->setDisabled(!$editor_link);
|
|
|
|
|
|
|
|
return $button;
|
|
|
|
}
|
|
|
|
|
|
|
|
private function renderFileButton($file_uri = null) {
|
|
|
|
|
|
|
|
$base_uri = $this->getRequest()->getRequestURI();
|
|
|
|
|
|
|
|
if ($file_uri) {
|
|
|
|
$text = pht('Download Raw File');
|
|
|
|
$href = $file_uri;
|
|
|
|
$icon = 'fa-download';
|
|
|
|
} else {
|
|
|
|
$text = pht('View Raw File');
|
|
|
|
$href = $base_uri->alter('view', 'raw');
|
|
|
|
$icon = 'fa-file-text';
|
|
|
|
}
|
|
|
|
|
|
|
|
$iconview = id(new PHUIIconView())
|
|
|
|
->setIconFont($icon);
|
|
|
|
$button = id(new PHUIButtonView())
|
|
|
|
->setTag('a')
|
|
|
|
->setText($text)
|
|
|
|
->setHref($href)
|
|
|
|
->setIcon($iconview);
|
|
|
|
|
|
|
|
return $button;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private function buildDisplayRows(
|
2016-01-06 15:15:25 +01:00
|
|
|
array $lines,
|
|
|
|
array $blame,
|
|
|
|
$show_color,
|
|
|
|
$show_blame) {
|
|
|
|
|
|
|
|
$drequest = $this->getDiffusionRequest();
|
2016-01-06 15:41:38 +01:00
|
|
|
$repository = $drequest->getRepository();
|
2016-01-05 14:18:59 +01:00
|
|
|
|
|
|
|
$handles = array();
|
2016-01-06 15:15:25 +01:00
|
|
|
if ($blame) {
|
|
|
|
$epoch_list = mpull($blame, 'getEpoch', 'getID');
|
|
|
|
$epoch_list = array_filter($epoch_list);
|
|
|
|
$epoch_list = array_unique($epoch_list);
|
|
|
|
$epoch_list = array_values($epoch_list);
|
|
|
|
|
2016-01-05 14:18:59 +01:00
|
|
|
$epoch_min = min($epoch_list);
|
|
|
|
$epoch_max = max($epoch_list);
|
|
|
|
$epoch_range = ($epoch_max - $epoch_min) + 1;
|
|
|
|
}
|
|
|
|
|
2016-01-06 15:15:25 +01:00
|
|
|
|
2016-01-05 14:18:59 +01:00
|
|
|
$line_arr = array();
|
|
|
|
$line_str = $drequest->getLine();
|
|
|
|
$ranges = explode(',', $line_str);
|
|
|
|
foreach ($ranges as $range) {
|
|
|
|
if (strpos($range, '-') !== false) {
|
|
|
|
list($min, $max) = explode('-', $range, 2);
|
|
|
|
$line_arr[] = array(
|
|
|
|
'min' => min($min, $max),
|
|
|
|
'max' => max($min, $max),
|
|
|
|
);
|
|
|
|
} else if (strlen($range)) {
|
|
|
|
$line_arr[] = array(
|
|
|
|
'min' => $range,
|
|
|
|
'max' => $range,
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
$display = array();
|
|
|
|
|
|
|
|
$line_number = 1;
|
2016-01-06 15:15:25 +01:00
|
|
|
$last_commit = null;
|
2016-01-05 14:18:59 +01:00
|
|
|
$color = null;
|
2016-01-06 15:15:25 +01:00
|
|
|
foreach ($lines as $line_index => $line) {
|
2016-01-05 14:18:59 +01:00
|
|
|
$display_line = array(
|
|
|
|
'epoch' => null,
|
|
|
|
'commit' => null,
|
|
|
|
'author' => null,
|
|
|
|
'target' => null,
|
|
|
|
'highlighted' => null,
|
|
|
|
'line' => $line_number,
|
|
|
|
'data' => $line,
|
|
|
|
);
|
|
|
|
|
|
|
|
if ($show_blame) {
|
|
|
|
// If the line's rev is same as the line above, show empty content
|
|
|
|
// with same color; otherwise generate blame info. The newer a change
|
|
|
|
// is, the more saturated the color.
|
|
|
|
|
2016-01-06 15:15:25 +01:00
|
|
|
$commit = idx($blame, $line_index, $last_commit);
|
2016-01-05 14:18:59 +01:00
|
|
|
|
2016-01-06 15:15:25 +01:00
|
|
|
if ($commit && $last_commit &&
|
|
|
|
($last_commit->getID() == $commit->getID())) {
|
2016-01-05 14:18:59 +01:00
|
|
|
$display_line['color'] = $color;
|
|
|
|
} else {
|
2016-01-06 15:15:25 +01:00
|
|
|
if ($commit) {
|
|
|
|
$epoch = $commit->getEpoch();
|
|
|
|
} else {
|
|
|
|
$epoch = null;
|
|
|
|
}
|
2016-01-05 14:18:59 +01:00
|
|
|
|
2016-01-06 15:15:25 +01:00
|
|
|
if (!$epoch) {
|
|
|
|
if (!$blame) {
|
|
|
|
$color = '#f6f6f6';
|
|
|
|
} else {
|
|
|
|
$color = '#ffd'; // Render as warning.
|
|
|
|
}
|
2016-01-05 14:18:59 +01:00
|
|
|
} else {
|
2016-01-06 15:15:25 +01:00
|
|
|
$color_ratio = ($epoch - $epoch_min) / $epoch_range;
|
2016-01-05 14:18:59 +01:00
|
|
|
$color_value = 0xE6 * (1.0 - $color_ratio);
|
|
|
|
$color = sprintf(
|
|
|
|
'#%02x%02x%02x',
|
|
|
|
$color_value,
|
|
|
|
0xF6,
|
|
|
|
$color_value);
|
|
|
|
}
|
|
|
|
|
2016-01-06 15:15:25 +01:00
|
|
|
$display_line['epoch'] = $epoch;
|
2016-01-05 14:18:59 +01:00
|
|
|
$display_line['color'] = $color;
|
|
|
|
|
2016-01-06 15:15:25 +01:00
|
|
|
if ($commit) {
|
|
|
|
$display_line['commit'] = $commit;
|
2016-01-05 14:18:59 +01:00
|
|
|
} else {
|
2016-01-06 15:15:25 +01:00
|
|
|
$display_line['commit'] = null;
|
2016-01-05 14:18:59 +01:00
|
|
|
}
|
|
|
|
|
2016-01-06 15:15:25 +01:00
|
|
|
$last_commit = $commit;
|
2016-01-05 14:18:59 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if ($line_arr) {
|
|
|
|
if ($line_number == $line_arr[0]['min']) {
|
|
|
|
$display_line['target'] = true;
|
|
|
|
}
|
|
|
|
foreach ($line_arr as $range) {
|
|
|
|
if ($line_number >= $range['min'] &&
|
|
|
|
$line_number <= $range['max']) {
|
|
|
|
$display_line['highlighted'] = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
$display[] = $display_line;
|
|
|
|
++$line_number;
|
|
|
|
}
|
|
|
|
|
|
|
|
$request = $this->getRequest();
|
|
|
|
$viewer = $request->getUser();
|
|
|
|
|
2016-01-06 15:15:25 +01:00
|
|
|
$commits = mpull($blame, null, 'getCommitIdentifier');
|
2016-01-05 14:18:59 +01:00
|
|
|
|
|
|
|
$revision_ids = id(new DifferentialRevision())
|
|
|
|
->loadIDsByCommitPHIDs(mpull($commits, 'getPHID'));
|
|
|
|
$revisions = array();
|
|
|
|
if ($revision_ids) {
|
|
|
|
$revisions = id(new DifferentialRevisionQuery())
|
|
|
|
->setViewer($viewer)
|
|
|
|
->withIDs($revision_ids)
|
|
|
|
->execute();
|
|
|
|
}
|
|
|
|
|
|
|
|
$phids = array();
|
2016-01-06 15:15:25 +01:00
|
|
|
foreach ($commits as $blame_commit) {
|
|
|
|
if ($blame_commit->getAuthorPHID()) {
|
|
|
|
$phids[] = $blame_commit->getAuthorPHID();
|
2016-01-05 14:18:59 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
foreach ($revisions as $revision) {
|
|
|
|
if ($revision->getAuthorPHID()) {
|
|
|
|
$phids[] = $revision->getAuthorPHID();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
$handles = $this->loadViewerHandles($phids);
|
|
|
|
|
|
|
|
$engine = null;
|
|
|
|
$inlines = array();
|
|
|
|
if ($this->getRequest()->getStr('lint') !== null && $this->lintMessages) {
|
|
|
|
$engine = new PhabricatorMarkupEngine();
|
|
|
|
$engine->setViewer($viewer);
|
|
|
|
|
|
|
|
foreach ($this->lintMessages as $message) {
|
|
|
|
$inline = id(new PhabricatorAuditInlineComment())
|
|
|
|
->setSyntheticAuthor(
|
|
|
|
ArcanistLintSeverity::getStringForSeverity($message['severity']).
|
|
|
|
' '.$message['code'].' ('.$message['name'].')')
|
|
|
|
->setLineNumber($message['line'])
|
|
|
|
->setContent($message['description']);
|
|
|
|
$inlines[$message['line']][] = $inline;
|
|
|
|
|
|
|
|
$engine->addObject(
|
|
|
|
$inline,
|
|
|
|
PhabricatorInlineCommentInterface::MARKUP_FIELD_BODY);
|
|
|
|
}
|
|
|
|
|
|
|
|
$engine->process();
|
|
|
|
require_celerity_resource('differential-changeset-view-css');
|
|
|
|
}
|
|
|
|
|
|
|
|
$rows = $this->renderInlines(
|
|
|
|
idx($inlines, 0, array()),
|
|
|
|
$show_blame,
|
|
|
|
(bool)$this->coverage,
|
|
|
|
$engine);
|
|
|
|
|
2016-01-06 15:41:38 +01:00
|
|
|
// NOTE: We're doing this manually because rendering is otherwise
|
|
|
|
// dominated by URI generation for very large files.
|
|
|
|
$line_base = (string)$repository->generateURI(
|
|
|
|
array(
|
|
|
|
'action' => 'browse',
|
|
|
|
'stable' => true,
|
|
|
|
));
|
|
|
|
|
|
|
|
require_celerity_resource('aphront-tooltip-css');
|
|
|
|
Javelin::initBehavior('phabricator-oncopy');
|
|
|
|
Javelin::initBehavior('phabricator-tooltips');
|
|
|
|
Javelin::initBehavior('phabricator-line-linker');
|
|
|
|
|
2016-01-05 14:18:59 +01:00
|
|
|
foreach ($display as $line) {
|
2016-01-06 15:41:38 +01:00
|
|
|
$line_href = $line_base.'$'.$line['line'];
|
2016-01-05 14:18:59 +01:00
|
|
|
|
|
|
|
$blame = array();
|
|
|
|
$style = null;
|
|
|
|
if (array_key_exists('color', $line)) {
|
|
|
|
if ($line['color']) {
|
|
|
|
$style = 'background: '.$line['color'].';';
|
|
|
|
}
|
|
|
|
|
|
|
|
$before_link = null;
|
|
|
|
$commit_link = null;
|
|
|
|
$revision_link = null;
|
|
|
|
if (idx($line, 'commit')) {
|
|
|
|
$commit = $line['commit'];
|
|
|
|
|
2016-01-06 15:15:25 +01:00
|
|
|
if ($commit) {
|
2016-01-05 14:18:59 +01:00
|
|
|
$tooltip = $this->renderCommitTooltip(
|
2016-01-06 15:15:25 +01:00
|
|
|
$commit,
|
2016-01-05 14:18:59 +01:00
|
|
|
$handles,
|
2016-01-06 15:15:25 +01:00
|
|
|
$commit->renderAuthorLink($handles));
|
2016-01-05 14:18:59 +01:00
|
|
|
} else {
|
|
|
|
$tooltip = null;
|
|
|
|
}
|
|
|
|
|
|
|
|
$commit_link = javelin_tag(
|
|
|
|
'a',
|
|
|
|
array(
|
|
|
|
'href' => $drequest->generateURI(
|
|
|
|
array(
|
|
|
|
'action' => 'commit',
|
2016-01-06 15:15:25 +01:00
|
|
|
'commit' => $commit->getCommitIdentifier(),
|
2016-01-05 14:18:59 +01:00
|
|
|
)),
|
|
|
|
'sigil' => 'has-tooltip',
|
|
|
|
'meta' => array(
|
|
|
|
'tip' => $tooltip,
|
|
|
|
'align' => 'E',
|
|
|
|
'size' => 600,
|
|
|
|
),
|
|
|
|
),
|
2016-01-06 15:15:25 +01:00
|
|
|
$commit->getShortName());
|
2016-01-05 14:18:59 +01:00
|
|
|
|
|
|
|
$revision_id = null;
|
2016-01-06 15:15:25 +01:00
|
|
|
if ($commit) {
|
|
|
|
$revision_id = idx($revision_ids, $commit->getPHID());
|
2016-01-05 14:18:59 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
if ($revision_id) {
|
|
|
|
$revision = idx($revisions, $revision_id);
|
|
|
|
if ($revision) {
|
|
|
|
$tooltip = $this->renderRevisionTooltip($revision, $handles);
|
|
|
|
$revision_link = javelin_tag(
|
|
|
|
'a',
|
|
|
|
array(
|
|
|
|
'href' => '/D'.$revision->getID(),
|
|
|
|
'sigil' => 'has-tooltip',
|
|
|
|
'meta' => array(
|
|
|
|
'tip' => $tooltip,
|
|
|
|
'align' => 'E',
|
|
|
|
'size' => 600,
|
|
|
|
),
|
|
|
|
),
|
|
|
|
'D'.$revision->getID());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-01-06 15:41:38 +01:00
|
|
|
if ($commit) {
|
|
|
|
$identifier = $commit->getCommitIdentifier();
|
|
|
|
$skip_href = $line_href.'?before='.$identifier.'&view=blame';
|
|
|
|
|
|
|
|
$before_link = javelin_tag(
|
|
|
|
'a',
|
|
|
|
array(
|
|
|
|
'href' => $skip_href,
|
|
|
|
'sigil' => 'has-tooltip',
|
|
|
|
'meta' => array(
|
|
|
|
'tip' => pht('Skip Past This Commit'),
|
|
|
|
'align' => 'E',
|
|
|
|
'size' => 300,
|
|
|
|
),
|
2016-01-05 14:18:59 +01:00
|
|
|
),
|
2016-01-06 15:41:38 +01:00
|
|
|
"\xC2\xAB");
|
|
|
|
}
|
2016-01-05 14:18:59 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
$blame[] = phutil_tag(
|
|
|
|
'th',
|
|
|
|
array(
|
|
|
|
'class' => 'diffusion-blame-link',
|
|
|
|
),
|
|
|
|
$before_link);
|
|
|
|
|
|
|
|
$object_links = array();
|
|
|
|
$object_links[] = $commit_link;
|
|
|
|
if ($revision_link) {
|
|
|
|
$object_links[] = phutil_tag('span', array(), '/');
|
|
|
|
$object_links[] = $revision_link;
|
|
|
|
}
|
|
|
|
|
|
|
|
$blame[] = phutil_tag(
|
|
|
|
'th',
|
|
|
|
array(
|
|
|
|
'class' => 'diffusion-rev-link',
|
|
|
|
),
|
|
|
|
$object_links);
|
|
|
|
}
|
|
|
|
|
|
|
|
$line_link = phutil_tag(
|
|
|
|
'a',
|
|
|
|
array(
|
|
|
|
'href' => $line_href,
|
|
|
|
'style' => $style,
|
|
|
|
),
|
|
|
|
$line['line']);
|
|
|
|
|
|
|
|
$blame[] = javelin_tag(
|
|
|
|
'th',
|
|
|
|
array(
|
|
|
|
'class' => 'diffusion-line-link',
|
|
|
|
'sigil' => 'phabricator-source-line',
|
|
|
|
'style' => $style,
|
|
|
|
),
|
|
|
|
$line_link);
|
|
|
|
|
|
|
|
if ($line['target']) {
|
|
|
|
Javelin::initBehavior(
|
|
|
|
'diffusion-jump-to',
|
|
|
|
array(
|
|
|
|
'target' => 'scroll_target',
|
|
|
|
));
|
|
|
|
$anchor_text = phutil_tag(
|
|
|
|
'a',
|
|
|
|
array(
|
|
|
|
'id' => 'scroll_target',
|
|
|
|
),
|
|
|
|
'');
|
|
|
|
} else {
|
|
|
|
$anchor_text = null;
|
|
|
|
}
|
|
|
|
|
|
|
|
$blame[] = phutil_tag(
|
|
|
|
'td',
|
|
|
|
array(
|
|
|
|
),
|
|
|
|
array(
|
|
|
|
$anchor_text,
|
|
|
|
|
|
|
|
// NOTE: See phabricator-oncopy behavior.
|
|
|
|
"\xE2\x80\x8B",
|
|
|
|
|
|
|
|
// TODO: [HTML] Not ideal.
|
|
|
|
phutil_safe_html(str_replace("\t", ' ', $line['data'])),
|
|
|
|
));
|
|
|
|
|
|
|
|
if ($this->coverage) {
|
|
|
|
require_celerity_resource('differential-changeset-view-css');
|
|
|
|
$cov_index = $line['line'] - 1;
|
|
|
|
|
|
|
|
if (isset($this->coverage[$cov_index])) {
|
|
|
|
$cov_class = $this->coverage[$cov_index];
|
|
|
|
} else {
|
|
|
|
$cov_class = 'N';
|
|
|
|
}
|
|
|
|
|
|
|
|
$blame[] = phutil_tag(
|
|
|
|
'td',
|
|
|
|
array(
|
|
|
|
'class' => 'cov cov-'.$cov_class,
|
|
|
|
),
|
|
|
|
'');
|
|
|
|
}
|
|
|
|
|
|
|
|
$rows[] = phutil_tag(
|
|
|
|
'tr',
|
|
|
|
array(
|
|
|
|
'class' => ($line['highlighted'] ?
|
|
|
|
'phabricator-source-highlight' :
|
|
|
|
null),
|
|
|
|
),
|
|
|
|
$blame);
|
|
|
|
|
|
|
|
$cur_inlines = $this->renderInlines(
|
|
|
|
idx($inlines, $line['line'], array()),
|
|
|
|
$show_blame,
|
|
|
|
$this->coverage,
|
|
|
|
$engine);
|
|
|
|
foreach ($cur_inlines as $cur_inline) {
|
|
|
|
$rows[] = $cur_inline;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return $rows;
|
|
|
|
}
|
|
|
|
|
|
|
|
private function renderInlines(
|
|
|
|
array $inlines,
|
2016-01-06 15:15:25 +01:00
|
|
|
$show_blame,
|
2016-01-05 14:18:59 +01:00
|
|
|
$has_coverage,
|
|
|
|
$engine) {
|
|
|
|
|
|
|
|
$rows = array();
|
|
|
|
foreach ($inlines as $inline) {
|
|
|
|
|
|
|
|
// TODO: This should use modern scaffolding code.
|
|
|
|
|
|
|
|
$inline_view = id(new PHUIDiffInlineCommentDetailView())
|
|
|
|
->setUser($this->getViewer())
|
|
|
|
->setMarkupEngine($engine)
|
|
|
|
->setInlineComment($inline)
|
|
|
|
->render();
|
|
|
|
|
2016-01-06 15:15:25 +01:00
|
|
|
$row = array_fill(0, ($show_blame ? 3 : 1), phutil_tag('th'));
|
2016-01-05 14:18:59 +01:00
|
|
|
|
|
|
|
$row[] = phutil_tag('td', array(), $inline_view);
|
|
|
|
|
|
|
|
if ($has_coverage) {
|
|
|
|
$row[] = phutil_tag(
|
|
|
|
'td',
|
|
|
|
array(
|
|
|
|
'class' => 'cov cov-I',
|
|
|
|
));
|
|
|
|
}
|
|
|
|
|
|
|
|
$rows[] = phutil_tag('tr', array('class' => 'inline'), $row);
|
|
|
|
}
|
|
|
|
|
|
|
|
return $rows;
|
|
|
|
}
|
|
|
|
|
|
|
|
private function loadFileForData($path, $data) {
|
|
|
|
$file = PhabricatorFile::buildFromFileDataOrHash(
|
|
|
|
$data,
|
|
|
|
array(
|
|
|
|
'name' => basename($path),
|
|
|
|
'ttl' => time() + 60 * 60 * 24,
|
|
|
|
'viewPolicy' => PhabricatorPolicies::POLICY_NOONE,
|
|
|
|
));
|
|
|
|
|
|
|
|
$unguarded = AphrontWriteGuard::beginScopedUnguardedWrites();
|
|
|
|
$file->attachToObject(
|
|
|
|
$this->getDiffusionRequest()->getRepository()->getPHID());
|
|
|
|
unset($unguarded);
|
|
|
|
|
|
|
|
return $file;
|
|
|
|
}
|
|
|
|
|
|
|
|
private function buildRawResponse($path, $data) {
|
|
|
|
$file = $this->loadFileForData($path, $data);
|
|
|
|
return $file->getRedirectResponse();
|
|
|
|
}
|
|
|
|
|
|
|
|
private function buildImageCorpus($file_uri) {
|
|
|
|
$properties = new PHUIPropertyListView();
|
|
|
|
|
|
|
|
$properties->addImageContent(
|
|
|
|
phutil_tag(
|
|
|
|
'img',
|
|
|
|
array(
|
|
|
|
'src' => $file_uri,
|
|
|
|
)));
|
|
|
|
|
|
|
|
$file = $this->renderFileButton($file_uri);
|
|
|
|
$header = id(new PHUIHeaderView())
|
|
|
|
->setHeader(pht('Image'))
|
|
|
|
->addActionLink($file);
|
|
|
|
|
|
|
|
return id(new PHUIObjectBoxView())
|
|
|
|
->setHeader($header)
|
|
|
|
->addPropertyList($properties);
|
|
|
|
}
|
|
|
|
|
|
|
|
private function buildBinaryCorpus($file_uri, $data) {
|
|
|
|
|
|
|
|
$size = new PhutilNumber(strlen($data));
|
|
|
|
$text = pht('This is a binary file. It is %s byte(s) in length.', $size);
|
|
|
|
$text = id(new PHUIBoxView())
|
|
|
|
->addPadding(PHUI::PADDING_LARGE)
|
|
|
|
->appendChild($text);
|
|
|
|
|
|
|
|
$file = $this->renderFileButton($file_uri);
|
|
|
|
$header = id(new PHUIHeaderView())
|
|
|
|
->setHeader(pht('Details'))
|
|
|
|
->addActionLink($file);
|
|
|
|
|
|
|
|
$box = id(new PHUIObjectBoxView())
|
|
|
|
->setHeader($header)
|
|
|
|
->appendChild($text);
|
|
|
|
|
|
|
|
return $box;
|
|
|
|
}
|
|
|
|
|
|
|
|
private function buildErrorCorpus($message) {
|
|
|
|
$text = id(new PHUIBoxView())
|
|
|
|
->addPadding(PHUI::PADDING_LARGE)
|
|
|
|
->appendChild($message);
|
|
|
|
|
|
|
|
$header = id(new PHUIHeaderView())
|
|
|
|
->setHeader(pht('Details'));
|
|
|
|
|
|
|
|
$box = id(new PHUIObjectBoxView())
|
|
|
|
->setHeader($header)
|
|
|
|
->appendChild($text);
|
|
|
|
|
|
|
|
return $box;
|
|
|
|
}
|
|
|
|
|
|
|
|
private function buildBeforeResponse($before) {
|
|
|
|
$request = $this->getRequest();
|
|
|
|
$drequest = $this->getDiffusionRequest();
|
|
|
|
|
|
|
|
// NOTE: We need to get the grandparent so we can capture filename changes
|
|
|
|
// in the parent.
|
|
|
|
|
|
|
|
$parent = $this->loadParentCommitOf($before);
|
|
|
|
$old_filename = null;
|
|
|
|
$was_created = false;
|
|
|
|
if ($parent) {
|
|
|
|
$grandparent = $this->loadParentCommitOf($parent);
|
|
|
|
|
|
|
|
if ($grandparent) {
|
|
|
|
$rename_query = new DiffusionRenameHistoryQuery();
|
|
|
|
$rename_query->setRequest($drequest);
|
|
|
|
$rename_query->setOldCommit($grandparent);
|
|
|
|
$rename_query->setViewer($request->getUser());
|
|
|
|
$old_filename = $rename_query->loadOldFilename();
|
|
|
|
$was_created = $rename_query->getWasCreated();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
$follow = null;
|
|
|
|
if ($was_created) {
|
|
|
|
// If the file was created in history, that means older commits won't
|
|
|
|
// have it. Since we know it existed at 'before', it must have been
|
|
|
|
// created then; jump there.
|
|
|
|
$target_commit = $before;
|
|
|
|
$follow = 'created';
|
|
|
|
} else if ($parent) {
|
|
|
|
// If we found a parent, jump to it. This is the normal case.
|
|
|
|
$target_commit = $parent;
|
|
|
|
} else {
|
|
|
|
// If there's no parent, this was probably created in the initial commit?
|
|
|
|
// And the "was_created" check will fail because we can't identify the
|
|
|
|
// grandparent. Keep the user at 'before'.
|
|
|
|
$target_commit = $before;
|
|
|
|
$follow = 'first';
|
|
|
|
}
|
|
|
|
|
|
|
|
$path = $drequest->getPath();
|
|
|
|
$renamed = null;
|
|
|
|
if ($old_filename !== null &&
|
|
|
|
$old_filename !== '/'.$path) {
|
|
|
|
$renamed = $path;
|
|
|
|
$path = $old_filename;
|
|
|
|
}
|
|
|
|
|
|
|
|
$line = null;
|
|
|
|
// If there's a follow error, drop the line so the user sees the message.
|
|
|
|
if (!$follow) {
|
|
|
|
$line = $this->getBeforeLineNumber($target_commit);
|
|
|
|
}
|
|
|
|
|
|
|
|
$before_uri = $drequest->generateURI(
|
|
|
|
array(
|
|
|
|
'action' => 'browse',
|
|
|
|
'commit' => $target_commit,
|
|
|
|
'line' => $line,
|
|
|
|
'path' => $path,
|
|
|
|
));
|
|
|
|
|
|
|
|
$before_uri->setQueryParams($request->getRequestURI()->getQueryParams());
|
|
|
|
$before_uri = $before_uri->alter('before', null);
|
|
|
|
$before_uri = $before_uri->alter('renamed', $renamed);
|
|
|
|
$before_uri = $before_uri->alter('follow', $follow);
|
|
|
|
|
|
|
|
return id(new AphrontRedirectResponse())->setURI($before_uri);
|
|
|
|
}
|
|
|
|
|
|
|
|
private function getBeforeLineNumber($target_commit) {
|
|
|
|
$drequest = $this->getDiffusionRequest();
|
|
|
|
|
|
|
|
$line = $drequest->getLine();
|
|
|
|
if (!$line) {
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
|
|
|
$raw_diff = $this->callConduitWithDiffusionRequest(
|
|
|
|
'diffusion.rawdiffquery',
|
|
|
|
array(
|
|
|
|
'commit' => $drequest->getCommit(),
|
|
|
|
'path' => $drequest->getPath(),
|
|
|
|
'againstCommit' => $target_commit,
|
|
|
|
));
|
|
|
|
$old_line = 0;
|
|
|
|
$new_line = 0;
|
|
|
|
|
|
|
|
foreach (explode("\n", $raw_diff) as $text) {
|
|
|
|
if ($text[0] == '-' || $text[0] == ' ') {
|
|
|
|
$old_line++;
|
|
|
|
}
|
|
|
|
if ($text[0] == '+' || $text[0] == ' ') {
|
|
|
|
$new_line++;
|
|
|
|
}
|
|
|
|
if ($new_line == $line) {
|
|
|
|
return $old_line;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// We didn't find the target line.
|
|
|
|
return $line;
|
|
|
|
}
|
|
|
|
|
|
|
|
private function loadParentCommitOf($commit) {
|
|
|
|
$drequest = $this->getDiffusionRequest();
|
|
|
|
$user = $this->getRequest()->getUser();
|
|
|
|
|
|
|
|
$before_req = DiffusionRequest::newFromDictionary(
|
|
|
|
array(
|
|
|
|
'user' => $user,
|
|
|
|
'repository' => $drequest->getRepository(),
|
|
|
|
'commit' => $commit,
|
|
|
|
));
|
|
|
|
|
|
|
|
$parents = DiffusionQuery::callConduitWithDiffusionRequest(
|
|
|
|
$user,
|
|
|
|
$before_req,
|
|
|
|
'diffusion.commitparentsquery',
|
|
|
|
array(
|
|
|
|
'commit' => $commit,
|
|
|
|
));
|
|
|
|
|
|
|
|
return head($parents);
|
|
|
|
}
|
|
|
|
|
|
|
|
private function renderRevisionTooltip(
|
|
|
|
DifferentialRevision $revision,
|
|
|
|
array $handles) {
|
|
|
|
$viewer = $this->getRequest()->getUser();
|
|
|
|
|
|
|
|
$date = phabricator_date($revision->getDateModified(), $viewer);
|
|
|
|
$id = $revision->getID();
|
|
|
|
$title = $revision->getTitle();
|
|
|
|
$header = "D{$id} {$title}";
|
|
|
|
|
|
|
|
$author = $handles[$revision->getAuthorPHID()]->getName();
|
|
|
|
|
|
|
|
return "{$header}\n{$date} \xC2\xB7 {$author}";
|
|
|
|
}
|
|
|
|
|
|
|
|
private function renderCommitTooltip(
|
|
|
|
PhabricatorRepositoryCommit $commit,
|
|
|
|
array $handles,
|
|
|
|
$author) {
|
|
|
|
|
|
|
|
$viewer = $this->getRequest()->getUser();
|
|
|
|
|
|
|
|
$date = phabricator_date($commit->getEpoch(), $viewer);
|
|
|
|
$summary = trim($commit->getSummary());
|
|
|
|
|
|
|
|
if ($commit->getAuthorPHID()) {
|
|
|
|
$author = $handles[$commit->getAuthorPHID()]->getName();
|
|
|
|
}
|
|
|
|
|
|
|
|
return "{$summary}\n{$date} \xC2\xB7 {$author}";
|
|
|
|
}
|
|
|
|
|
Improve organization of Diffusion browse controllers
Summary:
Currently we have this:
- DiffusionController (abstract, has some random shared browse code)
- DiffusionBrowseController (concrete, Handles routing, directories, and search)
- DiffusionBrowseFileController (concrete, handles files)
Instead, do this:
- DiffusionController (no browse-related code)
- DiffusionBrowseController (abstract, shared browse code)
- DiffusionBrowseMainController (concrete, handles routing)
- DiffusionBrowseDirectoryController (concrete, handles directories)
- DiffusionBrowseFileController (concrete, handles files)
- DiffusionBrowseSearchController (concrete, handles search)
Feels a lot cleaner.
Test Plan: Looked at directories, searches, and files.
Reviewers: btrahan
Reviewed By: btrahan
CC: aran
Differential Revision: https://secure.phabricator.com/D7045
2013-09-20 01:01:34 +02:00
|
|
|
protected function renderSearchForm($collapsed) {
|
2013-04-23 20:12:02 +02:00
|
|
|
$drequest = $this->getDiffusionRequest();
|
2014-02-01 20:48:28 +01:00
|
|
|
|
|
|
|
$forms = array();
|
2013-04-23 20:12:02 +02:00
|
|
|
$form = id(new AphrontFormView())
|
|
|
|
->setUser($this->getRequest()->getUser())
|
2013-08-26 20:53:11 +02:00
|
|
|
->setMethod('GET');
|
2013-04-23 20:12:02 +02:00
|
|
|
|
|
|
|
switch ($drequest->getRepository()->getVersionControlSystem()) {
|
|
|
|
case PhabricatorRepositoryType::REPOSITORY_TYPE_SVN:
|
2014-02-01 20:48:28 +01:00
|
|
|
$forms[] = id(clone $form)
|
|
|
|
->appendChild(pht('Search is not available in Subversion.'));
|
2013-04-23 20:12:02 +02:00
|
|
|
break;
|
|
|
|
default:
|
2014-02-01 20:48:28 +01:00
|
|
|
$forms[] = id(clone $form)
|
2013-04-23 20:12:02 +02:00
|
|
|
->appendChild(
|
2014-02-01 20:48:28 +01:00
|
|
|
id(new AphrontFormTextWithSubmitControl())
|
|
|
|
->setLabel(pht('File Name'))
|
|
|
|
->setSubmitLabel(pht('Search File Names'))
|
|
|
|
->setName('find')
|
|
|
|
->setValue($this->getRequest()->getStr('find')));
|
|
|
|
$forms[] = id(clone $form)
|
2013-04-23 20:12:02 +02:00
|
|
|
->appendChild(
|
2014-02-01 20:48:28 +01:00
|
|
|
id(new AphrontFormTextWithSubmitControl())
|
|
|
|
->setLabel(pht('Pattern'))
|
|
|
|
->setSubmitLabel(pht('Grep File Content'))
|
|
|
|
->setName('grep')
|
|
|
|
->setValue($this->getRequest()->getStr('grep')));
|
2013-04-23 20:12:02 +02:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2013-05-11 17:23:19 +02:00
|
|
|
$filter = new AphrontListFilterView();
|
2014-02-01 20:48:28 +01:00
|
|
|
$filter->appendChild($forms);
|
|
|
|
|
Improve organization of Diffusion browse controllers
Summary:
Currently we have this:
- DiffusionController (abstract, has some random shared browse code)
- DiffusionBrowseController (concrete, Handles routing, directories, and search)
- DiffusionBrowseFileController (concrete, handles files)
Instead, do this:
- DiffusionController (no browse-related code)
- DiffusionBrowseController (abstract, shared browse code)
- DiffusionBrowseMainController (concrete, handles routing)
- DiffusionBrowseDirectoryController (concrete, handles directories)
- DiffusionBrowseFileController (concrete, handles files)
- DiffusionBrowseSearchController (concrete, handles search)
Feels a lot cleaner.
Test Plan: Looked at directories, searches, and files.
Reviewers: btrahan
Reviewed By: btrahan
CC: aran
Differential Revision: https://secure.phabricator.com/D7045
2013-09-20 01:01:34 +02:00
|
|
|
if ($collapsed) {
|
2013-09-19 20:57:33 +02:00
|
|
|
$filter->setCollapsed(
|
|
|
|
pht('Show Search'),
|
|
|
|
pht('Hide Search'),
|
2014-02-01 20:48:28 +01:00
|
|
|
pht('Search for file names or content in this directory.'),
|
2013-09-19 20:57:33 +02:00
|
|
|
'#');
|
|
|
|
}
|
|
|
|
|
2015-05-22 17:22:25 +02:00
|
|
|
$filter = id(new PHUIBoxView())
|
|
|
|
->addClass('mlt mlb')
|
|
|
|
->appendChild($filter);
|
|
|
|
|
2013-05-11 17:23:19 +02:00
|
|
|
return $filter;
|
2013-04-23 20:12:02 +02:00
|
|
|
}
|
|
|
|
|
Improve organization of Diffusion browse controllers
Summary:
Currently we have this:
- DiffusionController (abstract, has some random shared browse code)
- DiffusionBrowseController (concrete, Handles routing, directories, and search)
- DiffusionBrowseFileController (concrete, handles files)
Instead, do this:
- DiffusionController (no browse-related code)
- DiffusionBrowseController (abstract, shared browse code)
- DiffusionBrowseMainController (concrete, handles routing)
- DiffusionBrowseDirectoryController (concrete, handles directories)
- DiffusionBrowseFileController (concrete, handles files)
- DiffusionBrowseSearchController (concrete, handles search)
Feels a lot cleaner.
Test Plan: Looked at directories, searches, and files.
Reviewers: btrahan
Reviewed By: btrahan
CC: aran
Differential Revision: https://secure.phabricator.com/D7045
2013-09-20 01:01:34 +02:00
|
|
|
protected function markupText($text) {
|
2012-04-24 03:36:25 +02:00
|
|
|
$engine = PhabricatorMarkupEngine::newDiffusionMarkupEngine();
|
2013-03-04 21:33:05 +01:00
|
|
|
$engine->setConfig('viewer', $this->getRequest()->getUser());
|
2013-02-13 23:50:15 +01:00
|
|
|
$text = $engine->markupText($text);
|
2012-04-24 03:36:25 +02:00
|
|
|
|
2013-01-18 09:32:58 +01:00
|
|
|
$text = phutil_tag(
|
2012-04-24 03:36:25 +02:00
|
|
|
'div',
|
|
|
|
array(
|
|
|
|
'class' => 'phabricator-remarkup',
|
|
|
|
),
|
|
|
|
$text);
|
|
|
|
|
|
|
|
return $text;
|
|
|
|
}
|
|
|
|
|
Improve organization of Diffusion browse controllers
Summary:
Currently we have this:
- DiffusionController (abstract, has some random shared browse code)
- DiffusionBrowseController (concrete, Handles routing, directories, and search)
- DiffusionBrowseFileController (concrete, handles files)
Instead, do this:
- DiffusionController (no browse-related code)
- DiffusionBrowseController (abstract, shared browse code)
- DiffusionBrowseMainController (concrete, handles routing)
- DiffusionBrowseDirectoryController (concrete, handles directories)
- DiffusionBrowseFileController (concrete, handles files)
- DiffusionBrowseSearchController (concrete, handles search)
Feels a lot cleaner.
Test Plan: Looked at directories, searches, and files.
Reviewers: btrahan
Reviewed By: btrahan
CC: aran
Differential Revision: https://secure.phabricator.com/D7045
2013-09-20 01:01:34 +02:00
|
|
|
protected function buildHeaderView(DiffusionRequest $drequest) {
|
2013-09-19 20:57:33 +02:00
|
|
|
$viewer = $this->getRequest()->getUser();
|
|
|
|
|
|
|
|
$header = id(new PHUIHeaderView())
|
|
|
|
->setUser($viewer)
|
2013-09-23 21:55:23 +02:00
|
|
|
->setHeader($this->renderPathLinks($drequest, $mode = 'browse'))
|
2013-09-19 20:57:33 +02:00
|
|
|
->setPolicyObject($drequest->getRepository());
|
|
|
|
|
|
|
|
return $header;
|
|
|
|
}
|
|
|
|
|
Improve organization of Diffusion browse controllers
Summary:
Currently we have this:
- DiffusionController (abstract, has some random shared browse code)
- DiffusionBrowseController (concrete, Handles routing, directories, and search)
- DiffusionBrowseFileController (concrete, handles files)
Instead, do this:
- DiffusionController (no browse-related code)
- DiffusionBrowseController (abstract, shared browse code)
- DiffusionBrowseMainController (concrete, handles routing)
- DiffusionBrowseDirectoryController (concrete, handles directories)
- DiffusionBrowseFileController (concrete, handles files)
- DiffusionBrowseSearchController (concrete, handles search)
Feels a lot cleaner.
Test Plan: Looked at directories, searches, and files.
Reviewers: btrahan
Reviewed By: btrahan
CC: aran
Differential Revision: https://secure.phabricator.com/D7045
2013-09-20 01:01:34 +02:00
|
|
|
protected function buildActionView(DiffusionRequest $drequest) {
|
|
|
|
$viewer = $this->getRequest()->getUser();
|
|
|
|
|
|
|
|
$view = id(new PhabricatorActionListView())
|
|
|
|
->setUser($viewer);
|
|
|
|
|
|
|
|
$history_uri = $drequest->generateURI(
|
|
|
|
array(
|
|
|
|
'action' => 'history',
|
|
|
|
));
|
|
|
|
|
|
|
|
$view->addAction(
|
|
|
|
id(new PhabricatorActionView())
|
|
|
|
->setName(pht('View History'))
|
|
|
|
->setHref($history_uri)
|
2014-05-12 19:08:32 +02:00
|
|
|
->setIcon('fa-list'));
|
Improve organization of Diffusion browse controllers
Summary:
Currently we have this:
- DiffusionController (abstract, has some random shared browse code)
- DiffusionBrowseController (concrete, Handles routing, directories, and search)
- DiffusionBrowseFileController (concrete, handles files)
Instead, do this:
- DiffusionController (no browse-related code)
- DiffusionBrowseController (abstract, shared browse code)
- DiffusionBrowseMainController (concrete, handles routing)
- DiffusionBrowseDirectoryController (concrete, handles directories)
- DiffusionBrowseFileController (concrete, handles files)
- DiffusionBrowseSearchController (concrete, handles search)
Feels a lot cleaner.
Test Plan: Looked at directories, searches, and files.
Reviewers: btrahan
Reviewed By: btrahan
CC: aran
Differential Revision: https://secure.phabricator.com/D7045
2013-09-20 01:01:34 +02:00
|
|
|
|
2014-05-13 22:52:48 +02:00
|
|
|
$behind_head = $drequest->getSymbolicCommit();
|
Improve organization of Diffusion browse controllers
Summary:
Currently we have this:
- DiffusionController (abstract, has some random shared browse code)
- DiffusionBrowseController (concrete, Handles routing, directories, and search)
- DiffusionBrowseFileController (concrete, handles files)
Instead, do this:
- DiffusionController (no browse-related code)
- DiffusionBrowseController (abstract, shared browse code)
- DiffusionBrowseMainController (concrete, handles routing)
- DiffusionBrowseDirectoryController (concrete, handles directories)
- DiffusionBrowseFileController (concrete, handles files)
- DiffusionBrowseSearchController (concrete, handles search)
Feels a lot cleaner.
Test Plan: Looked at directories, searches, and files.
Reviewers: btrahan
Reviewed By: btrahan
CC: aran
Differential Revision: https://secure.phabricator.com/D7045
2013-09-20 01:01:34 +02:00
|
|
|
$head_uri = $drequest->generateURI(
|
|
|
|
array(
|
|
|
|
'commit' => '',
|
|
|
|
'action' => 'browse',
|
|
|
|
));
|
|
|
|
$view->addAction(
|
|
|
|
id(new PhabricatorActionView())
|
|
|
|
->setName(pht('Jump to HEAD'))
|
|
|
|
->setHref($head_uri)
|
2014-05-12 19:08:32 +02:00
|
|
|
->setIcon('fa-home')
|
Improve organization of Diffusion browse controllers
Summary:
Currently we have this:
- DiffusionController (abstract, has some random shared browse code)
- DiffusionBrowseController (concrete, Handles routing, directories, and search)
- DiffusionBrowseFileController (concrete, handles files)
Instead, do this:
- DiffusionController (no browse-related code)
- DiffusionBrowseController (abstract, shared browse code)
- DiffusionBrowseMainController (concrete, handles routing)
- DiffusionBrowseDirectoryController (concrete, handles directories)
- DiffusionBrowseFileController (concrete, handles files)
- DiffusionBrowseSearchController (concrete, handles search)
Feels a lot cleaner.
Test Plan: Looked at directories, searches, and files.
Reviewers: btrahan
Reviewed By: btrahan
CC: aran
Differential Revision: https://secure.phabricator.com/D7045
2013-09-20 01:01:34 +02:00
|
|
|
->setDisabled(!$behind_head));
|
|
|
|
|
|
|
|
return $view;
|
|
|
|
}
|
|
|
|
|
2013-10-11 16:53:56 +02:00
|
|
|
protected function buildPropertyView(
|
|
|
|
DiffusionRequest $drequest,
|
|
|
|
PhabricatorActionListView $actions) {
|
|
|
|
|
2015-08-15 22:06:10 +02:00
|
|
|
$viewer = $this->getViewer();
|
2013-09-19 20:57:33 +02:00
|
|
|
|
2013-10-11 16:53:56 +02:00
|
|
|
$view = id(new PHUIPropertyListView())
|
|
|
|
->setUser($viewer)
|
|
|
|
->setActionList($actions);
|
2013-09-19 20:57:33 +02:00
|
|
|
|
2014-05-13 22:51:45 +02:00
|
|
|
$stable_commit = $drequest->getStableCommit();
|
2013-09-19 20:57:33 +02:00
|
|
|
|
|
|
|
$view->addProperty(
|
|
|
|
pht('Commit'),
|
|
|
|
phutil_tag(
|
|
|
|
'a',
|
|
|
|
array(
|
|
|
|
'href' => $drequest->generateURI(
|
|
|
|
array(
|
|
|
|
'action' => 'commit',
|
|
|
|
'commit' => $stable_commit,
|
|
|
|
)),
|
|
|
|
),
|
|
|
|
$drequest->getRepository()->formatCommitName($stable_commit)));
|
|
|
|
|
2014-05-13 22:52:03 +02:00
|
|
|
if ($drequest->getSymbolicType() == 'tag') {
|
2013-11-04 21:16:53 +01:00
|
|
|
$symbolic = $drequest->getSymbolicCommit();
|
|
|
|
$view->addProperty(pht('Tag'), $symbolic);
|
2013-09-19 20:57:33 +02:00
|
|
|
|
2013-11-04 21:16:53 +01:00
|
|
|
$tags = $this->callConduitWithDiffusionRequest(
|
|
|
|
'diffusion.tagsquery',
|
|
|
|
array(
|
|
|
|
'names' => array($symbolic),
|
|
|
|
'needMessages' => true,
|
|
|
|
));
|
|
|
|
$tags = DiffusionRepositoryTag::newFromConduit($tags);
|
|
|
|
|
|
|
|
$tags = mpull($tags, null, 'getName');
|
|
|
|
$tag = idx($tags, $symbolic);
|
|
|
|
|
|
|
|
if ($tag && strlen($tag->getMessage())) {
|
2015-09-19 20:29:01 +02:00
|
|
|
$view->addSectionHeader(
|
|
|
|
pht('Tag Content'), 'fa-tag');
|
2013-11-04 21:16:53 +01:00
|
|
|
$view->addTextContent($this->markupText($tag->getMessage()));
|
|
|
|
}
|
2013-09-19 20:57:33 +02:00
|
|
|
}
|
|
|
|
|
2015-08-15 22:06:10 +02:00
|
|
|
$repository = $drequest->getRepository();
|
|
|
|
|
|
|
|
$owners = 'PhabricatorOwnersApplication';
|
|
|
|
if (PhabricatorApplication::isClassInstalled($owners)) {
|
|
|
|
$package_query = id(new PhabricatorOwnersPackageQuery())
|
|
|
|
->setViewer($viewer)
|
2015-08-18 22:36:05 +02:00
|
|
|
->withStatuses(array(PhabricatorOwnersPackage::STATUS_ACTIVE))
|
2015-08-15 22:06:10 +02:00
|
|
|
->withControl(
|
|
|
|
$repository->getPHID(),
|
|
|
|
array(
|
|
|
|
$drequest->getPath(),
|
|
|
|
));
|
|
|
|
|
|
|
|
$package_query->execute();
|
|
|
|
|
|
|
|
$packages = $package_query->getControllingPackagesForPath(
|
|
|
|
$repository->getPHID(),
|
|
|
|
$drequest->getPath());
|
|
|
|
|
|
|
|
if ($packages) {
|
|
|
|
$ownership = id(new PHUIStatusListView())
|
|
|
|
->setUser($viewer);
|
|
|
|
|
|
|
|
foreach ($packages as $package) {
|
|
|
|
$icon = 'fa-list-alt';
|
|
|
|
$color = 'grey';
|
|
|
|
|
|
|
|
$item = id(new PHUIStatusItemView())
|
|
|
|
->setIcon($icon, $color)
|
|
|
|
->setTarget($viewer->renderHandle($package->getPHID()));
|
|
|
|
|
|
|
|
$ownership->addItem($item);
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
$ownership = phutil_tag('em', array(), pht('None'));
|
|
|
|
}
|
|
|
|
|
|
|
|
$view->addProperty(pht('Packages'), $ownership);
|
|
|
|
}
|
|
|
|
|
2013-09-19 20:57:33 +02:00
|
|
|
return $view;
|
|
|
|
}
|
|
|
|
|
2016-01-05 14:18:59 +01:00
|
|
|
private function buildOpenRevisions() {
|
|
|
|
$viewer = $this->getViewer();
|
Improve organization of Diffusion browse controllers
Summary:
Currently we have this:
- DiffusionController (abstract, has some random shared browse code)
- DiffusionBrowseController (concrete, Handles routing, directories, and search)
- DiffusionBrowseFileController (concrete, handles files)
Instead, do this:
- DiffusionController (no browse-related code)
- DiffusionBrowseController (abstract, shared browse code)
- DiffusionBrowseMainController (concrete, handles routing)
- DiffusionBrowseDirectoryController (concrete, handles directories)
- DiffusionBrowseFileController (concrete, handles files)
- DiffusionBrowseSearchController (concrete, handles search)
Feels a lot cleaner.
Test Plan: Looked at directories, searches, and files.
Reviewers: btrahan
Reviewed By: btrahan
CC: aran
Differential Revision: https://secure.phabricator.com/D7045
2013-09-20 01:01:34 +02:00
|
|
|
|
|
|
|
$drequest = $this->getDiffusionRequest();
|
|
|
|
$repository = $drequest->getRepository();
|
|
|
|
$path = $drequest->getPath();
|
|
|
|
|
|
|
|
$path_map = id(new DiffusionPathIDQuery(array($path)))->loadPathIDs();
|
|
|
|
$path_id = idx($path_map, $path);
|
|
|
|
if (!$path_id) {
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
2015-03-25 18:21:56 +01:00
|
|
|
$recent = (PhabricatorTime::getNow() - phutil_units('30 days in seconds'));
|
|
|
|
|
Improve organization of Diffusion browse controllers
Summary:
Currently we have this:
- DiffusionController (abstract, has some random shared browse code)
- DiffusionBrowseController (concrete, Handles routing, directories, and search)
- DiffusionBrowseFileController (concrete, handles files)
Instead, do this:
- DiffusionController (no browse-related code)
- DiffusionBrowseController (abstract, shared browse code)
- DiffusionBrowseMainController (concrete, handles routing)
- DiffusionBrowseDirectoryController (concrete, handles directories)
- DiffusionBrowseFileController (concrete, handles files)
- DiffusionBrowseSearchController (concrete, handles search)
Feels a lot cleaner.
Test Plan: Looked at directories, searches, and files.
Reviewers: btrahan
Reviewed By: btrahan
CC: aran
Differential Revision: https://secure.phabricator.com/D7045
2013-09-20 01:01:34 +02:00
|
|
|
$revisions = id(new DifferentialRevisionQuery())
|
2016-01-05 14:18:59 +01:00
|
|
|
->setViewer($viewer)
|
Improve organization of Diffusion browse controllers
Summary:
Currently we have this:
- DiffusionController (abstract, has some random shared browse code)
- DiffusionBrowseController (concrete, Handles routing, directories, and search)
- DiffusionBrowseFileController (concrete, handles files)
Instead, do this:
- DiffusionController (no browse-related code)
- DiffusionBrowseController (abstract, shared browse code)
- DiffusionBrowseMainController (concrete, handles routing)
- DiffusionBrowseDirectoryController (concrete, handles directories)
- DiffusionBrowseFileController (concrete, handles files)
- DiffusionBrowseSearchController (concrete, handles search)
Feels a lot cleaner.
Test Plan: Looked at directories, searches, and files.
Reviewers: btrahan
Reviewed By: btrahan
CC: aran
Differential Revision: https://secure.phabricator.com/D7045
2013-09-20 01:01:34 +02:00
|
|
|
->withPath($repository->getID(), $path_id)
|
|
|
|
->withStatus(DifferentialRevisionQuery::STATUS_OPEN)
|
2015-03-25 18:21:56 +01:00
|
|
|
->withUpdatedEpochBetween($recent, null)
|
2015-04-12 05:16:52 +02:00
|
|
|
->setOrder(DifferentialRevisionQuery::ORDER_MODIFIED)
|
Improve organization of Diffusion browse controllers
Summary:
Currently we have this:
- DiffusionController (abstract, has some random shared browse code)
- DiffusionBrowseController (concrete, Handles routing, directories, and search)
- DiffusionBrowseFileController (concrete, handles files)
Instead, do this:
- DiffusionController (no browse-related code)
- DiffusionBrowseController (abstract, shared browse code)
- DiffusionBrowseMainController (concrete, handles routing)
- DiffusionBrowseDirectoryController (concrete, handles directories)
- DiffusionBrowseFileController (concrete, handles files)
- DiffusionBrowseSearchController (concrete, handles search)
Feels a lot cleaner.
Test Plan: Looked at directories, searches, and files.
Reviewers: btrahan
Reviewed By: btrahan
CC: aran
Differential Revision: https://secure.phabricator.com/D7045
2013-09-20 01:01:34 +02:00
|
|
|
->setLimit(10)
|
|
|
|
->needRelationships(true)
|
2014-02-19 02:57:45 +01:00
|
|
|
->needFlags(true)
|
|
|
|
->needDrafts(true)
|
Improve organization of Diffusion browse controllers
Summary:
Currently we have this:
- DiffusionController (abstract, has some random shared browse code)
- DiffusionBrowseController (concrete, Handles routing, directories, and search)
- DiffusionBrowseFileController (concrete, handles files)
Instead, do this:
- DiffusionController (no browse-related code)
- DiffusionBrowseController (abstract, shared browse code)
- DiffusionBrowseMainController (concrete, handles routing)
- DiffusionBrowseDirectoryController (concrete, handles directories)
- DiffusionBrowseFileController (concrete, handles files)
- DiffusionBrowseSearchController (concrete, handles search)
Feels a lot cleaner.
Test Plan: Looked at directories, searches, and files.
Reviewers: btrahan
Reviewed By: btrahan
CC: aran
Differential Revision: https://secure.phabricator.com/D7045
2013-09-20 01:01:34 +02:00
|
|
|
->execute();
|
|
|
|
|
|
|
|
if (!$revisions) {
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
2015-03-25 18:21:56 +01:00
|
|
|
$header = id(new PHUIHeaderView())
|
|
|
|
->setHeader(pht('Open Revisions'))
|
|
|
|
->setSubheader(
|
|
|
|
pht('Recently updated open revisions affecting this file.'));
|
|
|
|
|
Improve organization of Diffusion browse controllers
Summary:
Currently we have this:
- DiffusionController (abstract, has some random shared browse code)
- DiffusionBrowseController (concrete, Handles routing, directories, and search)
- DiffusionBrowseFileController (concrete, handles files)
Instead, do this:
- DiffusionController (no browse-related code)
- DiffusionBrowseController (abstract, shared browse code)
- DiffusionBrowseMainController (concrete, handles routing)
- DiffusionBrowseDirectoryController (concrete, handles directories)
- DiffusionBrowseFileController (concrete, handles files)
- DiffusionBrowseSearchController (concrete, handles search)
Feels a lot cleaner.
Test Plan: Looked at directories, searches, and files.
Reviewers: btrahan
Reviewed By: btrahan
CC: aran
Differential Revision: https://secure.phabricator.com/D7045
2013-09-20 01:01:34 +02:00
|
|
|
$view = id(new DifferentialRevisionListView())
|
2015-03-25 18:21:56 +01:00
|
|
|
->setHeader($header)
|
Improve organization of Diffusion browse controllers
Summary:
Currently we have this:
- DiffusionController (abstract, has some random shared browse code)
- DiffusionBrowseController (concrete, Handles routing, directories, and search)
- DiffusionBrowseFileController (concrete, handles files)
Instead, do this:
- DiffusionController (no browse-related code)
- DiffusionBrowseController (abstract, shared browse code)
- DiffusionBrowseMainController (concrete, handles routing)
- DiffusionBrowseDirectoryController (concrete, handles directories)
- DiffusionBrowseFileController (concrete, handles files)
- DiffusionBrowseSearchController (concrete, handles search)
Feels a lot cleaner.
Test Plan: Looked at directories, searches, and files.
Reviewers: btrahan
Reviewed By: btrahan
CC: aran
Differential Revision: https://secure.phabricator.com/D7045
2013-09-20 01:01:34 +02:00
|
|
|
->setRevisions($revisions)
|
2016-01-05 14:18:59 +01:00
|
|
|
->setUser($viewer);
|
Improve organization of Diffusion browse controllers
Summary:
Currently we have this:
- DiffusionController (abstract, has some random shared browse code)
- DiffusionBrowseController (concrete, Handles routing, directories, and search)
- DiffusionBrowseFileController (concrete, handles files)
Instead, do this:
- DiffusionController (no browse-related code)
- DiffusionBrowseController (abstract, shared browse code)
- DiffusionBrowseMainController (concrete, handles routing)
- DiffusionBrowseDirectoryController (concrete, handles directories)
- DiffusionBrowseFileController (concrete, handles files)
- DiffusionBrowseSearchController (concrete, handles search)
Feels a lot cleaner.
Test Plan: Looked at directories, searches, and files.
Reviewers: btrahan
Reviewed By: btrahan
CC: aran
Differential Revision: https://secure.phabricator.com/D7045
2013-09-20 01:01:34 +02:00
|
|
|
|
|
|
|
$phids = $view->getRequiredHandlePHIDs();
|
|
|
|
$handles = $this->loadViewerHandles($phids);
|
|
|
|
$view->setHandles($handles);
|
|
|
|
|
2015-02-19 17:11:17 +01:00
|
|
|
return $view;
|
Improve organization of Diffusion browse controllers
Summary:
Currently we have this:
- DiffusionController (abstract, has some random shared browse code)
- DiffusionBrowseController (concrete, Handles routing, directories, and search)
- DiffusionBrowseFileController (concrete, handles files)
Instead, do this:
- DiffusionController (no browse-related code)
- DiffusionBrowseController (abstract, shared browse code)
- DiffusionBrowseMainController (concrete, handles routing)
- DiffusionBrowseDirectoryController (concrete, handles directories)
- DiffusionBrowseFileController (concrete, handles files)
- DiffusionBrowseSearchController (concrete, handles search)
Feels a lot cleaner.
Test Plan: Looked at directories, searches, and files.
Reviewers: btrahan
Reviewed By: btrahan
CC: aran
Differential Revision: https://secure.phabricator.com/D7045
2013-09-20 01:01:34 +02:00
|
|
|
}
|
|
|
|
|
2016-01-06 15:15:25 +01:00
|
|
|
private function loadBlame($path, $commit) {
|
|
|
|
$blame = $this->callConduitWithDiffusionRequest(
|
|
|
|
'diffusion.blame',
|
|
|
|
array(
|
|
|
|
'commit' => $commit,
|
|
|
|
'paths' => array($path),
|
|
|
|
));
|
|
|
|
|
|
|
|
$identifiers = idx($blame, $path, array());
|
|
|
|
|
|
|
|
if ($identifiers) {
|
|
|
|
$viewer = $this->getViewer();
|
|
|
|
$drequest = $this->getDiffusionRequest();
|
|
|
|
$repository = $drequest->getRepository();
|
|
|
|
|
|
|
|
$commits = id(new DiffusionCommitQuery())
|
|
|
|
->setViewer($viewer)
|
|
|
|
->withRepository($repository)
|
|
|
|
->withIdentifiers($identifiers)
|
|
|
|
// TODO: We only fetch this to improve author display behavior, but
|
|
|
|
// shouldn't really need to?
|
|
|
|
->needCommitData(true)
|
|
|
|
->execute();
|
|
|
|
$commits = mpull($commits, null, 'getCommitIdentifier');
|
|
|
|
} else {
|
|
|
|
$commits = array();
|
|
|
|
}
|
|
|
|
|
|
|
|
foreach ($identifiers as $key => $identifier) {
|
|
|
|
$commit = idx($commits, $identifier);
|
|
|
|
if ($commit) {
|
|
|
|
$identifiers[$key] = $commit;
|
|
|
|
} else {
|
|
|
|
$identifiers[$key] = null;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return $identifiers;
|
|
|
|
}
|
|
|
|
|
2011-03-08 02:25:47 +01:00
|
|
|
}
|