~rockstar/bzr-stats/import-branch-support

« back to all changes in this revision

Viewing changes to __init__.py

  • Committer: Paul Hummer
  • Date: 2008-07-26 22:17:02 UTC
  • Revision ID: paul.hummer@canonical.com-20080726221702-wr73kqqapcj448kr
Revisions with missing emails are no longer all attributed to the same person

Show diffs side-by-side

added added

removed removed

Lines of Context:
27
27
        fullname = config.parse_username(committer)[0]
28
28
        counts.setdefault(fullname, 0)
29
29
        counts[fullname] += 1
30
 
    return sorted(((count, name) for name,count in counts.iteritems()), reverse=True)
 
30
    return sorted(((count, name) for name,count in counts.iteritems()),
 
31
        reverse=True)
31
32
 
32
33
 
33
34
def collapse_by_person(committers):
86
87
        revisions = a_repo.get_revisions(revids)
87
88
        for count, rev in enumerate(revisions):
88
89
            pb.update('checking', count, len(revids))
89
 
            email = config.parse_username(rev.get_apparent_author())[1]
 
90
            username = config.parse_username(rev.get_apparent_author())
 
91
            if username[1] == '':
 
92
                email = username[0]
 
93
            else:
 
94
                email = username[1]
90
95
            committers.setdefault(email, []).append(rev)
91
96
    finally:
92
97
        pb.finished()
93
 
    
 
98
 
94
99
    return committers
95
100
 
96
101
 
112
117
 
113
118
def get_diff_info(a_repo, start_rev, end_rev):
114
119
    """Get only the info for new revisions between the two revisions
115
 
    
 
120
 
116
121
    This lets us figure out what has actually changed between 2 revisions.
117
122
    """
118
123
    pb = ui.ui_factory.nested_progress_bar()
153
158
        sorted_fullnames = sorted(((count, fullname)
154
159
                                  for fullname,count in fullnames.iteritems()),
155
160
                                  reverse=True)
156
 
        to_file.write('%4d %s <%s>\n'
157
 
                      % (count, sorted_fullnames[0][1],
158
 
                         sorted_emails[0][1]))
 
161
        # There is a chanch sometimes with svn imports that the full name and
 
162
        # email can BOTH be blank.
 
163
        if sorted_fullnames[0][1] == '':
 
164
            to_file.write('%4d %s\n'
 
165
                          % (count, 'Unknown'))
 
166
        else:
 
167
            to_file.write('%4d %s <%s>\n'
 
168
                          % (count, sorted_fullnames[0][1],
 
169
                             sorted_emails[0][1]))
159
170
        if len(sorted_fullnames) > 1:
160
171
            print '     Other names:'
161
172
            for count, fname in sorted_fullnames[1:]: