2011-03-12 16:17:34 -08:00
|
|
|
<?php
|
|
|
|
|
|
|
|
final class DiffusionBranchTableView extends DiffusionView {
|
|
|
|
|
|
|
|
private $branches;
|
2012-05-10 09:28:19 +02:00
|
|
|
private $commits = array();
|
2011-03-12 16:17:34 -08:00
|
|
|
|
|
|
|
public function setBranches(array $branches) {
|
2014-01-17 16:10:56 -08:00
|
|
|
assert_instances_of($branches, 'DiffusionRepositoryRef');
|
2011-03-12 16:17:34 -08:00
|
|
|
$this->branches = $branches;
|
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
|
2012-05-08 22:28:27 +02:00
|
|
|
public function setCommits(array $commits) {
|
2014-01-17 16:10:56 -08:00
|
|
|
assert_instances_of($commits, 'PhabricatorRepositoryCommit');
|
2012-05-08 22:28:27 +02:00
|
|
|
$this->commits = mpull($commits, null, 'getCommitIdentifier');
|
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
|
2011-03-12 16:17:34 -08:00
|
|
|
public function render() {
|
|
|
|
$drequest = $this->getDiffusionRequest();
|
|
|
|
$current_branch = $drequest->getBranch();
|
|
|
|
|
|
|
|
$rows = array();
|
|
|
|
$rowc = array();
|
|
|
|
foreach ($this->branches as $branch) {
|
2014-01-17 16:10:56 -08:00
|
|
|
$commit = idx($this->commits, $branch->getCommitIdentifier());
|
2012-05-08 22:28:27 +02:00
|
|
|
if ($commit) {
|
2013-10-30 13:06:28 -07:00
|
|
|
$details = $commit->getSummary();
|
2012-05-08 22:28:27 +02:00
|
|
|
$datetime = phabricator_datetime($commit->getEpoch(), $this->user);
|
|
|
|
} else {
|
|
|
|
$datetime = null;
|
|
|
|
$details = null;
|
|
|
|
}
|
|
|
|
|
2011-03-12 16:17:34 -08:00
|
|
|
$rows[] = array(
|
2013-01-17 18:57:09 -08:00
|
|
|
phutil_tag(
|
2012-05-08 22:28:27 +02:00
|
|
|
'a',
|
|
|
|
array(
|
|
|
|
'href' => $drequest->generateURI(
|
|
|
|
array(
|
|
|
|
'action' => 'history',
|
2014-01-17 16:10:56 -08:00
|
|
|
'branch' => $branch->getShortName(),
|
2012-05-08 22:28:27 +02:00
|
|
|
))
|
|
|
|
),
|
2013-05-11 08:23:19 -07:00
|
|
|
pht('History')),
|
2013-01-17 18:43:35 -08:00
|
|
|
phutil_tag(
|
2011-03-31 01:07:51 -07:00
|
|
|
'a',
|
|
|
|
array(
|
Fix many encoding and architecture problems in Diffusion request and URI handling
Summary:
Diffusion request/uri handling is currently a big, hastily ported mess. In particular, it has:
- Tons and tons of duplicated code.
- Bugs with handling unusual branch and file names.
- An excessively large (and yet insufficiently expressive) API on DiffusionRequest, including a nonsensical concrete base class.
- Other tools were doing hacky things like passing ":" branch names.
This diff attempts to fix these issues.
- Make the base class abstract (it was concrete ONLY for "/diffusion/").
- Move all URI generation to DiffusionRequest. Make the core static. Add unit tests.
- Delete the 300 copies of URI generation code throughout Diffusion.
- Move all URI parsing to DiffusionRequest. Make the core static. Add unit tests.
- Add an appropriate static initializer for other callers.
- Convert all code calling `newFromAphrontRequestDictionary` outside of Diffusion to the new `newFromDictionary` API.
- Refactor static initializers to be sensibly-sized.
- Refactor derived DiffusionRequest classes to remove duplicated code.
- Properly encode branch names (fixes branches with "/", see <https://github.com/facebook/phabricator/issues/100>).
- Properly encode path names (fixes issues in D1742).
- Properly escape delimiter characters ";" and "$" in path names so files like "$100" are not interpreted as "line 100".
- Fix a couple warnings.
- Fix a couple lint issues.
- Fix a bug where we would not parse filenames with spaces in them correctly in the Git browse query.
- Fix a bug where Git change queries would fail unnecessarily.
- Provide or improve some documentation.
This thing is pretty gigantic but also kind of hard to split up. If it's unreasonably difficult to review, let me know and I can take a stab at it though.
This supplants D1742.
Test Plan:
- Used home, repository, branch, browse, change, history, diff (ajax), lastmodified (ajax) views of Diffusion.
- Used Owners typeaheads and search.
- Used diffusion.getrecentcommitsbypath method.
- Pushed a change to an absurdly-named file on an absurdly-named branch, everything worked properly.
{F9185}
Reviewers: nh, vrana, btrahan
Reviewed By: btrahan
CC: aran, epriestley
Differential Revision: https://secure.phabricator.com/D1921
2012-03-19 19:52:14 -07:00
|
|
|
'href' => $drequest->generateURI(
|
|
|
|
array(
|
2012-04-18 08:02:08 -07:00
|
|
|
'action' => 'browse',
|
2014-01-17 16:10:56 -08:00
|
|
|
'branch' => $branch->getShortName(),
|
Fix many encoding and architecture problems in Diffusion request and URI handling
Summary:
Diffusion request/uri handling is currently a big, hastily ported mess. In particular, it has:
- Tons and tons of duplicated code.
- Bugs with handling unusual branch and file names.
- An excessively large (and yet insufficiently expressive) API on DiffusionRequest, including a nonsensical concrete base class.
- Other tools were doing hacky things like passing ":" branch names.
This diff attempts to fix these issues.
- Make the base class abstract (it was concrete ONLY for "/diffusion/").
- Move all URI generation to DiffusionRequest. Make the core static. Add unit tests.
- Delete the 300 copies of URI generation code throughout Diffusion.
- Move all URI parsing to DiffusionRequest. Make the core static. Add unit tests.
- Add an appropriate static initializer for other callers.
- Convert all code calling `newFromAphrontRequestDictionary` outside of Diffusion to the new `newFromDictionary` API.
- Refactor static initializers to be sensibly-sized.
- Refactor derived DiffusionRequest classes to remove duplicated code.
- Properly encode branch names (fixes branches with "/", see <https://github.com/facebook/phabricator/issues/100>).
- Properly encode path names (fixes issues in D1742).
- Properly escape delimiter characters ";" and "$" in path names so files like "$100" are not interpreted as "line 100".
- Fix a couple warnings.
- Fix a couple lint issues.
- Fix a bug where we would not parse filenames with spaces in them correctly in the Git browse query.
- Fix a bug where Git change queries would fail unnecessarily.
- Provide or improve some documentation.
This thing is pretty gigantic but also kind of hard to split up. If it's unreasonably difficult to review, let me know and I can take a stab at it though.
This supplants D1742.
Test Plan:
- Used home, repository, branch, browse, change, history, diff (ajax), lastmodified (ajax) views of Diffusion.
- Used Owners typeaheads and search.
- Used diffusion.getrecentcommitsbypath method.
- Pushed a change to an absurdly-named file on an absurdly-named branch, everything worked properly.
{F9185}
Reviewers: nh, vrana, btrahan
Reviewed By: btrahan
CC: aran, epriestley
Differential Revision: https://secure.phabricator.com/D1921
2012-03-19 19:52:14 -07:00
|
|
|
)),
|
2011-03-31 01:07:51 -07:00
|
|
|
),
|
2014-01-17 16:10:56 -08:00
|
|
|
$branch->getShortName()),
|
2011-03-12 16:17:34 -08:00
|
|
|
self::linkCommit(
|
|
|
|
$drequest->getRepository(),
|
2014-01-17 16:10:56 -08:00
|
|
|
$branch->getCommitIdentifier()),
|
2012-05-08 22:28:27 +02:00
|
|
|
$datetime,
|
2013-01-28 18:41:43 -08:00
|
|
|
AphrontTableView::renderSingleDisplayLine($details),
|
2011-03-12 16:17:34 -08:00
|
|
|
);
|
2014-01-17 16:10:56 -08:00
|
|
|
if ($branch->getShortName() == $current_branch) {
|
2011-03-12 16:17:34 -08:00
|
|
|
$rowc[] = 'highlighted';
|
|
|
|
} else {
|
|
|
|
$rowc[] = null;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
$view = new AphrontTableView($rows);
|
|
|
|
$view->setHeaders(
|
|
|
|
array(
|
2013-05-11 08:23:19 -07:00
|
|
|
pht('History'),
|
|
|
|
pht('Branch'),
|
|
|
|
pht('Head'),
|
|
|
|
pht('Modified'),
|
|
|
|
pht('Details'),
|
2011-03-12 16:17:34 -08:00
|
|
|
));
|
|
|
|
$view->setColumnClasses(
|
|
|
|
array(
|
2012-05-08 22:28:27 +02:00
|
|
|
'',
|
2012-04-18 08:02:08 -07:00
|
|
|
'pri',
|
2012-05-08 22:28:27 +02:00
|
|
|
'',
|
|
|
|
'',
|
2011-03-12 16:17:34 -08:00
|
|
|
'wide',
|
|
|
|
));
|
|
|
|
$view->setRowClasses($rowc);
|
|
|
|
return $view->render();
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|