[PATCH] Change branches to sort 'active' branches first, and add an option to show only active branches

Eric Hopper hopper at omnifarious.org
Wed Jun 6 10:14:00 CDT 2007


On 6/6/07, Thomas Arendsen Hein <thomas at intevation.de> wrote:
>
> > +    def branch_cmp(b1, b2):
> > +        # Make sure that branches who's tip is an unmerged head show
> > +        # up before all other branches.
> > +        b1_head = b1[1] in heads
> > +        b2_head = b2[1] in heads
> > +        if b1_head and not b2_head:
> > +            return -1
> > +        if b2_head and not b1_head:
> > +            return 1
> > +        return -cmp(b1, b2) # Descending by rev #
> > +    l.sort(branch_cmp)
>
> Maybe it is better to add a boolean (is it a head) to each tuple as
> the first element and then just use l.sort(); l.reverse()


That might be.  It would save an extra dict lookup.  The first thing that
was done with negating the revision number then negating it again on display
was evil.

Should be indented two more spaces.


Oops.

> -foo                            5:5f8fb06e083e
> > +foo                            5:5f8fb06e083e *HEAD*
> >  default                        3:bf1bc2f45e83
> >  bar                            2:67ec16bde7f1
>
> Looks like foo is no something dangerous: beware, it's a *HEAD*! :)
>
> Suggestions:
> - add "(inactive)" to the non-heads
> - write " The following branches are inactive:\n" before showing
>   the first inactive branch head.


I want something that renders the list still susceptible to the wiles of
awk.  So I will choose the "(inactive)" option.  You're right that "*HEAD*"
is a little too scary looking.

Both suggestions show no unneeded things with 'hg branches -a'.


Thanks for the suggestions,
-- 
Eric Hopper -- http://www.omnifarious.org/~hopper/
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://selenic.com/pipermail/mercurial-devel/attachments/20070606/22d55c7c/attachment.htm 


More information about the Mercurial-devel mailing list