Merge lp:~viktor-nagy/bzr-email/tip-hook into lp:bzr-email

Proposed by Jelmer Vernooij
Status: Work in progress
Proposed branch: lp:~viktor-nagy/bzr-email/tip-hook
Merge into: lp:bzr-email
Diff against target: 75 lines (+23/-0) (has conflicts)
2 files modified
__init__.py (+15/-0)
smtp_connection.py (+8/-0)
Text conflict in __init__.py
Text conflict in smtp_connection.py
To merge this branch: bzr merge lp:~viktor-nagy/bzr-email/tip-hook
Reviewer Review Type Date Requested Status
John A Meinel Needs Fixing
Jelmer Vernooij (community) code Needs Fixing
Review via email: mp+50238@code.launchpad.net

This proposal supersedes a proposal from 2008-08-18.

To post a comment you must log in.
Revision history for this message
Jelmer Vernooij (jelmer) wrote :

Hi,

I'm sorry it's taken so long before we had a chance to look at this branch. Unfortunately it now has conflicts with trunk. If you still care about getting this functionality in, is there any chance you can resolve them and resubmit? Please don't hesitate to ask us if we don't follow up to a MP.

review: Needs Fixing (code)
Revision history for this message
John A Meinel (jameinel) wrote :

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On 2/17/2011 4:01 PM, Jelmer Vernooij wrote:
> Jelmer Vernooij has proposed merging lp:~viktor-nagy/bzr-email/tip-hook into lp:bzr-email.
>
> Requested reviews:
> Bazaar Developers (bzr)
>
> For more details, see:
> https://code.launchpad.net/~viktor-nagy/bzr-email/tip-hook/+merge/50238

This is conflicting with trunk after Jelmer's earlier update.

The way it is written it will default to smtp_use_tls = False, I would
rather default to True, but a user can disable it with an explicit
setting. (because get() defaults to returning None which evaluates to
False.)

I think just adding

use_tls = config.get_user_option('smtp_use_tls')
if use_tls is None:
  use_tls = True

...

On the other hand, isn't the connection side of things handled by bzr
code now? At least, I thought bzr-email was using bzrlib.smtp_connection
now. So that code should be pulled into bzr core.

I also don't fully understand what this is for:
+def tip_change_hook(params):
+ '''
+ This is the post_change_branch_tip commit hook that runs on a smart
server after the branch's tip has changed.
+ '''
+ from bzrlib.branch import BzrBranch6
+ if not isinstance(params.branch, BzrBranch6):
+ raise errors.UpgradeRequired(params.branch.base)
+ _emailer.EmailSender(params.branch, params.new_revid,
params.branch.get_config(),
+ local_branch=None).send_maybe()
+

Why do you have to have BzrBranch6 or better? Certainly that sounds like
something the user wanted to enforce, but should not be something in
bzr-email itself.)

 review: needsfixing

John
=:->

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (Cygwin)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iEYEARECAAYFAk1dnoMACgkQJdeBCYSNAAOD7wCePJk/Qk40OwoaSMcmTgEN9Xdu
/GoAoKPWkL91NlhA+wXlETOi4aNcKdEi
=M3nm
-----END PGP SIGNATURE-----

review: Needs Fixing

Unmerged revisions

38. By ViktorNagy

Change the name for the post change branch tip hook from tip_commit to
tip_change

37. By ViktorNagy

* added post_change_branch_tip hook
* adds a new config option smtp_use_ttls = True | False, and corrects
the statttls() negotiation

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file '__init__.py'
--- __init__.py 2010-10-09 23:15:45 +0000
+++ __init__.py 2011-02-17 22:01:52 +0000
@@ -79,6 +79,7 @@
79# lazy_import emailer so that it doesn't get loaded if it isn't used79# lazy_import emailer so that it doesn't get loaded if it isn't used
80lazy_import(globals(), """\80lazy_import(globals(), """\
81from bzrlib.plugins.email import emailer as _emailer81from bzrlib.plugins.email import emailer as _emailer
82from bzrlib.branch import BzrBranch6
82""")83""")
8384
8485
@@ -94,6 +95,16 @@
94 _emailer.EmailSender(master, new_revid, master.get_config(),95 _emailer.EmailSender(master, new_revid, master.get_config(),
95 local_branch=local).send_maybe()96 local_branch=local).send_maybe()
9697
98def tip_change_hook(params):
99 '''
100 This is the post_change_branch_tip commit hook that runs on a smart server after the branch's tip has changed.
101 '''
102 from bzrlib.branch import BzrBranch6
103 if not isinstance(params.branch, BzrBranch6):
104 raise errors.UpgradeRequired(params.branch.base)
105 _emailer.EmailSender(params.branch, params.new_revid, params.branch.get_config(),
106 local_branch=None).send_maybe()
107
97108
98def branch_post_change_hook(params):109def branch_post_change_hook(params):
99 """This is the post_change_branch_tip hook."""110 """This is the post_change_branch_tip hook."""
@@ -107,9 +118,13 @@
107 install_named_hook = getattr(Branch.hooks, 'install_named_hook', None)118 install_named_hook = getattr(Branch.hooks, 'install_named_hook', None)
108 if install_named_hook is not None:119 if install_named_hook is not None:
109 install_named_hook('post_commit', branch_commit_hook, 'bzr-email')120 install_named_hook('post_commit', branch_commit_hook, 'bzr-email')
121<<<<<<< TREE
110 if 'post_change_branch_tip' in Branch.hooks:122 if 'post_change_branch_tip' in Branch.hooks:
111 install_named_hook('post_change_branch_tip',123 install_named_hook('post_change_branch_tip',
112 branch_post_change_hook, 'bzr-email')124 branch_post_change_hook, 'bzr-email')
125=======
126 install_named_hook('post_change_branch_tip', tip_change_hook, 'bzr-email-on-tip')
127>>>>>>> MERGE-SOURCE
113 else:128 else:
114 Branch.hooks.install_hook('post_commit', branch_commit_hook)129 Branch.hooks.install_hook('post_commit', branch_commit_hook)
115 if getattr(Branch.hooks, 'name_hook', None) is not None:130 if getattr(Branch.hooks, 'name_hook', None) is not None:
116131
=== modified file 'smtp_connection.py'
--- smtp_connection.py 2011-02-14 14:22:40 +0000
+++ smtp_connection.py 2011-02-17 22:01:52 +0000
@@ -55,6 +55,7 @@
5555
56 self._smtp_username = config.get_user_option('smtp_username')56 self._smtp_username = config.get_user_option('smtp_username')
57 self._smtp_password = config.get_user_option('smtp_password')57 self._smtp_password = config.get_user_option('smtp_password')
58 self._use_ttls = config.get_user_option('smtp_use_ttls')
5859
59 self._connection = None60 self._connection = None
6061
@@ -85,6 +86,7 @@
85 # If this fails, it just returns an error, but it shouldn't raise an86 # If this fails, it just returns an error, but it shouldn't raise an
86 # exception unless something goes really wrong (in which case we want87 # exception unless something goes really wrong (in which case we want
87 # to fail anyway).88 # to fail anyway).
89<<<<<<< TREE
88 try:90 try:
89 self._connection.starttls()91 self._connection.starttls()
90 except smtplib.SMTPException, e:92 except smtplib.SMTPException, e:
@@ -95,6 +97,12 @@
95 pass97 pass
96 else:98 else:
97 raise99 raise
100=======
101 if self._use_ttls:
102 self._connection.ehlo()
103 self._connection.starttls()
104 self._connection.ehlo()
105>>>>>>> MERGE-SOURCE
98106
99 def _authenticate(self):107 def _authenticate(self):
100 """If necessary authenticate yourself to the server."""108 """If necessary authenticate yourself to the server."""

Subscribers

People subscribed via source and target branches

to all changes: