mirror of
https://we.phorge.it/source/phorge.git
synced 2024-11-18 21:02:41 +01:00
Improved change view support.
This commit is contained in:
parent
5063e978f1
commit
60918c9a9e
8 changed files with 102 additions and 20 deletions
|
@ -90,6 +90,10 @@ class DifferentialChangesetParser {
|
|||
return $this;
|
||||
}
|
||||
|
||||
public function getChangeset() {
|
||||
return $this->changeset;
|
||||
}
|
||||
|
||||
public function getChangesetID() {
|
||||
return $this->changesetID;
|
||||
}
|
||||
|
@ -858,10 +862,10 @@ EOSYNTHETIC;
|
|||
}
|
||||
|
||||
protected function renderShield($message, $more) {
|
||||
$end = $this->getLength();
|
||||
$changeset_id = $this->getChangesetID();
|
||||
|
||||
if ($more) {
|
||||
$end = $this->getLength();
|
||||
$reference = $this->getChangeset()->getRenderingReference();
|
||||
$more =
|
||||
' '.
|
||||
javelin_render_tag(
|
||||
|
@ -872,7 +876,7 @@ EOSYNTHETIC;
|
|||
'class' => 'complete',
|
||||
'href' => '#',
|
||||
'meta' => array(
|
||||
'id' => $changeset_id,
|
||||
'id' => $reference,
|
||||
'range' => "0-{$end}",
|
||||
),
|
||||
),
|
||||
|
@ -958,6 +962,7 @@ EOSYNTHETIC;
|
|||
$gaps = array_reverse($gaps);
|
||||
|
||||
$changeset = $this->changesetID;
|
||||
$reference = $this->getChangeset()->getRenderingReference();
|
||||
|
||||
for ($ii = $range_start; $ii < $range_start + $range_len; $ii++) {
|
||||
if (empty($mask[$ii])) {
|
||||
|
@ -977,7 +982,7 @@ EOSYNTHETIC;
|
|||
'mustcapture' => true,
|
||||
'sigil' => 'show-more',
|
||||
'meta' => array(
|
||||
'id' => $changeset,
|
||||
'id' => $reference,
|
||||
'range' => "{$top}-{$len}/{$top}-20",
|
||||
),
|
||||
),
|
||||
|
@ -991,7 +996,7 @@ EOSYNTHETIC;
|
|||
'mustcapture' => true,
|
||||
'sigil' => 'show-more',
|
||||
'meta' => array(
|
||||
'id' => $changeset,
|
||||
'id' => $reference,
|
||||
'range' => "{$top}-{$len}/{$top}-{$len}",
|
||||
),
|
||||
),
|
||||
|
@ -1005,7 +1010,7 @@ EOSYNTHETIC;
|
|||
'mustcapture' => true,
|
||||
'sigil' => 'show-more',
|
||||
'meta' => array(
|
||||
'id' => $changeset,
|
||||
'id' => $reference,
|
||||
'range' => "{$top}-{$len}/{$end}-20",
|
||||
),
|
||||
),
|
||||
|
@ -1067,13 +1072,13 @@ EOSYNTHETIC;
|
|||
$html[] = $context_not_available;
|
||||
}
|
||||
|
||||
if ($o_num) {
|
||||
if ($o_num && $changeset) {
|
||||
$o_id = ' id="C'.$changeset.'OL'.$o_num.'"';
|
||||
} else {
|
||||
$o_id = null;
|
||||
}
|
||||
|
||||
if ($n_num) {
|
||||
if ($n_num && $changeset) {
|
||||
$n_id = ' id="C'.$changeset.'NL'.$n_num.'"';
|
||||
} else {
|
||||
$n_id = null;
|
||||
|
|
|
@ -32,6 +32,7 @@ class DifferentialChangeset extends DifferentialDAO {
|
|||
|
||||
private $unsavedHunks = array();
|
||||
private $hunks;
|
||||
private $renderingReference;
|
||||
|
||||
protected function getConfiguration() {
|
||||
return array(
|
||||
|
@ -75,6 +76,18 @@ class DifferentialChangeset extends DifferentialDAO {
|
|||
return $name;
|
||||
}
|
||||
|
||||
public function setRenderingReference($rendering_reference) {
|
||||
$this->renderingReference = $rendering_reference;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getRenderingReference() {
|
||||
if ($this->renderingReference) {
|
||||
return $this->renderingReference;
|
||||
}
|
||||
return $this->getID();
|
||||
}
|
||||
|
||||
public function addUnsavedHunk(DifferentialHunk $hunk) {
|
||||
if ($this->hunks === null) {
|
||||
$this->hunks = array();
|
||||
|
|
|
@ -70,10 +70,12 @@ class DifferentialChangesetListView extends AphrontView {
|
|||
$vs_id = null;
|
||||
}
|
||||
|
||||
$detail_uri = new PhutilURI('/differential/changeset/');
|
||||
$ref = $changeset->getRenderingReference();
|
||||
|
||||
$detail_uri = new PhutilURI($this->renderURI);
|
||||
$detail_uri->setQueryParams(
|
||||
array(
|
||||
'id' => $id,
|
||||
'id' => $ref,
|
||||
'vs' => $vs_id,
|
||||
'whitespace' => 'TODO',
|
||||
));
|
||||
|
@ -103,7 +105,7 @@ class DifferentialChangesetListView extends AphrontView {
|
|||
$output[] = $detail->render();
|
||||
|
||||
$mapping[$uniq_id] = array(
|
||||
$changeset->getID(),
|
||||
$ref,
|
||||
$vs_id);
|
||||
}
|
||||
|
||||
|
|
|
@ -21,6 +21,8 @@ class DiffusionCommitController extends DiffusionController {
|
|||
public function processRequest() {
|
||||
$drequest = $this->getDiffusionRequest();
|
||||
|
||||
$callsign = $drequest->getRepository()->getCallsign();
|
||||
|
||||
$content = array();
|
||||
$content[] = $this->buildCrumbs(array(
|
||||
'commit' => true,
|
||||
|
@ -43,7 +45,7 @@ class DiffusionCommitController extends DiffusionController {
|
|||
$detail_panel->appendChild(
|
||||
'<div class="diffusion-commit-view">'.
|
||||
'<div class="diffusion-commit-dateline">'.
|
||||
'r'.$repository->getCallsign().$commit->getCommitIdentifier().
|
||||
'r'.$callsign.$commit->getCommitIdentifier().
|
||||
' · '.
|
||||
date('F jS, Y g:i A', $commit->getEpoch()).
|
||||
'</div>'.
|
||||
|
@ -82,7 +84,7 @@ class DiffusionCommitController extends DiffusionController {
|
|||
id(new PhabricatorRepository())->establishConnection('r'),
|
||||
'SELECT * FROM %T WHERE fullCommitName = %s',
|
||||
PhabricatorRepository::TABLE_BADCOMMIT,
|
||||
'r'.$repository->getCallsign().$commit->getCommitIdentifier());
|
||||
'r'.$callsign.$commit->getCommitIdentifier());
|
||||
}
|
||||
|
||||
if ($bad_commit) {
|
||||
|
@ -100,11 +102,36 @@ class DiffusionCommitController extends DiffusionController {
|
|||
|
||||
$content[] = $change_panel;
|
||||
|
||||
$change_list =
|
||||
'<div style="margin: 2em; color: #666; padding: 1em;
|
||||
background: #eee;">'.
|
||||
'(list of changes goes here)'.
|
||||
'</div>';
|
||||
if ($changes) {
|
||||
$changesets = DiffusionPathChange::convertToDifferentialChangesets(
|
||||
$changes);
|
||||
foreach ($changesets as $changeset) {
|
||||
$branch = $drequest->getBranchURIComponent(
|
||||
$drequest->getBranch());
|
||||
$filename = $changeset->getFilename();
|
||||
$commit = $drequest->getCommit();
|
||||
$reference = "{$branch}{$filename};{$commit}";
|
||||
$changeset->setRenderingReference($reference);
|
||||
}
|
||||
|
||||
$change_list = new DifferentialChangesetListView();
|
||||
$change_list->setChangesets($changesets);
|
||||
$change_list->setRenderURI('/diffusion/'.$callsign.'/diff/');
|
||||
|
||||
// TODO: This is pretty awkward, unify the CSS between Diffusion and
|
||||
// Differential better.
|
||||
require_celerity_resource('differential-core-view-css');
|
||||
$change_list =
|
||||
'<div class="differential-primary-pane">'.
|
||||
$change_list->render().
|
||||
'</div>';
|
||||
} else {
|
||||
$change_list =
|
||||
'<div style="margin: 2em; color: #666; padding: 1em;
|
||||
background: #eee;">'.
|
||||
'(no changes blah blah)'.
|
||||
'</div>';
|
||||
}
|
||||
|
||||
$content[] = $change_list;
|
||||
}
|
||||
|
|
|
@ -6,7 +6,9 @@
|
|||
|
||||
|
||||
|
||||
phutil_require_module('phabricator', 'applications/differential/view/changesetlistview');
|
||||
phutil_require_module('phabricator', 'applications/diffusion/controller/base');
|
||||
phutil_require_module('phabricator', 'applications/diffusion/data/pathchange');
|
||||
phutil_require_module('phabricator', 'applications/diffusion/query/pathchange/base');
|
||||
phutil_require_module('phabricator', 'applications/diffusion/view/commitchangetable');
|
||||
phutil_require_module('phabricator', 'applications/repository/storage/repository');
|
||||
|
|
|
@ -125,5 +125,33 @@ final class DiffusionPathChange {
|
|||
return substr($first, 0, 80);
|
||||
}
|
||||
|
||||
final public static function convertToArcanistChanges(array $changes) {
|
||||
$direct = array();
|
||||
$result = array();
|
||||
foreach ($changes as $path) {
|
||||
$change = new ArcanistDiffChange();
|
||||
$change->setCurrentPath($path->getPath());
|
||||
$direct[] = $path->getPath();
|
||||
$change->setType($path->getChangeType());
|
||||
$file_type = $path->getFileType();
|
||||
if ($file_type == DifferentialChangeType::FILE_NORMAL) {
|
||||
$file_type = DifferentialChangeType::FILE_TEXT;
|
||||
}
|
||||
$change->setFileType($file_type);
|
||||
$change->setOldPath($path->getTargetPath());
|
||||
foreach ($path->getAwayPaths() as $away_path) {
|
||||
$change->addAwayPath($away_path);
|
||||
}
|
||||
$result[$path->getPath()] = $change;
|
||||
}
|
||||
|
||||
return array_select_keys($result, $direct);
|
||||
}
|
||||
|
||||
final public static function convertToDifferentialChangesets(array $changes) {
|
||||
$arcanist_changes = self::convertToArcanistChanges($changes);
|
||||
$diff = DifferentialDiff::newFromRawChanges($arcanist_changes);
|
||||
return $diff->getChangesets();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -6,6 +6,11 @@
|
|||
|
||||
|
||||
|
||||
phutil_require_module('arcanist', 'parser/diff/change');
|
||||
|
||||
phutil_require_module('phabricator', 'applications/differential/constants/changetype');
|
||||
phutil_require_module('phabricator', 'applications/differential/storage/diff');
|
||||
|
||||
phutil_require_module('phutil', 'utils');
|
||||
|
||||
|
||||
|
|
|
@ -112,8 +112,8 @@ final class DiffusionSvnDiffQuery extends DiffusionDiffQuery {
|
|||
$changesets = $diff->getChangesets();
|
||||
$changeset = reset($changesets);
|
||||
|
||||
$id = $drequest->getPath().';'.$drequest->getCommit();
|
||||
$changeset->setID($id);
|
||||
$reference = $drequest->getPath().';'.$drequest->getCommit();
|
||||
$changeset->setRenderingReference($reference);
|
||||
|
||||
return $changeset;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue