From e85ecd03de67c530bee64047d7d237f1fb6c69d1 Mon Sep 17 00:00:00 2001 From: epriestley Date: Mon, 24 Jan 2011 13:18:41 -0800 Subject: [PATCH] DifferentialDiffView --- .divinerconfig | 6 +- src/__phutil_library_map__.php | 8 ++ ...AphrontDefaultApplicationConfiguration.php | 5 + .../base/DifferentialController.php | 34 +++++ .../differential/controller/base/__init__.php | 16 +++ .../DifferentialDiffViewController.php | 52 +++++++ .../controller/diffview/__init__.php | 17 +++ .../DifferentialChangesetDetailView.php | 131 ++++++++++++++++++ .../DifferentialDiffTableOfContentsView.php | 121 ++++++++++++++++ .../view/difftableofcontents/__init__.php | 15 ++ webroot/rsrc/css/base.css | 45 +++++- 11 files changed, 447 insertions(+), 3 deletions(-) create mode 100644 src/applications/differential/controller/base/DifferentialController.php create mode 100644 src/applications/differential/controller/base/__init__.php create mode 100644 src/applications/differential/controller/diffview/DifferentialDiffViewController.php create mode 100644 src/applications/differential/controller/diffview/__init__.php create mode 100644 src/applications/differential/view/changesetdetailview/DifferentialChangesetDetailView.php create mode 100644 src/applications/differential/view/difftableofcontents/DifferentialDiffTableOfContentsView.php create mode 100644 src/applications/differential/view/difftableofcontents/__init__.php diff --git a/.divinerconfig b/.divinerconfig index 51d539832b..18dd78d6d1 100644 --- a/.divinerconfig +++ b/.divinerconfig @@ -1,7 +1,9 @@ { - "name" : "differential", - "src_base" : "https://github.com/facebook/differential/blob/master", + "name" : "Phabricator", + "src_base" : "https://github.com/facebook/phabricator/blob/master", "groups" : { + "aphront" : "Aphront (Web Stack)", + "storage" : "Storage" } } diff --git a/src/__phutil_library_map__.php b/src/__phutil_library_map__.php index 54f01b66a5..283c3d5b91 100644 --- a/src/__phutil_library_map__.php +++ b/src/__phutil_library_map__.php @@ -57,9 +57,13 @@ phutil_register_library_map(array( 'DifferentialAction' => 'applications/differential/constants/action', 'DifferentialChangeType' => 'applications/differential/constants/changetype', 'DifferentialChangeset' => 'applications/differential/storage/changeset', + 'DifferentialChangesetDetailView' => 'applications/differential/view/changesetdetailview', + 'DifferentialController' => 'applications/differential/controller/base', 'DifferentialDAO' => 'applications/differential/storage/base', 'DifferentialDiff' => 'applications/differential/storage/diff', 'DifferentialDiffProperty' => 'applications/differential/storage/diffproperty', + 'DifferentialDiffTableOfContentsView' => 'applications/differential/view/difftableofcontents', + 'DifferentialDiffViewController' => 'applications/differential/controller/diffview', 'DifferentialHunk' => 'applications/differential/storage/hunk', 'DifferentialLintStatus' => 'applications/differential/constants/lintstatus', 'DifferentialRevision' => 'applications/differential/storage/revision', @@ -160,9 +164,13 @@ phutil_register_library_map(array( 'ConduitAPI_file_upload_Method' => 'ConduitAPIMethod', 'ConduitAPI_user_find_Method' => 'ConduitAPIMethod', 'DifferentialChangeset' => 'DifferentialDAO', + 'DifferentialChangesetDetailView' => 'AphrontView', + 'DifferentialController' => 'PhabricatorController', 'DifferentialDAO' => 'PhabricatorLiskDAO', 'DifferentialDiff' => 'DifferentialDAO', 'DifferentialDiffProperty' => 'DifferentialDAO', + 'DifferentialDiffTableOfContentsView' => 'AphrontView', + 'DifferentialDiffViewController' => 'DifferentialController', 'DifferentialHunk' => 'DifferentialDAO', 'DifferentialRevision' => 'DifferentialDAO', 'PhabricatorConduitAPIController' => 'PhabricatorConduitController', diff --git a/src/aphront/default/configuration/AphrontDefaultApplicationConfiguration.php b/src/aphront/default/configuration/AphrontDefaultApplicationConfiguration.php index bed40f15f5..08db3600c5 100644 --- a/src/aphront/default/configuration/AphrontDefaultApplicationConfiguration.php +++ b/src/aphront/default/configuration/AphrontDefaultApplicationConfiguration.php @@ -75,6 +75,11 @@ class AphrontDefaultApplicationConfiguration 'log/$' => 'PhabricatorConduitLogController', ), '/api/(?[^/]+)$' => 'PhabricatorConduitAPIController', + + '/differential/' => array( + 'diff/(?\d+)/$' => 'DifferentialDiffViewController', + ), + '.*' => 'AphrontDefaultApplicationController', ); } diff --git a/src/applications/differential/controller/base/DifferentialController.php b/src/applications/differential/controller/base/DifferentialController.php new file mode 100644 index 0000000000..f896b73487 --- /dev/null +++ b/src/applications/differential/controller/base/DifferentialController.php @@ -0,0 +1,34 @@ +setApplicationName('Differential'); + $page->setBaseURI('/differential/'); + $page->setTitle(idx($data, 'title')); + $page->setGlyph("\xE2\x9A\x99"); + $page->appendChild($view); + + $response = new AphrontWebpageResponse(); + return $response->setContent($page->render()); + } + +} diff --git a/src/applications/differential/controller/base/__init__.php b/src/applications/differential/controller/base/__init__.php new file mode 100644 index 0000000000..e554a20267 --- /dev/null +++ b/src/applications/differential/controller/base/__init__.php @@ -0,0 +1,16 @@ +id = $data['id']; + } + + public function processRequest() { + $diff = id(new DifferentialDiff())->load($this->id); + if (!$diff) { + return new Aphront404Response(); + } + + $changesets = $diff->loadChangesets(); + $changesets = msort($changesets, 'getSortKey'); + + $table_of_contents = id(new DifferentialDiffTableOfContentsView()) + ->setChangesets($changesets); + + $details = id(new DifferentialChangesetDetailView()) + ->setChangesets($changesets); + + return $this->buildStandardPageResponse( + array( + $table_of_contents, + $details, + ), + array( + 'title' => 'Diff View', + )); + } + +} diff --git a/src/applications/differential/controller/diffview/__init__.php b/src/applications/differential/controller/diffview/__init__.php new file mode 100644 index 0000000000..5a2715daa8 --- /dev/null +++ b/src/applications/differential/controller/diffview/__init__.php @@ -0,0 +1,17 @@ +changesets = $changesets; + return $this; + } + + public function render() { + $against = array(); // TODO + $edit = false; + + $changesets = $this->changesets; + foreach ($changesets as $key => $changeset) { + if (empty($against[$changeset->getID()])) { + $type = $changeset->getChangeType(); + if ($type == DifferentialChangeType::TYPE_MOVE_AWAY || + $type == DifferentialChangeType::TYPE_MULTICOPY) { + unset($changesets[$key]); + } + } + } + + $output = array(); + $mapping = array(); + foreach ($changesets as $key => $changeset) { + $file = $changeset->getFilename(); + $class = 'differential-changeset'; + if (!$edit) { + $class .= ' differential-changeset-noneditable'; + } + $id = $changeset->getID(); + if ($id) { + $against_id = idx($against, $id); + } else { + $against_id = null; + } + +/* + $detail_uri = URI($render_uri) + ->addQueryData(array( + 'changeset' => $id, + 'against' => $against_id, + 'whitespace' => $whitespace, + )); +*/ + $detail_uri = '!'; + + $detail = phutil_render_tag( + 'a', + array( + 'style' => 'float: right', + 'href' => $detail_uri, + 'target' => '_blank', + ), + 'Standalone View'); + +// $div =
Loading…
; + + $display_filename = $changeset->getDisplayFilename(); + $output[] = + '
'. + '

'.phutil_escape_html($display_filename).'

'. + '
Loading...
'. + '
'; + +/* +
getID()}> + {$detail} +

{$file}

+ {$div} +
; +*/ +/* + $mapping[$div->requireUniqueId()] = array_filter( + array( + $changeset->getID(), + idx($against, $changeset->getID()), + )); + +*/ + } +/* + require_static('differential-diff-css'); + require_static('differential-syntax-css'); + + Javelin::initBehavior('differential-populate', array( + 'registry' => $mapping, + 'whitespace' => $whitespace, + 'uri' => $render_uri, + )); + + Javelin::initBehavior('differential-context', array( + 'uri' => $render_uri, + )); + + if ($edit) { + require_static('remarkup-css'); + Javelin::initBehavior('differential-inline', array( + 'uri' => '/differential/feedback/'.$revision->getID().'/', + )); + } +*/ + return + '
'. + implode("\n", $output). + '
'; + } + +} diff --git a/src/applications/differential/view/difftableofcontents/DifferentialDiffTableOfContentsView.php b/src/applications/differential/view/difftableofcontents/DifferentialDiffTableOfContentsView.php new file mode 100644 index 0000000000..6c5e4c2188 --- /dev/null +++ b/src/applications/differential/view/difftableofcontents/DifferentialDiffTableOfContentsView.php @@ -0,0 +1,121 @@ +changesets = $changesets; + return $this; + } + + public function render() { + + $rows = array(); + + $changesets = $this->changesets; + foreach ($changesets as $changeset) { + $file = $changeset->getFilename(); + $display_file = $changeset->getDisplayFilename(); + + $type = $changeset->getChangeType(); + $ftype = $changeset->getFileType(); + + if (DifferentialChangeType::isOldLocationChangeType($type)) { + $link = phutil_escape_html($display_file); + $away = $changeset->getAwayPaths(); + if (count($away) > 1) { + $meta = array(); + if ($type == DifferentialChangeType::TYPE_MULTICOPY) { + $meta[] = 'Deleted after being copied to multiple locations:'; + } else { + $meta[] = 'Copied to multiple locations:'; + } + foreach ($away as $path) { + $meta[] = $path; + } + $meta = implode('
', $meta); + } else { + if ($type == DifferentialChangeType::TYPE_MOVE_AWAY) { + $meta = 'Moved to '.reset($away); + } else { + $meta = 'Copied to '.reset($away); + } + } + } else { + $link = phutil_render_tag( + 'a', + array( + 'href' => '#', // TODO: filename normalizer + ), + phutil_escape_html($display_file)); + if ($type == DifferentialChangeType::TYPE_MOVE_HERE) { + $meta = 'Moved from '.phutil_escape_html($changeset->getOldFile()); + } else if ($type == DifferentialChangeType::TYPE_COPY_HERE) { + $meta = 'Copied from '.phutil_escape_html($changeset->getOldFile()); + } else { + $meta = null; + } + } + + $line_count = $changeset->getAffectedLineCount(); + if ($line_count == 0) { + $lines = null; + } else if ($line_count == 1) { + $lines = ' (1 line)'; + } else { + $lines = ' ('.$line_count.' lines)'; + } + + $char = DifferentialChangeType::getSummaryCharacterForChangeType($type); + $chartitle = DifferentialChangeType::getFullNameForChangeType($type); + $desc = DifferentialChangeType::getShortNameForFileType($ftype); + if ($desc) { + $desc = '('.$desc.')'; + } + $pchar = + ($changeset->getOldProperties() === $changeset->getNewProperties()) + ? null + : 'M'; + + $rows[] = + ''. + ''.$char.''. + ''.$pchar.''. + ''.$desc.''. + ''.$link.$lines.''. + ''; + if ($meta) { + $rows[] = + ''. + ''. + ''.$meta.''. + ''; + } + } + + return + '
'. + '

Table of Contents

'. + ''. + implode("\n", $rows). + '
'. + '
'; + } +} diff --git a/src/applications/differential/view/difftableofcontents/__init__.php b/src/applications/differential/view/difftableofcontents/__init__.php new file mode 100644 index 0000000000..6981924676 --- /dev/null +++ b/src/applications/differential/view/difftableofcontents/__init__.php @@ -0,0 +1,15 @@ +