/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 __init__.py

  • Committer: John Arbash Meinel
  • Date: 2010-01-15 21:32:57 UTC
  • mto: (0.140.32 trunk)
  • mto: This revision was merged to the branch mainline in revision 6646.
  • Revision ID: john@arbash-meinel.com-20100115213257-jupa04qkt5fdkm82
Handle the case where we have a user but no email.

This now seems to match properly for all the cases involved.
A UserName but no email will match the same username, an email with
no UserName will match the same email. But the empty entries never
add a match to similar named entries.

Show diffs side-by-side

added added

removed removed

Lines of Context:
87
87
                email_to_id[old_email] = cur_id
88
88
    for email, usernames in email_users.iteritems():
89
89
        assert email not in email_to_id
 
90
        if not email:
 
91
            # We use a different algorithm for usernames that have no email
 
92
            # address, we just try to match by username, and not at all by
 
93
            # email
 
94
            for user in usernames:
 
95
                if not user:
 
96
                    continue # The mysterious ('', '') user
 
97
                user_id = username_to_id.get(user)
 
98
                if user_id is None:
 
99
                    id_counter += 1
 
100
                    user_id = id_counter
 
101
                    username_to_id[user] = user_id
 
102
                    id_to_combos[user_id] = id_combos = set()
 
103
                else:
 
104
                    id_combos = id_combos[user_id]
 
105
                id_combos.add((user, email))
 
106
            continue
 
107
 
90
108
        id_counter += 1
91
109
        cur_id = id_counter
92
110
        id_to_combos[cur_id] = id_combos = set()
93
 
        if email:
94
 
            email_to_id[email] = cur_id
 
111
        email_to_id[email] = cur_id
95
112
 
96
113
        for user in usernames:
97
114
            combo = (user, email)
98
115
            id_combos.add(combo)
99
 
            if not user or not email:
100
 
                # We don't match on empty usernames and empty emails
 
116
            if not user:
 
117
                # We don't match on empty usernames
101
118
                continue
102
119
            user_id = username_to_id.get(user)
103
120
            if user_id is not None:
186
203
        sorted_fullnames = sorted(((count, fullname)
187
204
                                  for fullname,count in fullnames.iteritems()),
188
205
                                  reverse=True)
189
 
        if sorted_fullnames[0][1] == '':
 
206
        if sorted_fullnames[0][1] == '' and sorted_emails[0][1] == '':
190
207
            to_file.write('%4d %s\n'
191
208
                          % (count, 'Unknown'))
192
209
        else: