Mercurial > hg-stable
changeset 15561:ca572e94d8e7
notify: add option for writing to mbox
This makes it possible to test how the mails that are sent _really_ look like.
author | Mads Kiilerich <mads@kiilerich.com> |
---|---|
date | Wed, 23 Nov 2011 02:36:33 +0100 |
parents | cc58c228503e |
children | a82b6038ff08 |
files | hgext/notify.py mercurial/mail.py tests/test-notify.t |
diffstat | 3 files changed, 62 insertions(+), 4 deletions(-) [+] |
line wrap: on
line diff
--- a/hgext/notify.py Wed Nov 23 02:11:24 2011 +0100 +++ b/hgext/notify.py Wed Nov 23 02:36:33 2011 +0100 @@ -105,6 +105,9 @@ notify.merge If True, send notifications for merge changesets. Default: True. +notify.mbox + If set, append mails to this mbox file instead of sending. Default: None. + If set, the following entries will also be used to customize the notifications: email.from @@ -156,6 +159,7 @@ self.stripcount = int(self.ui.config('notify', 'strip', 0)) self.root = self.strip(self.repo.root) self.domain = self.ui.config('notify', 'domain') + self.mbox = self.ui.config('notify', 'mbox') self.test = self.ui.configbool('notify', 'test', True) self.charsets = mail._charsets(self.ui) self.subs = self.subscribers() @@ -288,7 +292,7 @@ self.ui.status(_('notify: sending %d subscribers %d changes\n') % (len(self.subs), count)) mail.sendmail(self.ui, util.email(msg['From']), - self.subs, msgtext) + self.subs, msgtext, mbox=self.mbox) def diff(self, ctx, ref=None):
--- a/mercurial/mail.py Wed Nov 23 02:11:24 2011 +0100 +++ b/mercurial/mail.py Wed Nov 23 02:36:33 2011 +0100 @@ -114,8 +114,8 @@ return _smtp(ui) return lambda s, r, m: _sendmail(ui, s, r, m) -def sendmail(ui, sender, recipients, msg): - send = connect(ui) +def sendmail(ui, sender, recipients, msg, mbox=None): + send = connect(ui, mbox=mbox) return send(sender, recipients, msg) def validateconfig(ui):
--- a/tests/test-notify.t Wed Nov 23 02:11:24 2011 +0100 +++ b/tests/test-notify.t Wed Nov 23 02:36:33 2011 +0100 @@ -113,6 +113,9 @@ notify.merge If True, send notifications for merge changesets. Default: True. + notify.mbox + If set, append mails to this mbox file instead of sending. Default: None. + If set, the following entries will also be used to customize the notifications: @@ -350,7 +353,7 @@ description: merge (run 'hg update' to get a working copy) -truncate multi-byte subject +non-ascii content and truncation of multi-byte subject $ cat <<EOF >> $HGRCPATH > [notify] @@ -395,3 +398,54 @@ a +a (run 'hg update' to get a working copy) + +long lines + + $ cat <<EOF >> $HGRCPATH + > [notify] + > maxsubject = 67 + > test = False + > mbox = mbox + > EOF + $ python -c 'print "no" * 500' >> a/a + $ hg --cwd a commit -A -m "long line" + $ hg --traceback --cwd b pull ../a + pulling from ../a + searching for changes + adding changesets + adding manifests + adding file changes + added 1 changesets with 1 changes to 1 files + notify: sending 2 subscribers 1 changes + (run 'hg update' to get a working copy) + $ python -c 'import sys,re; print re.sub("\n\t", " ", file("b/mbox").read()),' + From test@test.com ... ... .. ..:..:.. .... (re) + Content-Type: text/plain; charset="us-ascii" + MIME-Version: 1.0 + Content-Transfer-Encoding: 7bit + X-Test: foo + Date: * (glob) + Subject: long line + From: test@test.com + X-Hg-Notification: changeset e0be44cf638b + Message-Id: <hg.e0be44cf638b.*.*@*> (glob) + To: baz@test.com, foo@bar + + changeset e0be44cf638b in b + description: long line + diffstat: + + a | 1 + + 1 files changed, 1 insertions(+), 0 deletions(-) + + diffs (8 lines): + + diff -r 7ea05ad269dc -r e0be44cf638b a + --- a/a Thu Jan 01 00:00:00 1970 +0000 + +++ b/a Thu Jan 01 00:00:00 1970 +0000 + @@ -1,3 +1,4 @@ + a + a + a + +nononononononononononononononononononononononononononononononononononononononononononononononononononononononononononononononononononononononononononononononononononononononononononononononononononononononononononononononononononononononononononononononononononononononononononononononononononononononononononononononononononononononononononononononononononononononononononononononononononononononononononononononononononononononononononononononononononononononononononononononononononononononononononononononononononononononononononononononononononononononononononononononononononononononononononononononononononononononononononononononononononononononononononononononononononononononononononononononononononononononononononononononononononononononononononononononononononononononononononononononononononononononononononononononononononononononononononononononononononononononononononononononononononononononononononononononononononononononononononononononononononononononononononononononononononono +