/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar

« back to all changes in this revision

Viewing changes to breezy/plugins/stats/cmds.py

  • Committer: Jelmer Vernooij
  • Date: 2017-06-10 00:06:46 UTC
  • mfrom: (6673 work)
  • mto: This revision was merged to the branch mainline in revision 6675.
  • Revision ID: jelmer@jelmer.uk-20170610000646-xj6jh277lo4xuo10
Merge trunk.

Show diffs side-by-side

added added

removed removed

Lines of Context:
60
60
            info[1][email] = info[1].setdefault(email, 0) + 1
61
61
            info[2][username] = info[2].setdefault(username, 0) + 1
62
62
    res = [(len(revs), revs, emails, fnames)
63
 
           for revs, emails, fnames in committer_to_info.itervalues()]
 
63
           for revs, emails, fnames in committer_to_info.values()]
64
64
    res.sort(reverse=True)
65
65
    return res
66
66
 
89
89
                old_email_id = email_to_id[old_email]
90
90
                assert old_email_id in (old_id, new_id)
91
91
                email_to_id[old_email] = cur_id
92
 
    for email, usernames in email_users.iteritems():
 
92
    for email, usernames in email_users.items():
93
93
        assert email not in email_to_id
94
94
        if not email:
95
95
            # We use a different algorithm for usernames that have no email
131
131
                    collapse_ids(user_id, cur_id, id_combos)
132
132
            username_to_id[low_user] = cur_id
133
133
    combo_to_best_combo = {}
134
 
    for cur_id, combos in id_to_combos.iteritems():
 
134
    for cur_id, combos in id_to_combos.items():
135
135
        best_combo = sorted(combos,
136
136
                            key=lambda x:combo_count[x],
137
137
                            reverse=True)[0]
206
206
    for count, revs, emails, fullnames in info:
207
207
        # Get the most common email name
208
208
        sorted_emails = sorted(((count, email)
209
 
                               for email,count in emails.iteritems()),
 
209
                               for email, count in emails.items()),
210
210
                               reverse=True)
211
211
        sorted_fullnames = sorted(((count, fullname)
212
 
                                  for fullname,count in fullnames.iteritems()),
 
212
                                  for fullname, count in fullnames.items()),
213
213
                                  reverse=True)
214
214
        if sorted_fullnames[0][1] == '' and sorted_emails[0][1] == '':
215
215
            to_file.write('%4d %s\n'
237
237
        if gather_class_stats is not None:
238
238
            to_file.write('     Contributions:\n')
239
239
            classes, total = gather_class_stats(revs)
240
 
            for name,count in sorted(classes.items(), lambda x,y: cmp((x[1], x[0]), (y[1], y[0]))):
 
240
            for name, count in sorted(classes.items(), key=classify_key):
241
241
                if name is None:
242
242
                    name = "Unknown"
243
243
                to_file.write("     %4.0f%% %s\n" % ((float(count) / total) * 100.0, name))
342
342
    return ret, total
343
343
 
344
344
 
 
345
def classify_key(item):
 
346
    """Sort key for item of (author, count) from classify_delta."""
 
347
    return -item[1], item[0]
 
348
 
 
349
 
345
350
def display_credits(credits, to_file):
346
351
    (coders, documenters, artists, translators) = credits
347
352
    def print_section(name, lst):
392
397
    finally:
393
398
        repository.unlock()
394
399
    def sort_class(name):
395
 
        return map(lambda (x,y): x,
396
 
               sorted(ret[name].items(), lambda x,y: cmp((x[1], x[0]), (y[1], y[0])), reverse=True))
 
400
        return [author
 
401
            for author, _  in sorted(ret[name].items(), key=classify_key)]
397
402
    return (sort_class("code"), sort_class("documentation"), sort_class("art"), sort_class("translation"))
398
403
 
399
404