Changeset View
Changeset View
Standalone View
Standalone View
src/repository/graph/view/ArcanistCommitGraphSetView.php
| Show First 20 Lines • Show All 247 Lines • ▼ Show 20 Lines | return array( | ||||
| id(new ArcanistGridCell()) | id(new ArcanistGridCell()) | ||||
| ->setKey('messages') | ->setKey('messages') | ||||
| ->setContent($messages_view), | ->setContent($messages_view), | ||||
| ); | ); | ||||
| } | } | ||||
| private function drawMarkerCell(array $items) { | private function drawMarkerCell(array $items) { | ||||
| $api = $this->getRepositoryAPI(); | $api = $this->getRepositoryAPI(); | ||||
| $depth = $this->getViewDepth(); | |||||
| $marker_refs = $this->getMarkerRefs(); | $marker_refs = $this->getMarkerRefs(); | ||||
| $commit_refs = $this->getCommitRefs(); | $commit_refs = $this->getCommitRefs(); | ||||
| if (count($commit_refs) === 1) { | if (count($commit_refs) === 1) { | ||||
| $commit_ref = head($commit_refs); | $commit_ref = head($commit_refs); | ||||
| $commit_hash = $commit_ref->getCommitHash(); | $commit_hash = $commit_ref->getCommitHash(); | ||||
| $commit_hash = tsprintf( | $commit_hash = tsprintf( | ||||
| '%s', | '%s', | ||||
| substr($commit_hash, 0, 7)); | substr($commit_hash, 0, 7)); | ||||
| $commit_label = $commit_hash; | $commit_label = $commit_hash; | ||||
| } else { | } else { | ||||
| $min = head($commit_refs); | $min = head($commit_refs); | ||||
| $max = last($commit_refs); | $max = last($commit_refs); | ||||
| $commit_label = tsprintf( | $commit_label = tsprintf( | ||||
| '%s..%s', | '%s..%s', | ||||
| substr($min->getCommitHash(), 0, 7), | substr($min->getCommitHash(), 0, 7), | ||||
| substr($max->getCommitHash(), 0, 7)); | substr($max->getCommitHash(), 0, 7)); | ||||
| } | } | ||||
| $member_views = $this->getMemberViews(); | |||||
| $member_count = count($member_views); | |||||
| if ($member_count > 1) { | |||||
| $items[] = array( | |||||
| 'group' => $member_views, | |||||
| ); | |||||
| } | |||||
| $terminal_width = phutil_console_get_terminal_width(); | $terminal_width = phutil_console_get_terminal_width(); | ||||
| $max_depth = (int)floor(3 + (max(0, $terminal_width - 72) / 6)); | $max_depth = (int)floor(3 + (max(0, $terminal_width - 72) / 6)); | ||||
| $depth = $this->getViewDepth(); | |||||
| if ($depth <= $max_depth) { | if ($depth <= $max_depth) { | ||||
| $indent = str_repeat(' ', ($depth * 2)); | $display_depth = ($depth * 2); | ||||
| $is_squished = false; | |||||
| } else { | } else { | ||||
| $more = ' ... '; | $display_depth = ($max_depth * 2); | ||||
| $indent = str_repeat(' ', ($max_depth * 2) - strlen($more)).$more; | $is_squished = true; | ||||
| } | } | ||||
| $indent .= '- '; | |||||
| $empty_indent = str_repeat(' ', strlen($indent)); | |||||
| $max_width = ($max_depth * 2) + 16; | $max_width = ($max_depth * 2) + 16; | ||||
| $available_width = $max_width - (min($max_depth, $depth) * 2); | $available_width = $max_width - $display_depth; | ||||
| $mark_ne = "\xE2\x94\x97"; | |||||
| $mark_ew = "\xE2\x94\x81"; | |||||
| $mark_esw = "\xE2\x94\xB3"; | |||||
| $mark_sw = "\xE2\x94\x93"; | |||||
| $mark_bullet = "\xE2\x80\xA2"; | |||||
| $mark_ns_light = "\xE2\x94\x82"; | |||||
| $mark_ne_light = "\xE2\x94\x94"; | |||||
| $mark_esw_light = "\xE2\x94\xAF"; | |||||
| $has_children = $this->getChildViews(); | |||||
| $is_first = true; | $is_first = true; | ||||
| $last_key = last_key($items); | |||||
| $cell = array(); | $cell = array(); | ||||
| foreach ($items as $item) { | foreach ($items as $item_key => $item) { | ||||
| $marker_ref = idx($item, 'marker'); | $marker_ref = idx($item, 'marker'); | ||||
| $group_ref = idx($item, 'group'); | |||||
| $is_last = ($item_key === $last_key); | |||||
| if ($marker_ref) { | if ($marker_ref) { | ||||
| $marker_name = $marker_ref->getName(); | $marker_name = $marker_ref->getName(); | ||||
| $is_active = $marker_ref->getIsActive(); | |||||
| if ($is_active) { | |||||
| $marker_width = $available_width - 4; | |||||
| } else { | |||||
| $marker_width = $available_width; | |||||
| } | |||||
| $marker_name = id(new PhutilUTF8StringTruncator()) | $marker_name = id(new PhutilUTF8StringTruncator()) | ||||
| ->setMaximumGlyphs($available_width) | ->setMaximumGlyphs($marker_width) | ||||
| ->truncateString($marker_name); | ->truncateString($marker_name); | ||||
| if ($marker_ref->getIsActive()) { | if ($marker_ref->getIsActive()) { | ||||
| $label = tsprintf( | $label = tsprintf( | ||||
| '<bg:green>**%s**</bg>', | '<bg:green>**%s**</bg> **%s**', | ||||
| ' * ', | |||||
| $marker_name); | $marker_name); | ||||
| } else { | } else { | ||||
| $label = tsprintf( | $label = tsprintf( | ||||
| '**%s**', | '**%s**', | ||||
| $marker_name); | $marker_name); | ||||
| } | } | ||||
| } else if ($group_ref) { | |||||
| $label = pht( | |||||
| '(... %s more revisions ...)', | |||||
| new PhutilNumber(count($group_ref) - 1)); | |||||
| } else if ($is_first) { | } else if ($is_first) { | ||||
| $label = $commit_label; | $label = $commit_label; | ||||
| } else { | } else { | ||||
| $label = ''; | $label = ''; | ||||
| } | } | ||||
| if ($display_depth > 2) { | |||||
| $indent = str_repeat(' ', $display_depth - 2); | |||||
| } else { | |||||
| $indent = ''; | |||||
| } | |||||
| if ($is_first) { | if ($is_first) { | ||||
| $indent_text = $indent; | if ($display_depth === 0) { | ||||
| $path = $mark_bullet.' '; | |||||
| } else { | |||||
| if ($has_children) { | |||||
| $path = $mark_ne.$mark_ew.$mark_esw.' '; | |||||
| } else if (!$is_last) { | |||||
| $path = $mark_ne.$mark_ew.$mark_esw_light.' '; | |||||
| } else { | |||||
| $path = $mark_ne.$mark_ew.$mark_ew.' '; | |||||
| } | |||||
| } | |||||
| } else if ($group_ref) { | |||||
| $path = $mark_ne.'/'.$mark_sw.' '; | |||||
| } else { | |||||
| if ($is_last && !$has_children) { | |||||
| $path = $mark_ne_light.' '; | |||||
| } else { | } else { | ||||
| $indent_text = $empty_indent; | $path = $mark_ns_light.' '; | ||||
| } | |||||
| if ($display_depth > 0) { | |||||
| $path = ' '.$path; | |||||
| } | |||||
| } | } | ||||
| $indent_text = sprintf( | |||||
| '%s%s', | |||||
| $indent, | |||||
| $path); | |||||
| $cell[] = tsprintf( | $cell[] = tsprintf( | ||||
| "%s%s\n", | "%s%s\n", | ||||
| $indent_text, | $indent_text, | ||||
| $label); | $label); | ||||
| $is_first = false; | $is_first = false; | ||||
| } | } | ||||
| $member_views = $this->getMemberViews(); | |||||
| $member_count = count($member_views); | |||||
| if ($member_count > 1) { | |||||
| $cell[] = tsprintf( | |||||
| "%s%s\n", | |||||
| $empty_indent, | |||||
| pht( | |||||
| '- <... %s more revisions ...>', | |||||
| new PhutilNumber($member_count - 1))); | |||||
| } | |||||
| 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'); | $count = idx($item, 'collapseCount'); | ||||
| if ($count) { | if ($count) { | ||||
| ▲ Show 20 Lines • Show All 161 Lines • Show Last 20 Lines | |||||