On 6/6/07, <b class="gmail_sendername">Thomas Arendsen Hein</b> &lt;<a href="mailto:thomas@intevation.de">thomas@intevation.de</a>&gt; wrote:<div><span class="gmail_quote"></span><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
&gt; +&nbsp;&nbsp;&nbsp;&nbsp;def branch_cmp(b1, b2):<br>&gt; +&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;# Make sure that branches who&#39;s tip is an unmerged head show<br>&gt; +&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;# up before all other branches.<br>&gt; +&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;b1_head = b1[1] in heads<br>&gt; +&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;b2_head = b2[1] in heads
<br>&gt; +&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if b1_head and not b2_head:<br>&gt; +&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;return -1<br>&gt; +&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if b2_head and not b1_head:<br>&gt; +&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;return 1<br>&gt; +&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;return -cmp(b1, b2) # Descending by rev #<br>&gt; +&nbsp;&nbsp;&nbsp;&nbsp;
l.sort(branch_cmp)<br><br>Maybe it is better to add a boolean (is it a head) to each tuple as<br>the first element and then just use l.sort(); l.reverse()</blockquote><div><br>That might be.&nbsp; It would save an extra dict lookup.&nbsp; The first thing that was done with negating the revision number then negating it again on display was evil.
<br><br></div><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">Should be indented two more spaces.</blockquote><div><br>Oops.<br></div><br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
&gt; -foo&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;5:5f8fb06e083e<br>&gt; +foo&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;5:5f8fb06e083e *HEAD*<br>&gt;&nbsp;&nbsp;default&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;3:bf1bc2f45e83<br>&gt;&nbsp;&nbsp;bar&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;2:67ec16bde7f1
<br><br>Looks like foo is no something dangerous: beware, it&#39;s a *HEAD*! :)<br><br>Suggestions:<br>- add &quot;(inactive)&quot; to the non-heads<br>- write &quot; The following branches are inactive:\n&quot; before showing
<br>&nbsp;&nbsp;the first inactive branch head.</blockquote><div><br>I want something that renders the list still susceptible to the wiles of awk.&nbsp; So I will choose the &quot;(inactive)&quot; option.&nbsp; You&#39;re right that &quot;*HEAD*&quot; is a little too scary looking.
<br><br></div><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">Both suggestions show no unneeded things with &#39;hg branches -a&#39;.</blockquote>
<div><br>Thanks for the suggestions,<br></div></div>-- <br>Eric Hopper -- <a href="http://www.omnifarious.org/~hopper/">http://www.omnifarious.org/~hopper/</a><br>