From 338851ac54be8467d17279d18db7d86e4acc556c Mon Sep 17 00:00:00 2001 From: Jakub Vrana Date: Sat, 6 Apr 2013 11:40:43 -0700 Subject: [PATCH] Merge attached revisions and commits in task detail Summary: With freetext fields, most tasks would have attached revisions when they have attached commits. See T1048 for example. Merge these two fields together. Test Plan: Displayed task with commit and unrelated revision. Displayed task with commit and related revision: {F39394,size=full} Reviewers: epriestley Reviewed By: epriestley CC: aran, Korvin Differential Revision: https://secure.phabricator.com/D5601 --- .../ManiphestTaskDetailController.php | 42 ++++++++++++++++++- .../phid/PhabricatorObjectHandle.php | 6 ++- 2 files changed, 44 insertions(+), 4 deletions(-) diff --git a/src/applications/maniphest/controller/ManiphestTaskDetailController.php b/src/applications/maniphest/controller/ManiphestTaskDetailController.php index ad01efbe19..4b66aea52c 100644 --- a/src/applications/maniphest/controller/ManiphestTaskDetailController.php +++ b/src/applications/maniphest/controller/ManiphestTaskDetailController.php @@ -493,10 +493,42 @@ final class ManiphestTaskDetailController extends ManiphestController { => pht('Depends On'), PhabricatorEdgeConfig::TYPE_TASK_HAS_RELATED_DREV => pht('Differential Revisions'), - PhabricatorEdgeConfig::TYPE_TASK_HAS_COMMIT - => pht('Commits'), ); + $revisions_commits = array(); + $handles = $this->getLoadedHandles(); + + $commit_phids = array_keys( + $edges[PhabricatorEdgeConfig::TYPE_TASK_HAS_COMMIT]); + if ($commit_phids) { + $commits = id(new PhabricatorRepositoryCommit()) + ->putInSet(new LiskDAOSet()) + ->loadAllWhere('phid IN (%Ls)', $commit_phids); + + foreach ($commits as $commit) { + $phid = $commit->getPHID(); + $revisions_commits[$phid] = $handles[$phid]->renderLink(); + + $data = $commit->loadOneRelative( + new PhabricatorRepositoryCommitData(), + 'commitID'); + + $revision_phid = ($data + ? $data->getCommitDetail('differential.revisionPHID') + : null); + + $revision_handle = idx($handles, $revision_phid); + if ($revision_handle) { + $has_drev = PhabricatorEdgeConfig::TYPE_TASK_HAS_RELATED_DREV; + unset($edges[$has_drev][$revision_phid]); + $revisions_commits[$phid] = hsprintf( + '%s / %s', + $revision_handle->renderLink($revision_handle->getName()), + $revisions_commits[$phid]); + } + } + } + foreach ($edge_types as $edge_type => $edge_name) { if ($edges[$edge_type]) { $view->addProperty( @@ -505,6 +537,12 @@ final class ManiphestTaskDetailController extends ManiphestController { } } + if ($revisions_commits) { + $view->addProperty( + pht('Commits'), + phutil_implode_html(phutil_tag('br'), $revisions_commits)); + } + $attached = $task->getAttached(); $file_infos = idx($attached, PhabricatorPHIDConstants::PHID_TYPE_FILE); if ($file_infos) { diff --git a/src/applications/phid/PhabricatorObjectHandle.php b/src/applications/phid/PhabricatorObjectHandle.php index 1ded1abc27..c8673a5be0 100644 --- a/src/applications/phid/PhabricatorObjectHandle.php +++ b/src/applications/phid/PhabricatorObjectHandle.php @@ -166,8 +166,10 @@ final class PhabricatorObjectHandle { } - public function renderLink() { - $name = $this->getLinkName(); + public function renderLink($name = null) { + if ($name === null) { + $name = $this->getLinkName(); + } $class = null; $title = null;