Changeset View
Changeset View
Standalone View
Standalone View
src/repository/graph/view/ArcanistCommitGraphSetView.php
| Show First 20 Lines • Show All 163 Lines • ▼ Show 20 Lines | foreach ($commit_refs as $commit_ref) { | ||||
| $revision_ref = idx($result_map, $commit_hash); | $revision_ref = idx($result_map, $commit_hash); | ||||
| $object_layout[] = array( | $object_layout[] = array( | ||||
| 'commit' => $commit_ref, | 'commit' => $commit_ref, | ||||
| 'revision' => $revision_ref, | 'revision' => $revision_ref, | ||||
| ); | ); | ||||
| } | } | ||||
| $marker_layout = array(); | $items = array(); | ||||
| foreach ($object_layout as $layout) { | foreach ($object_layout as $layout) { | ||||
| $commit_ref = idx($layout, 'commit'); | $commit_ref = idx($layout, 'commit'); | ||||
| if (!$commit_ref) { | if (!$commit_ref) { | ||||
| $marker_layout[] = $layout; | $items[] = $layout; | ||||
| continue; | continue; | ||||
| } | } | ||||
| $commit_hash = $commit_ref->getCommitHash(); | $commit_hash = $commit_ref->getCommitHash(); | ||||
| $markers = idx($marker_refs, $commit_hash); | $markers = idx($marker_refs, $commit_hash); | ||||
| if (!$markers) { | if (!$markers) { | ||||
| $marker_layout[] = $layout; | $items[] = $layout; | ||||
| continue; | continue; | ||||
| } | } | ||||
| $head_marker = array_shift($markers); | $head_marker = array_shift($markers); | ||||
| $layout['marker'] = $head_marker; | $layout['marker'] = $head_marker; | ||||
| $marker_layout[] = $layout; | $items[] = $layout; | ||||
| if (!$markers) { | if (!$markers) { | ||||
| continue; | continue; | ||||
| } | } | ||||
| foreach ($markers as $marker) { | foreach ($markers as $marker) { | ||||
| $marker_layout[] = array( | $items[] = array( | ||||
| 'marker' => $marker, | 'marker' => $marker, | ||||
| ); | ); | ||||
| } | } | ||||
| } | } | ||||
| $marker_view = $this->drawMarkerCell($marker_layout); | $items = $this->collapseItems($items); | ||||
| $commits_view = $this->drawCommitsCell($marker_layout); | |||||
| $status_view = $this->drawStatusCell($marker_layout); | $marker_view = $this->drawMarkerCell($items); | ||||
| $revisions_view = $this->drawRevisionsCell($marker_layout); | $commits_view = $this->drawCommitsCell($items); | ||||
| $messages_view = $this->drawMessagesCell($marker_layout); | $status_view = $this->drawStatusCell($items); | ||||
| $revisions_view = $this->drawRevisionsCell($items); | |||||
| $messages_view = $this->drawMessagesCell($items); | |||||
| return array( | return array( | ||||
| id(new ArcanistGridCell()) | id(new ArcanistGridCell()) | ||||
| ->setKey('marker') | ->setKey('marker') | ||||
| ->setContent($marker_view), | ->setContent($marker_view), | ||||
| id(new ArcanistGridCell()) | id(new ArcanistGridCell()) | ||||
| ->setKey('commits') | ->setKey('commits') | ||||
| ->setContent($commits_view), | ->setContent($commits_view), | ||||
| ▲ Show 20 Lines • Show All 91 Lines • ▼ Show 20 Lines | private function drawMarkerCell(array $items) { | ||||
| } | } | ||||
| return $cell; | return $cell; | ||||
| } | } | ||||
| private function drawCommitsCell(array $items) { | private function drawCommitsCell(array $items) { | ||||
| $cell = array(); | $cell = array(); | ||||
| foreach ($items as $item) { | foreach ($items as $item) { | ||||
| $count = idx($item, 'collapseCount'); | |||||
| if ($count) { | |||||
| $cell[] = tsprintf(" : \n"); | |||||
| continue; | |||||
| } | |||||
| $commit_ref = idx($item, 'commit'); | $commit_ref = idx($item, 'commit'); | ||||
| if (!$commit_ref) { | if (!$commit_ref) { | ||||
| $cell[] = tsprintf("\n"); | $cell[] = tsprintf("\n"); | ||||
| continue; | continue; | ||||
| } | } | ||||
| $commit_label = $this->drawCommitLabel($commit_ref); | $commit_label = $this->drawCommitLabel($commit_ref); | ||||
| $cell[] = tsprintf("%s\n", $commit_label); | $cell[] = tsprintf("%s\n", $commit_label); | ||||
| Show All 34 Lines | private function drawRevisionLabel(ArcanistRevisionRef $revision_ref) { | ||||
| return tsprintf('%s', $monogram); | return tsprintf('%s', $monogram); | ||||
| } | } | ||||
| private function drawMessagesCell(array $items) { | private function drawMessagesCell(array $items) { | ||||
| $cell = array(); | $cell = array(); | ||||
| foreach ($items as $item) { | foreach ($items as $item) { | ||||
| $count = idx($item, 'collapseCount'); | |||||
| if ($count) { | |||||
| $cell[] = tsprintf( | |||||
| "%s\n", | |||||
| pht( | |||||
| '<... %s more commits ...>', | |||||
| new PhutilNumber($count))); | |||||
| continue; | |||||
| } | |||||
| $revision_ref = idx($item, 'revision'); | $revision_ref = idx($item, 'revision'); | ||||
| if ($revision_ref) { | if ($revision_ref) { | ||||
| $cell[] = tsprintf("%s\n", $revision_ref->getName()); | $cell[] = tsprintf("%s\n", $revision_ref->getName()); | ||||
| continue; | continue; | ||||
| } | } | ||||
| $commit_ref = idx($item, 'commit'); | $commit_ref = idx($item, 'commit'); | ||||
| if ($commit_ref) { | if ($commit_ref) { | ||||
| Show All 38 Lines | if ($ansi_color) { | ||||
| $status = tsprintf( | $status = tsprintf( | ||||
| sprintf('<fg:%s>%%s</fg>', $ansi_color), | sprintf('<fg:%s>%%s</fg>', $ansi_color), | ||||
| $status); | $status); | ||||
| } | } | ||||
| return tsprintf('%s', $status); | return tsprintf('%s', $status); | ||||
| } | } | ||||
| private function collapseItems(array $items) { | |||||
| $show_context = 3; | |||||
| $map = array(); | |||||
| foreach ($items as $key => $item) { | |||||
| $can_collapse = | |||||
| (isset($item['commit'])) && | |||||
| (!isset($item['revision'])) && | |||||
| (!isset($item['marker'])); | |||||
| $map[$key] = $can_collapse; | |||||
| } | |||||
| $map = phutil_partition($map); | |||||
| foreach ($map as $partition) { | |||||
| $value = head($partition); | |||||
| if (!$value) { | |||||
| break; | |||||
| } | |||||
| $count = count($partition); | |||||
| if ($count < ($show_context * 2) + 3) { | |||||
| continue; | |||||
| } | |||||
| $partition = array_slice($partition, $show_context, -$show_context, true); | |||||
| $is_first = true; | |||||
| foreach ($partition as $key => $value) { | |||||
| if ($is_first) { | |||||
| $items[$key]['collapseCount'] = $count; | |||||
| } else { | |||||
| unset($items[$key]); | |||||
| } | |||||
| $is_first = false; | |||||
| } | |||||
| } | |||||
| return $items; | |||||
| } | |||||
| } | } | ||||