[MERGE] Diff now emits files in alphabetical order

Andrew Bennetts andrew at canonical.com
Tue Dec 18 05:37:06 GMT 2007


Aaron Bentley wrote:
[...]
> > Ideally, for bzr development at least, I'd like to see diff emit files in this
> > order:
> > 
> >   - doc/*
> >   - bzrlib/tests/*
> >   - everything else
> 
> Care to define that sort order? ;-)

Sure, let's take away any ambiguity:

    def andrew_cmp(a, b):
         if a.startswith('doc/'): return -1
         if b.startswith('doc/'): return 1
         if a.startswith('bzrlib/tests/'): return -1
         if b.startswith('bzrlib/tests/'): return 1
         return cmp(a, b)
    
    filenames_list.sort(cmp=andrew_cmp)

(I almost wouldn't care if the final line of that function were “return 0”...)

> > Of course, this change isn't really any better or worse in that respect
> > (although I guess it will tend to put doc/ first),
> 
> It should put bzrlib first.

Oh yeah.  Duh.  I have no idea what I was thinking there :)

Feel free to point and laugh now.

> > so personally I'm neutral on
> > changing from grouped by changed kind to alphabetical by name.  I guess there's
> > been some user interest in alphabetical ordering?
> 
> Well, not a groundswell, by any means.  I also think that using
> iter_changes is better because simplifies the code and gives you access
> to better-quality change data.

Fair enough.  If you think it's a worthwhile change I certainly don't object,
I'm just sharing my thoughts on the colour of the bike-shed.

-Andrew.




More information about the bazaar mailing list