Select the types of activity you want to include in your feed.
@recaptime-dev's working patches + fork for Phorge, a community fork of Phabricator. (Upstream dev and stable branches are at upstream/main and upstream/stable respectively.)
hq.recaptime.dev/wiki/Phorge
···1919 return pht('Lists revisions this one is depended on by.');
2020 }
21212222- public function shouldAppearInPropertyView() {
2323- return true;
2424- }
2525-2626- public function renderPropertyViewLabel() {
2727- return $this->getFieldName();
2828- }
2929-3030- public function getRequiredHandlePHIDsForPropertyView() {
3131- return PhabricatorEdgeQuery::loadDestinationPHIDs(
3232- $this->getObject()->getPHID(),
3333- DifferentialRevisionDependedOnByRevisionEdgeType::EDGECONST);
3434- }
3535-3636- public function renderPropertyViewValue(array $handles) {
3737- return $this->renderHandleList($handles);
3838- }
3939-4022}
···82828383 $graph = null;
8484 if ($this->parents) {
8585- $graph = $this->renderGraph();
8585+ $graph = id(new PHUIDiffGraphView())
8686+ ->setIsHead($this->isHead)
8787+ ->setIsTail($this->isTail)
8888+ ->renderGraph($this->parents);
8689 }
87908891 $show_builds = PhabricatorApplication::isClassInstalledForViewer(
···217220 false,
218221 ));
219222 return $view->render();
220220- }
221221-222222- /**
223223- * Draw a merge/branch graph from the parent revision data. We're basically
224224- * building up a bunch of strings like this:
225225- *
226226- * ^
227227- * |^
228228- * o|
229229- * |o
230230- * o
231231- *
232232- * ...which form an ASCII representation of the graph we eventually want to
233233- * draw.
234234- *
235235- * NOTE: The actual implementation is black magic.
236236- */
237237- private function renderGraph() {
238238- // This keeps our accumulated information about each line of the
239239- // merge/branch graph.
240240- $graph = array();
241241-242242- // This holds the next commit we're looking for in each column of the
243243- // graph.
244244- $threads = array();
245245-246246- // This is the largest number of columns any row has, i.e. the width of
247247- // the graph.
248248- $count = 0;
249249-250250- foreach ($this->history as $key => $history) {
251251- $joins = array();
252252- $splits = array();
253253-254254- $parent_list = $this->parents[$history->getCommitIdentifier()];
255255-256256- // Look for some thread which has this commit as the next commit. If
257257- // we find one, this commit goes on that thread. Otherwise, this commit
258258- // goes on a new thread.
259259-260260- $line = '';
261261- $found = false;
262262- $pos = count($threads);
263263- for ($n = 0; $n < $count; $n++) {
264264- if (empty($threads[$n])) {
265265- $line .= ' ';
266266- continue;
267267- }
268268-269269- if ($threads[$n] == $history->getCommitIdentifier()) {
270270- if ($found) {
271271- $line .= ' ';
272272- $joins[] = $n;
273273- unset($threads[$n]);
274274- } else {
275275- $line .= 'o';
276276- $found = true;
277277- $pos = $n;
278278- }
279279- } else {
280280-281281- // We render a "|" for any threads which have a commit that we haven't
282282- // seen yet, this is later drawn as a vertical line.
283283- $line .= '|';
284284- }
285285- }
286286-287287- // If we didn't find the thread this commit goes on, start a new thread.
288288- // We use "o" to mark the commit for the rendering engine, or "^" to
289289- // indicate that there's nothing after it so the line from the commit
290290- // upward should not be drawn.
291291-292292- if (!$found) {
293293- if ($this->isHead) {
294294- $line .= '^';
295295- } else {
296296- $line .= 'o';
297297- foreach ($graph as $k => $meta) {
298298- // Go back across all the lines we've already drawn and add a
299299- // "|" to the end, since this is connected to some future commit
300300- // we don't know about.
301301- for ($jj = strlen($meta['line']); $jj <= $count; $jj++) {
302302- $graph[$k]['line'] .= '|';
303303- }
304304- }
305305- }
306306- }
307307-308308- // Update the next commit on this thread to the commit's first parent.
309309- // This might have the effect of making a new thread.
310310- $threads[$pos] = head($parent_list);
311311-312312- // If we made a new thread, increase the thread count.
313313- $count = max($pos + 1, $count);
314314-315315- // Now, deal with splits (merges). I picked this terms opposite to the
316316- // underlying repository term to confuse you.
317317- foreach (array_slice($parent_list, 1) as $parent) {
318318- $found = false;
319319-320320- // Try to find the other parent(s) in our existing threads. If we find
321321- // them, split to that thread.
322322-323323- foreach ($threads as $idx => $thread_commit) {
324324- if ($thread_commit == $parent) {
325325- $found = true;
326326- $splits[] = $idx;
327327- }
328328- }
329329-330330- // If we didn't find the parent, we don't know about it yet. Find the
331331- // first free thread and add it as the "next" commit in that thread.
332332- // This might create a new thread.
333333-334334- if (!$found) {
335335- for ($n = 0; $n < $count; $n++) {
336336- if (empty($threads[$n])) {
337337- break;
338338- }
339339- }
340340- $threads[$n] = $parent;
341341- $splits[] = $n;
342342- $count = max($n + 1, $count);
343343- }
344344- }
345345-346346- $graph[] = array(
347347- 'line' => $line,
348348- 'split' => $splits,
349349- 'join' => $joins,
350350- );
351351- }
352352-353353- // If this is the last page in history, replace the "o" with an "x" so we
354354- // do not draw a connecting line downward, and replace "^" with an "X" for
355355- // repositories with exactly one commit.
356356- if ($this->isTail && $graph) {
357357- $last = array_pop($graph);
358358- $last['line'] = str_replace('o', 'x', $last['line']);
359359- $last['line'] = str_replace('^', 'X', $last['line']);
360360- $graph[] = $last;
361361- }
362362-363363- // Render into tags for the behavior.
364364-365365- foreach ($graph as $k => $meta) {
366366- $graph[$k] = javelin_tag(
367367- 'div',
368368- array(
369369- 'sigil' => 'commit-graph',
370370- 'meta' => $meta,
371371- ),
372372- '');
373373- }
374374-375375- Javelin::initBehavior(
376376- 'diffusion-commit-graph',
377377- array(
378378- 'count' => $count,
379379- ));
380380-381381- return $graph;
382223 }
383224384225}
···11+<?php
22+33+final class PHUIDiffGraphView extends Phobject {
44+55+ private $isHead = true;
66+ private $isTail = true;
77+88+ public function setIsHead($is_head) {
99+ $this->isHead = $is_head;
1010+ return $this;
1111+ }
1212+1313+ public function getIsHead() {
1414+ return $this->isHead;
1515+ }
1616+1717+ public function setIsTail($is_tail) {
1818+ $this->isTail = $is_tail;
1919+ return $this;
2020+ }
2121+2222+ public function getIsTail() {
2323+ return $this->isTail;
2424+ }
2525+2626+ public function renderGraph(array $parents) {
2727+ // This keeps our accumulated information about each line of the
2828+ // merge/branch graph.
2929+ $graph = array();
3030+3131+ // This holds the next commit we're looking for in each column of the
3232+ // graph.
3333+ $threads = array();
3434+3535+ // This is the largest number of columns any row has, i.e. the width of
3636+ // the graph.
3737+ $count = 0;
3838+3939+ foreach ($parents as $cursor => $parent_list) {
4040+ $joins = array();
4141+ $splits = array();
4242+4343+ // Look for some thread which has this commit as the next commit. If
4444+ // we find one, this commit goes on that thread. Otherwise, this commit
4545+ // goes on a new thread.
4646+4747+ $line = '';
4848+ $found = false;
4949+ $pos = count($threads);
5050+ for ($n = 0; $n < $count; $n++) {
5151+ if (empty($threads[$n])) {
5252+ $line .= ' ';
5353+ continue;
5454+ }
5555+5656+ if ($threads[$n] == $cursor) {
5757+ if ($found) {
5858+ $line .= ' ';
5959+ $joins[] = $n;
6060+ unset($threads[$n]);
6161+ } else {
6262+ $line .= 'o';
6363+ $found = true;
6464+ $pos = $n;
6565+ }
6666+ } else {
6767+6868+ // We render a "|" for any threads which have a commit that we haven't
6969+ // seen yet, this is later drawn as a vertical line.
7070+ $line .= '|';
7171+ }
7272+ }
7373+7474+ // If we didn't find the thread this commit goes on, start a new thread.
7575+ // We use "o" to mark the commit for the rendering engine, or "^" to
7676+ // indicate that there's nothing after it so the line from the commit
7777+ // upward should not be drawn.
7878+7979+ if (!$found) {
8080+ if ($this->getIsHead()) {
8181+ $line .= '^';
8282+ } else {
8383+ $line .= 'o';
8484+ foreach ($graph as $k => $meta) {
8585+ // Go back across all the lines we've already drawn and add a
8686+ // "|" to the end, since this is connected to some future commit
8787+ // we don't know about.
8888+ for ($jj = strlen($meta['line']); $jj <= $count; $jj++) {
8989+ $graph[$k]['line'] .= '|';
9090+ }
9191+ }
9292+ }
9393+ }
9494+9595+ // Update the next commit on this thread to the commit's first parent.
9696+ // This might have the effect of making a new thread.
9797+ $threads[$pos] = head($parent_list);
9898+9999+ // If we made a new thread, increase the thread count.
100100+ $count = max($pos + 1, $count);
101101+102102+ // Now, deal with splits (merges). I picked this terms opposite to the
103103+ // underlying repository term to confuse you.
104104+ foreach (array_slice($parent_list, 1) as $parent) {
105105+ $found = false;
106106+107107+ // Try to find the other parent(s) in our existing threads. If we find
108108+ // them, split to that thread.
109109+110110+ foreach ($threads as $idx => $thread_commit) {
111111+ if ($thread_commit == $parent) {
112112+ $found = true;
113113+ $splits[] = $idx;
114114+ }
115115+ }
116116+117117+ // If we didn't find the parent, we don't know about it yet. Find the
118118+ // first free thread and add it as the "next" commit in that thread.
119119+ // This might create a new thread.
120120+121121+ if (!$found) {
122122+ for ($n = 0; $n < $count; $n++) {
123123+ if (empty($threads[$n])) {
124124+ break;
125125+ }
126126+ }
127127+ $threads[$n] = $parent;
128128+ $splits[] = $n;
129129+ $count = max($n + 1, $count);
130130+ }
131131+ }
132132+133133+ $graph[] = array(
134134+ 'line' => $line,
135135+ 'split' => $splits,
136136+ 'join' => $joins,
137137+ );
138138+ }
139139+140140+ // If this is the last page in history, replace the "o" with an "x" so we
141141+ // do not draw a connecting line downward, and replace "^" with an "X" for
142142+ // repositories with exactly one commit.
143143+ if ($this->getIsTail() && $graph) {
144144+ $last = array_pop($graph);
145145+ $last['line'] = str_replace('o', 'x', $last['line']);
146146+ $last['line'] = str_replace('^', 'X', $last['line']);
147147+ $graph[] = $last;
148148+ }
149149+150150+ // Render into tags for the behavior.
151151+152152+ foreach ($graph as $k => $meta) {
153153+ $graph[$k] = javelin_tag(
154154+ 'div',
155155+ array(
156156+ 'sigil' => 'commit-graph',
157157+ 'meta' => $meta,
158158+ ),
159159+ '');
160160+ }
161161+162162+ Javelin::initBehavior(
163163+ 'diffusion-commit-graph',
164164+ array(
165165+ 'count' => $count,
166166+ ));
167167+168168+ return $graph;
169169+ }
170170+171171+}
+18-1
src/view/phui/PHUITabView.php
···66 private $key;
77 private $keyLocked;
88 private $contentID;
99+ private $color;
9101011 public function setKey($key) {
1112 if ($this->keyLocked) {
···5859 return $this->contentID;
5960 }
60616262+ public function setColor($color) {
6363+ $this->color = $color;
6464+ return $this;
6565+ }
6666+6767+ public function getColor() {
6868+ return $this->color;
6969+ }
7070+6171 public function newMenuItem() {
6262- return id(new PHUIListItemView())
7272+ $item = id(new PHUIListItemView())
6373 ->setName($this->getName())
6474 ->setKey($this->getKey())
6575 ->setType(PHUIListItemView::TYPE_LINK)
···6979 array(
7080 'tabKey' => $this->getKey(),
7181 ));
8282+8383+ $color = $this->getColor();
8484+ if ($color !== null) {
8585+ $item->setStatusColor($color);
8686+ }
8787+8888+ return $item;
7289 }
73907491}