Page MenuHomestyx hydra

No OneTemporary

diff --git a/src/applications/diffusion/controller/DiffusionHistoryController.php b/src/applications/diffusion/controller/DiffusionHistoryController.php
index fb35d9b6ad..eeb8f13118 100644
--- a/src/applications/diffusion/controller/DiffusionHistoryController.php
+++ b/src/applications/diffusion/controller/DiffusionHistoryController.php
@@ -1,127 +1,126 @@
<?php
final class DiffusionHistoryController extends DiffusionController {
public function shouldAllowPublic() {
return true;
}
public function handleRequest(AphrontRequest $request) {
$response = $this->loadDiffusionContext();
if ($response) {
return $response;
}
require_celerity_resource('diffusion-css');
$viewer = $this->getViewer();
$drequest = $this->getDiffusionRequest();
$repository = $drequest->getRepository();
$pager = id(new PHUIPagerView())
->readFromRequest($request);
$params = array(
'commit' => $drequest->getCommit(),
'path' => $drequest->getPath(),
'offset' => $pager->getOffset(),
'limit' => $pager->getPageSize() + 1,
);
$history_results = $this->callConduitWithDiffusionRequest(
'diffusion.historyquery',
$params);
$history = DiffusionPathChange::newFromConduit(
$history_results['pathChanges']);
$history = $pager->sliceResults($history);
$history_list = id(new DiffusionCommitGraphView())
->setViewer($viewer)
->setDiffusionRequest($drequest)
->setHistory($history);
// NOTE: If we have a path (like "src/"), many nodes in the graph are
// likely to be missing (since the path wasn't touched by those commits).
// If we draw the graph, commits will often appear to be unrelated because
// intermediate nodes are omitted. Just drop the graph.
// The ideal behavior would be to load the entire graph and then connect
// ancestors appropriately, but this would currrently be prohibitively
// expensive in the general case.
- $show_graph = !strlen($drequest->getPath());
+ $show_graph = !phutil_nonempty_string($drequest->getPath());
if ($show_graph) {
$history_list
->setParents($history_results['parents'])
->setIsHead(!$pager->getOffset())
->setIsTail(!$pager->getHasMorePages());
}
$header = $this->buildHeader($drequest);
$crumbs = $this->buildCrumbs(
array(
'branch' => true,
'path' => true,
'view' => 'history',
));
$crumbs->setBorder(true);
$title = array(
pht('History'),
$repository->getDisplayName(),
);
$pager = id(new PHUIBoxView())
->addClass('mlb')
->appendChild($pager);
$tabs = $this->buildTabsView('history');
$view = id(new PHUITwoColumnView())
->setHeader($header)
->setTabs($tabs)
->setFooter(array(
$history_list,
$pager,
));
return $this->newPage()
->setTitle($title)
->setCrumbs($crumbs)
->appendChild($view)
->addClass('diffusion-history-view');
}
private function buildHeader(DiffusionRequest $drequest) {
$viewer = $this->getViewer();
$repository = $drequest->getRepository();
- $no_path = !strlen($drequest->getPath());
- if ($no_path) {
- $header_text = pht('History');
- } else {
+ if (phutil_nonempty_string($drequest->getPath())) {
$header_text = $this->renderPathLinks($drequest, $mode = 'history');
+ } else {
+ $header_text = pht('History');
}
$header = id(new PHUIHeaderView())
->setUser($viewer)
->setHeader($header_text)
->setHeaderIcon('fa-clock-o');
if (!$repository->isSVN()) {
$branch_tag = $this->renderBranchTag($drequest);
$header->addTag($branch_tag);
}
if ($drequest->getSymbolicCommit()) {
$symbolic_tag = $this->renderSymbolicCommit($drequest);
$header->addTag($symbolic_tag);
}
return $header;
}
}
diff --git a/src/applications/diffusion/query/pathid/DiffusionPathIDQuery.php b/src/applications/diffusion/query/pathid/DiffusionPathIDQuery.php
index 7c9e721431..d994410034 100644
--- a/src/applications/diffusion/query/pathid/DiffusionPathIDQuery.php
+++ b/src/applications/diffusion/query/pathid/DiffusionPathIDQuery.php
@@ -1,96 +1,99 @@
<?php
/**
* @task pathutil Path Utilities
*/
final class DiffusionPathIDQuery extends Phobject {
private $paths = array();
public function __construct(array $paths) {
$this->paths = $paths;
}
public function loadPathIDs() {
$repository = new PhabricatorRepository();
$path_normal_map = array();
foreach ($this->paths as $path) {
$normal = self::normalizePath($path);
$path_normal_map[$normal][] = $path;
}
$paths = queryfx_all(
$repository->establishConnection('r'),
'SELECT * FROM %T WHERE pathHash IN (%Ls)',
PhabricatorRepository::TABLE_PATH,
array_map('md5', array_keys($path_normal_map)));
$paths = ipull($paths, 'id', 'path');
$result = array();
foreach ($path_normal_map as $normal => $originals) {
foreach ($originals as $original) {
$result[$original] = idx($paths, $normal);
}
}
return $result;
}
/**
* Convert a path to the canonical, absolute representation used by Diffusion.
*
* @param string Some repository path.
* @return string Canonicalized Diffusion path.
* @task pathutil
*/
public static function normalizePath($path) {
+ // Ensure we have a string, not a null.
+ $path = coalesce($path, '');
+
// Normalize to single slashes, e.g. "///" => "/".
$path = preg_replace('@[/]{2,}@', '/', $path);
return '/'.trim($path, '/');
}
/**
* Return the canonical parent directory for a path. Note, returns "/" when
* passed "/".
*
* @param string Some repository path.
* @return string That path's canonical parent directory.
* @task pathutil
*/
public static function getParentPath($path) {
$path = self::normalizePath($path);
$path = dirname($path);
if (phutil_is_windows() && $path == '\\') {
$path = '/';
}
return $path;
}
/**
* Generate a list of parents for a repository path. The path itself is
* included.
*
* @param string Some repository path.
* @return list List of canonical paths between the path and the root.
* @task pathutil
*/
public static function expandPathToRoot($path) {
$path = self::normalizePath($path);
$parents = array($path);
$parts = explode('/', trim($path, '/'));
while (count($parts) >= 1) {
if (array_pop($parts)) {
$parents[] = '/'.implode('/', $parts);
}
}
return $parents;
}
}

File Metadata

Mime Type
text/x-diff
Expires
Sat, Nov 23, 6:53 PM (1 d, 9 h)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
973
Default Alt Text
(6 KB)

Event Timeline