Merge lp:~jelmer/bzr-pqm/lp-land-supports-child_pqm_email into lp:bzr-pqm

Proposed by Jelmer Vernooij
Status: Merged
Merged at revision: 82
Proposed branch: lp:~jelmer/bzr-pqm/lp-land-supports-child_pqm_email
Merge into: lp:bzr-pqm
Diff against target: 78 lines (+23/-12)
2 files modified
lpland.py (+4/-4)
pqm_submit.py (+19/-8)
To merge this branch: bzr merge lp:~jelmer/bzr-pqm/lp-land-supports-child_pqm_email
Reviewer Review Type Date Requested Status
Martin Pool (community) Approve
Review via email: mp+86111@code.launchpad.net

Description of the change

Factor out the code that determines the e-mail address of PQM out of "bzr pqm-subnmit", and use it in "bzr lp-land" too.

This fixes the support in lp-land for looking at the "child_pqm_email" configuration option set in the submission branch.

To post a comment you must log in.
Revision history for this message
Martin Pool (mbp) wrote :

thanks

this makes me wonder if, separately, the config infrastructure should
support the general "if not set raise an error of class e", perhaps
including the context where it was looked up.

  vote approve

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'lpland.py'
2--- lpland.py 2011-02-17 18:59:44 +0000
3+++ lpland.py 2011-12-16 20:29:36 +0000
4@@ -207,9 +207,6 @@
5 self.incremental = incremental
6 self.rollback = rollback
7 self.config = self.branch.get_config()
8- self.mail_to = self.config.get_user_option('pqm_email')
9- if not self.mail_to:
10- raise pqm_submit.NoPQMSubmissionAddress(branch)
11 self.mail_from = self.config.get_user_option('pqm_user_email')
12 if not self.mail_from:
13 self.mail_from = self.config.username()
14@@ -250,7 +247,10 @@
15 submission = self.submission(mp)
16 self.check_submission(submission)
17 self.set_message(submission, mp)
18- email = submission.to_email(self.mail_from, self.mail_to)
19+ mail_to = pqm_submit.pqm_email(self.config, mp.target_branch)
20+ if not mail_to:
21+ raise pqm_submit.NoPQMSubmissionAddress(self.branch)
22+ email = submission.to_email(self.mail_from, mail_to)
23 if outf is not None:
24 outf.write(email.as_string())
25 else:
26
27=== modified file 'pqm_submit.py'
28--- pqm_submit.py 2011-12-15 01:33:31 +0000
29+++ pqm_submit.py 2011-12-16 20:29:36 +0000
30@@ -173,7 +173,7 @@
31 unsigned_text = ''.join(self.to_lines())
32 unsigned_text = unsigned_text.encode('ascii') #URLs should be ascii
33
34- if bzrlib_version < (2, 5):
35+ if bzrlib_version < (2, 5, 0, 'dev', 5):
36 if self.source_branch:
37 config = self.source_branch.get_config()
38 else:
39@@ -227,6 +227,22 @@
40 return None
41
42
43+def pqm_email(local_config, submit_location):
44+ """Determine the PQM email address.
45+
46+ :param local_config: Config object for local branch
47+ :param submit_location: Location of submit branch
48+ """
49+ mail_to = local_config.get_user_option('pqm_email')
50+ if not mail_to:
51+ submit_branch = Branch.open(submit_location)
52+ submit_branch_config = submit_branch.get_config()
53+ mail_to = submit_branch_config.get_user_option('child_pqm_email')
54+ if mail_to is None:
55+ return None
56+ return mail_to.encode('utf8') # same here
57+
58+
59 def submit(branch, message, dry_run=False, public_location=None,
60 submit_location=None, tree=None, ignore_local=False):
61 """Submit the given branch to the pqm."""
62@@ -247,14 +263,9 @@
63 if not mail_from:
64 mail_from = config.username()
65 mail_from = mail_from.encode('utf8') # Make sure this isn't unicode
66- mail_to = config.get_user_option('pqm_email')
67+ mail_to = pqm_email(config, submit_location)
68 if not mail_to:
69- submit_branch = Branch.open(submit_location)
70- submit_branch_config = submit_branch.get_config()
71- mail_to = submit_branch_config.get_user_option('child_pqm_email')
72- if not mail_to:
73- raise NoPQMSubmissionAddress(branch)
74- mail_to = mail_to.encode('utf8') # same here
75+ raise NoPQMSubmissionAddress(branch)
76
77 if not ignore_local:
78 submission.check_tree()

Subscribers

People subscribed via source and target branches

to all changes:
to status/vote changes: