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

Thomas Arendsen Hein thomas at intevation.de
Wed Jun 6 02:45:27 CDT 2007


* Eric Hopper <hopper at omnifarious.org> [20070606 05:53]:
> # HG changeset patch
> # User Eric Hopper <hopper at omnifarious.org>
> # Date 1181101122 25200
> # Node ID 177fc31f3f2c502387eeb6ece6a6dd534d010a7e
> # Parent  fd53dbf6fb2bcc9c94b76f336b8b175aefb453d0
> Change branches to sort 'active' branches first, and add an option to show only active branches.
> 
> diff --git a/mercurial/commands.py b/mercurial/commands.py
> --- a/mercurial/commands.py
> +++ b/mercurial/commands.py
> +    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()

> +            ishead = ((not active) and (n in heads) and " *HEAD*") or ''

And this (is it a head) can already be reused here :)

I think the "*HEAD*" is too distracting

> -    "branches": (branches, [], _('hg branches')),
> +    "branches": (branches,
> +                 [('a', 'active', False,
> +                 _("show only branches that have unmerged heads"))],

Should be indented two more spaces.

> -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.

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

Thomas

-- 
thomas at intevation.de - http://intevation.de/~thomas/ - OpenPGP key: 0x5816791A
Intevation GmbH, Osnabrueck - Register: Amtsgericht Osnabrueck, HR B 18998
Geschaeftsfuehrer: Frank Koormann, Bernhard Reiter, Dr. Jan-Oliver Wagner
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: not available
Url : http://selenic.com/pipermail/mercurial-devel/attachments/20070606/8f39291d/attachment.pgp 


More information about the Mercurial-devel mailing list