From 5e00d00cf79f97ef443da060759a181ba978dad8 Mon Sep 17 00:00:00 2001 From: epriestley Date: Sat, 16 Jul 2011 18:44:48 -0700 Subject: [PATCH] Show more information on revision views Summary: Show line count, arcanist project and base revision. This adds a little clutter but I think we're still okay and I can play around with it later. Test Plan: Looked at a couple of revisions. I'm actually not 100% sure about the SVN logic but maybe I will test that before committing. Reviewed By: tomo Reviewers: tomo, jungejason, tuomaspelkonen, aran CC: aran, tomo Differential Revision: 685 --- .../DifferentialRevisionViewController.php | 11 +++ .../DifferentialRevisionUpdateHistoryView.php | 75 ++++++++++++------- .../constants/PhabricatorPHIDConstants.php | 1 + .../data/PhabricatorObjectHandleData.php | 20 +++++ 4 files changed, 81 insertions(+), 26 deletions(-) diff --git a/src/applications/differential/controller/revisionview/DifferentialRevisionViewController.php b/src/applications/differential/controller/revisionview/DifferentialRevisionViewController.php index 81d83f3a8b..e1192c3e7e 100644 --- a/src/applications/differential/controller/revisionview/DifferentialRevisionViewController.php +++ b/src/applications/differential/controller/revisionview/DifferentialRevisionViewController.php @@ -99,6 +99,10 @@ class DifferentialRevisionViewController extends DifferentialController { } } + if ($target->getArcanistProjectPHID()) { + $object_phids[] = $target->getArcanistProjectPHID(); + } + foreach ($revision->getAttached() as $type => $phids) { foreach ($phids as $phid => $info) { $object_phids[] = $phid; @@ -457,6 +461,13 @@ class DifferentialRevisionViewController extends DifferentialController { $properties['Commits'] = implode('
', $links); } + $properties['Lines'] = number_format($diff->getLineCount()); + $arcanist_phid = $diff->getArcanistProjectPHID(); + if ($arcanist_phid) { + $properties['Arcanist Project'] = phutil_escape_html( + $handles[$arcanist_phid]->getName()); + } + $properties['Apply Patch'] = 'arc patch D'.$revision->getID().''; $properties['Export Patch'] = diff --git a/src/applications/differential/view/revisionupdatehistory/DifferentialRevisionUpdateHistoryView.php b/src/applications/differential/view/revisionupdatehistory/DifferentialRevisionUpdateHistoryView.php index 9d71845ad7..df14dfa595 100644 --- a/src/applications/differential/view/revisionupdatehistory/DifferentialRevisionUpdateHistoryView.php +++ b/src/applications/differential/view/revisionupdatehistory/DifferentialRevisionUpdateHistoryView.php @@ -75,6 +75,7 @@ final class DifferentialRevisionUpdateHistoryView extends AphrontView { $rows = array(); $disable = false; $radios = array(); + $last_base = null; foreach ($data as $row) { $name = phutil_escape_html($row['name']); @@ -123,7 +124,8 @@ final class DifferentialRevisionUpdateHistoryView extends AphrontView { $old = null; } - $desc = phutil_escape_html($row['desc']); + $desc = $row['desc']; + if ($row['age']) { $age = phabricator_format_timestamp($row['age']); } else { @@ -144,11 +146,18 @@ final class DifferentialRevisionUpdateHistoryView extends AphrontView { $unit = null; } + $base = $this->renderBaseRevision($diff); + if ($last_base !== null && $base !== $last_base) { + // TODO: Render some kind of notice about rebases. + } + $last_base = $base; + $rows[] = ''. ''.$name.''. ''.$id.''. - ''.$desc.''. + ''.phutil_escape_html($base).''. + ''.phutil_escape_html($desc).''. ''.$age.''. ''.$lint.''. ''.$unit.''. @@ -157,31 +166,31 @@ final class DifferentialRevisionUpdateHistoryView extends AphrontView { ''; } - Javelin::initBehavior( - 'differential-diff-radios', + Javelin::initBehavior( + 'differential-diff-radios', + array( + 'radios' => $radios, + )); + + $options = array( + 'ignore-all' => 'Ignore All', + 'ignore-trailing' => 'Ignore Trailing', + 'show-all' => 'Show All', + ); + + $select = ''; - foreach ($options as $value => $label) { - $select .= phutil_render_tag( - 'option', - array( - 'value' => $value, - 'selected' => ($value == $this->selectedWhitespace) - ? 'selected' - : null, - ), - phutil_escape_html($label)); - } - $select .= ''; + 'value' => $value, + 'selected' => ($value == $this->selectedWhitespace) + ? 'selected' + : null, + ), + phutil_escape_html($label)); + } + $select .= ''; return '
'. @@ -191,6 +200,7 @@ final class DifferentialRevisionUpdateHistoryView extends AphrontView { ''. 'Diff'. 'ID'. + 'Base'. 'Description'. 'Created'. 'Lint'. @@ -285,4 +295,17 @@ final class DifferentialRevisionUpdateHistoryView extends AphrontView { ''; } + private function renderBaseRevision(DifferentialDiff $diff) { + switch ($diff->getSourceControlSystem()) { + case 'git': + return substr($diff->getSourceControlBaseRevision(), 0, 7); + case 'svn': + $base = $diff->getSourceControlBaseRevision(); + $base = explode('@', $base); + $base = end($base); + return $base; + default: + return null; + } + } } diff --git a/src/applications/phid/constants/PhabricatorPHIDConstants.php b/src/applications/phid/constants/PhabricatorPHIDConstants.php index 2b603059ff..7595bfc673 100644 --- a/src/applications/phid/constants/PhabricatorPHIDConstants.php +++ b/src/applications/phid/constants/PhabricatorPHIDConstants.php @@ -33,5 +33,6 @@ final class PhabricatorPHIDConstants { const PHID_TYPE_STRY = 'STRY'; const PHID_TYPE_POLL = 'POLL'; const PHID_TYPE_WIKI = 'WIKI'; + const PHID_TYPE_APRJ = 'APRJ'; } diff --git a/src/applications/phid/handle/data/PhabricatorObjectHandleData.php b/src/applications/phid/handle/data/PhabricatorObjectHandleData.php index f105c99fcd..277769d275 100644 --- a/src/applications/phid/handle/data/PhabricatorObjectHandleData.php +++ b/src/applications/phid/handle/data/PhabricatorObjectHandleData.php @@ -345,6 +345,26 @@ class PhabricatorObjectHandleData { $handles[$phid] = $handle; } break; + case PhabricatorPHIDConstants::PHID_TYPE_APRJ: + $project_dao = newv('PhabricatorRepositoryArcanistProject', array()); + + $projects = $project_dao->loadAllWhere( + 'phid IN (%Ls)', + $phids); + $projects = mpull($projects, null, 'getPHID'); + foreach ($phids as $phid) { + $handle = new PhabricatorObjectHandle(); + $handle->setPHID($phid); + $handle->setType($type); + if (empty($projects[$phid])) { + $handle->setName('Unknown Arcanist Project'); + } else { + $project = $projects[$phid]; + $handle->setName($project->getName()); + } + $handles[$phid] = $handle; + } + break; case PhabricatorPHIDConstants::PHID_TYPE_WIKI: $document_dao = newv('PhrictionDocument', array()); $content_dao = newv('PhrictionContent', array());