Merge lp://staging/~jelmer/trac-launchpad-migrator/merge-1 into lp://staging/trac-launchpad-migrator

Proposed by Jelmer Vernooij
Status: Merged
Approved by: Graham Binns
Approved revision: not available
Merge reported by: Jelmer Vernooij
Merged at revision: not available
Proposed branch: lp://staging/~jelmer/trac-launchpad-migrator/merge-1
Merge into: lp://staging/trac-launchpad-migrator
Diff against target: None lines
To merge this branch: bzr merge lp://staging/~jelmer/trac-launchpad-migrator/merge-1
Reviewer Review Type Date Requested Status
Graham Binns (community) Approve
Review via email: mp+7552@code.staging.launchpad.net
To post a comment you must log in.
Revision history for this message
Jelmer Vernooij (jelmer) wrote :

Hi Graham,

The attached patch makes trac-launchpad-migrator create an email
address based on the hostname of the trac instance and the username of
a person if there was no email address stored in trac.

The hostname has to be hardcoded in migrate.py at the moment.

Cheers,

Jelmer

Revision history for this message
Graham Binns (gmb) wrote :

Awesome stuff! This fixes bug 388392; I'll mark it as such when I merge
it. Thanks for this.

 review approve
 status approved

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'migrate.py'
2--- migrate.py 2009-06-17 09:28:40 +0000
3+++ migrate.py 2009-06-17 13:35:59 +0000
4@@ -24,6 +24,11 @@
5 sys.exit()
6
7 KNOWN_USERS = {}
8+# This can be set to a hostname that will be used to create
9+# email addresses from trac users that only have a username set but not
10+# an email address. It should probably be set to the mailname of the
11+# system that was running the trac instance.
12+TRAC_HOSTNAME = None
13
14 # If you have a group of users whose details you already know, include
15 # them in the KNOWN_USERS dict in the following format to save time and
16@@ -294,6 +299,15 @@
17 return text
18
19
20+def extract_person_email(trac_person):
21+ email = trac_person['email']
22+ if email:
23+ return email
24+ if trac_person['username'] and TRAC_HOSTNAME:
25+ return "%s@%s" % (trac_person['username'], TRAC_HOSTNAME)
26+ return None
27+
28+
29 def create_bug(db, trac_ticket):
30 bug_id = trac_ticket['id']
31 bug_type = trac_ticket['type']
32@@ -307,7 +321,7 @@
33
34 trac_reporter = db.get_user(reporter)
35 #reporter_email = trac_reporter.get('email', 'foo@bar.com')
36- reporter_email = trac_reporter['email']
37+ reporter_email = extract_person_email(trac_reporter)
38 if not reporter_email:
39 print '[ticket %s] pb with reporter %s' % (bug_id, reporter)
40 return None
41@@ -324,7 +338,7 @@
42 owner = owners.split(',')[0]
43 if owner:
44 trac_owner = db.get_user(owner)
45- owner_email = trac_owner['email']
46+ owner_email = extract_person_email(trac_owner)
47 if not owner_email:
48 print '[ticket %s] pb with owner %s' % (bug_id,
49 owner)
50@@ -340,7 +354,7 @@
51 for username in subscribers.split(','):
52 username = username.strip()
53 trac_person = db.get_user(username)
54- person_email = trac_person['email']
55+ person_email = extract_person_email(trac_person)
56 if not person_email:
57 print '[ticket %s] pb with cc %s' % (bug_id,
58 username)
59@@ -399,7 +413,7 @@
60
61 reporter = trac_comment['author']
62 trac_reporter = db.get_user(reporter)
63- reporter_email = trac_reporter['email']
64+ reporter_email = extract_person_email(trac_reporter)
65 if not reporter_email:
66 print '[comment %s] pb with comment reporter %s' % (1,
67 reporter)

Subscribers

People subscribed via source and target branches

to all changes: