[PATCH] notify: fix neglect of custom headers set via template
Christian Ebert
blacktrash at gmx.net
Thu Jan 15 00:40:24 UTC 2009
# HG changeset patch
# User Christian Ebert <blacktrash at gmx.net>
# Date 1231979932 -3600
# Node ID a48d67b1528aa57ec7d90cc4b10532824fcd4e40
# Parent 0b2ee57dfdb168de0f4ac0a85139be66c0e8e457
notify: fix neglect of custom headers set via template
e981725da3fe introduced a bug that discarded all custom headers.
Add custom header to test template.
diff --git a/hgext/notify.py b/hgext/notify.py
--- a/hgext/notify.py
+++ b/hgext/notify.py
@@ -185,10 +185,16 @@
# store sender and subject
sender, subject = msg['From'], msg['Subject']
+ del msg['From'], msg['Subject']
+ # store remaining headers
+ headers = msg.items()
# create fresh mime message from msg body
text = msg.get_payload()
# for notification prefer readability over data precision
msg = mail.mimeencode(self.ui, text, self.charsets, self.test)
+ # reinstate custom headers
+ for k, v in headers:
+ msg[k] = v
def fix_subject(subject):
'''try to make subject line exist and be useful.'''
diff --git a/tests/test-notify b/tests/test-notify
--- a/tests/test-notify
+++ b/tests/test-notify
@@ -52,7 +52,7 @@
config = $HGTMP/.notify.conf
domain = test.com
strip = 3
-template = Subject: {desc|firstline|strip}\nFrom: {author}\n\nchangeset {node|short} in {webroot}\ndescription:\n\t{desc|tabindent|strip}
+template = Subject: {desc|firstline|strip}\nFrom: {author}\nX-Test: foo\n\nchangeset {node|short} in {webroot}\ndescription:\n\t{desc|tabindent|strip}
[web]
baseurl = http://test/
diff --git a/tests/test-notify.out b/tests/test-notify.out
--- a/tests/test-notify.out
+++ b/tests/test-notify.out
@@ -108,6 +108,7 @@
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
+X-Test: foo
Date:
Subject: b
From: test at test.com
@@ -138,6 +139,7 @@
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
+X-Test: foo
Date:
Subject: b
From: test at test.com
More information about the Mercurial-devel
mailing list