Merge lp:~johnf-inodes/bzr-email/server_support into lp:bzr-email

Proposed by John Ferlito
Status: Needs review
Proposed branch: lp:~johnf-inodes/bzr-email/server_support
Merge into: lp:bzr-email
Diff against target: None lines
To merge this branch: bzr merge lp:~johnf-inodes/bzr-email/server_support
Reviewer Review Type Date Requested Status
Robert Collins (community) Needs Information
Review via email: mp+4096@code.launchpad.net
To post a comment you must log in.
Revision history for this message
John Ferlito (johnf-inodes) wrote :

Two patches

* The first detects if bzr is running in server mode and send emails on a change rather than a commit

* The second is similar and sets the email from address to the commiter of the revision

Revision history for this message
Robert Collins (lifeless) wrote :

We should perhaps always use a set from address, rather than claiming to the person that wrote it, at least for the body.

I'm not sure why this is needed though: the post_commit_push_pull setting was intended to manage this; I have a concern that autodetecting 'on server side' will interact badly with 'ssh server; commit-something-locally', when that has a checkout from the same machine. Can you tell me more about how this is deployed for you?

review: Needs Information
Revision history for this message
Jelmer Vernooij (jelmer) wrote :

John, ping?

Revision history for this message
John Ferlito (johnf-inodes) wrote :

So we aren't using this any more and I really can't remember. But my vague recollection is we were running the smart server and I wanted all the configuration on that end, to enforce the messages being sent rather than on the client side.

From memory I think that commits worked fine but maybe merge's didn't.

Unmerged revisions

41. By John Ferlito

If we are a server use the committers from address rather than our own

40. By John Ferlito

Support running in serve mode

When running in serve mode the server sees a commit as a push. Deal with this
and send emails appropriately.

Updating diff...

An updated diff will be available in a few minutes. Reload to see the changes.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file '__init__.py'
2--- __init__.py 2008-12-09 20:09:15 +0000
3+++ __init__.py 2009-03-03 07:24:15 +0000
4@@ -70,6 +70,7 @@
5 # These three are used during import: No point lazy_importing them.
6 from bzrlib import errors
7 from bzrlib.branch import Branch
8+from bzrlib.smart.server import SmartTCPServer
9 from bzrlib.lazy_import import lazy_import
10
11 # lazy_import emailer so that it doesn't get loaded if it isn't used
12@@ -97,6 +98,8 @@
13 _emailer.EmailSender(params.branch, params.new_revid,
14 params.branch.get_config(), local_branch=None, op='change').send_maybe()
15
16+def server_started_hook(backing_urls, public_urls):
17+ _emailer.EmailSender.server_mode = True
18
19 def install_hooks():
20 """Install CommitSender to send after commits with bzr >= 0.15 """
21@@ -111,6 +114,12 @@
22 if getattr(Branch.hooks, 'name_hook', None) is not None:
23 Branch.hooks.name_hook(branch_commit_hook, "bzr-email")
24
25+ install_named_hook = getattr(SmartTCPServer.hooks, 'install_named_hook', None)
26+ if install_named_hook is not None:
27+ if 'server_started' in SmartTCPServer.hooks:
28+ install_named_hook('server_started', server_started_hook,
29+ 'bzr-email')
30+
31
32 def test_suite():
33 from unittest import TestSuite
34
35=== modified file 'emailer.py'
36--- emailer.py 2008-12-09 20:09:15 +0000
37+++ emailer.py 2009-03-03 09:05:30 +0000
38@@ -29,6 +29,7 @@
39 """An email message sender."""
40
41 _smtplib_implementation = SMTPConnection
42+ server_mode = False
43
44 def __init__(self, branch, revision_id, config, local_branch=None,
45 op='commit'):
46@@ -42,6 +43,7 @@
47 self.revision = None
48 self.revno = None
49 self.op = op
50+ self.server_mode = EmailSender.server_mode
51
52 def _setup_revision_and_revno(self):
53 self.revision = self.repository.get_revision(self._revision_id)
54@@ -164,7 +166,10 @@
55 """What address should I send from."""
56 result = self.config.get_user_option('post_commit_sender')
57 if result is None:
58- result = self.config.username()
59+ if self.server_mode and self.revision is not None:
60+ result = self.revision.committer
61+ else:
62+ result = self.config.username()
63 return result
64
65 def send(self):
66@@ -235,10 +240,10 @@
67 result = self.config.get_user_option('post_commit_difflimit')
68 post_commit_push_pull = self.config.get_user_option(
69 'post_commit_push_pull') == 'True'
70- if post_commit_push_pull and self.op == 'commit':
71+ if (post_commit_push_pull or self.server_mode) and self.op == 'commit':
72 # We will be called again with a push op, send the mail then.
73 return False
74- if not post_commit_push_pull and self.op != 'commit':
75+ if not post_commit_push_pull and not self.server_mode and self.op != 'commit':
76 # Mailing on commit only, and this is a push/pull operation.
77 return False
78 return bool(self.to() and self.from_address())

Subscribers

People subscribed via source and target branches

to all changes: