/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: 2018-11-16 23:19:12 UTC
  • mfrom: (7180 work)
  • mto: This revision was merged to the branch mainline in revision 7294.
  • Revision ID: jelmer@jelmer.uk-20181116231912-e043vpq22bdkxa6q
Merge trunk.

Show diffs side-by-side

added added

removed removed

Lines of Context:
95
95
            # email
96
96
            for user in usernames:
97
97
                if not user:
98
 
                    continue # The mysterious ('', '') user
 
98
                    continue  # The mysterious ('', '') user
99
99
                # When mapping, use case-insensitive names
100
100
                low_user = user.lower()
101
101
                user_id = username_to_id.get(low_user)
131
131
    combo_to_best_combo = {}
132
132
    for cur_id, combos in id_to_combos.items():
133
133
        best_combo = sorted(combos,
134
 
                            key=lambda x:combo_count[x],
 
134
                            key=lambda x: combo_count[x],
135
135
                            reverse=True)[0]
136
136
        for combo in combos:
137
137
            combo_to_best_combo[combo] = best_combo
141
141
def get_revisions_and_committers(a_repo, revids):
142
142
    """Get the Revision information, and the best-match for committer."""
143
143
 
144
 
    email_users = {} # user@email.com => User Name
 
144
    email_users = {}  # user@email.com => User Name
145
145
    combo_count = {}
146
146
    with ui.ui_factory.nested_progress_bar() as pb:
147
147
        trace.note('getting revisions')
167
167
        ancestry = [
168
168
            r for (r, ps) in graph.iter_ancestry([revision])
169
169
            if ps is not None and r != NULL_REVISION]
170
 
        revs, canonical_committer = get_revisions_and_committers(a_repo, ancestry)
 
170
        revs, canonical_committer = get_revisions_and_committers(
 
171
            a_repo, ancestry)
171
172
 
172
173
    return collapse_by_person(revs, canonical_committer)
173
174
 
181
182
        graph = a_repo.get_graph()
182
183
        trace.note('getting ancestry diff')
183
184
        ancestry = graph.find_difference(start_rev, end_rev)[1]
184
 
        revs, canonical_committer = get_revisions_and_committers(a_repo, ancestry)
 
185
        revs, canonical_committer = get_revisions_and_committers(
 
186
            a_repo, ancestry)
185
187
 
186
188
    return collapse_by_person(revs, canonical_committer)
187
189
 
192
194
    for count, revs, emails, fullnames in info:
193
195
        # Get the most common email name
194
196
        sorted_emails = sorted(((count, email)
195
 
                               for email, count in emails.items()),
 
197
                                for email, count in emails.items()),
196
198
                               reverse=True)
197
199
        sorted_fullnames = sorted(((count, fullname)
198
 
                                  for fullname, count in fullnames.items()),
 
200
                                   for fullname, count in fullnames.items()),
199
201
                                  reverse=True)
200
202
        if sorted_fullnames[0][1] == '' and sorted_emails[0][1] == '':
201
203
            to_file.write('%4d %s\n'
226
228
            for name, count in sorted(classes.items(), key=classify_key):
227
229
                if name is None:
228
230
                    name = "Unknown"
229
 
                to_file.write("     %4.0f%% %s\n" % ((float(count) / total) * 100.0, name))
 
231
                to_file.write("     %4.0f%% %s\n" %
 
232
                              ((float(count) / total) * 100.0, name))
230
233
 
231
234
 
232
235
class cmd_committer_statistics(commands.Command):
234
237
 
235
238
    aliases = ['stats', 'committer-stats']
236
239
    takes_args = ['location?']
237
 
    takes_options = ['revision', 
238
 
            option.Option('show-class', help="Show the class of contributions.")]
 
240
    takes_options = ['revision',
 
241
                     option.Option('show-class', help="Show the class of contributions.")]
239
242
 
240
243
    encoding_type = 'replace'
241
244
 
323
326
 
324
327
def display_credits(credits, to_file):
325
328
    (coders, documenters, artists, translators) = credits
 
329
 
326
330
    def print_section(name, lst):
327
331
        if len(lst) == 0:
328
332
            return
364
368
                        if not author in ret[c]:
365
369
                            ret[c][author] = 0
366
370
                        ret[c][author] += 1
 
371
 
367
372
    def sort_class(name):
368
373
        return [author
369
 
            for author, _  in sorted(ret[name].items(), key=classify_key)]
 
374
                for author, _ in sorted(ret[name].items(), key=classify_key)]
370
375
    return (sort_class("code"), sort_class("documentation"), sort_class("art"), sort_class("translation"))
371
376
 
372
377