Sort branches by date

Asked by kgraefe on 2012-03-27

I am serving a directory containing several Bazaar branches using serve-branches.

Those branches are sorted by name on the main page. Is it possible to sort them by date (latest first)?

Question information

Language:
English Edit question
Status:
Solved
For:
loggerhead Edit question
Assignee:
No assignee Edit question
Solved by:
kgraefe
Solved:
2012-03-28
Last query:
2012-03-28
Last reply:
2012-03-27
Jelmer Vernooij (jelmer) said : #1

Hi,

Am 27/03/12 23:30, schrieb kgraefe:
> New question #191875 on loggerhead:
> https://answers.launchpad.net/loggerhead/+question/191875
>
> I am serving a directory containing several Bazaar branches using serve-branches.
>
> Those branches are sorted by name on the main page. Is it possible to sort them by date (latest first)?
I don't think this is possible at the moment.

Cheers,

Jelmer

kgraefe (konradgraefe) said : #2

Thank you, so this is my patch [1] and the result [2].

However it may have two caveats:
- as it's the first time I did Python the code quality may be poor.
- it's not implemented as optional.

[1] http://pastebin.com/PMaEuM5F
[2] http://i.imgur.com/DUiSG.png

Martin Pool (mbp) said : #3

Hi, thanks very much for sending us a patch!

On Wed, Mar 28, 2012 at 6:05 PM, kgraefe
<email address hidden> wrote:
> Question #191875 on loggerhead changed:
> https://answers.launchpad.net/loggerhead/+question/191875
>
>    Status: Answered => Solved
>
> kgraefe confirmed that the question is solved:
> Thank you, so this is my patch [1] and the result [2].
>
> However it may have two caveats:
> - as it's the first time I did Python the code quality may be poor.
> - it's not implemented as optional.

Right, I do think it ought to be optional, which means probably adding
a URL parameter or path segment for ordering, and a link to change it.

I think the code quality is OK except that it's doing an insertion
sort, which may get expensive on big directories. I would suggest you
split it out into a new function and have a read of
<http://wiki.python.org/moin/HowTo/Sorting>.

Also, you might like to make a new branch of Loggerhead, push it to
lp, and then propose merging it into lp:loggerhead, so we can have the
conversation on that proposal.