[PATCH] Notify : Add sending date to notify message

Mathieu Clabaut mathieu.clabaut at gmail.com
Thu May 24 09:45:10 CDT 2007


# HG changeset patch
# User Mathieu Clabaut <mathieu.clabaut at gmail.com>
# Date 1180017158 -7200
# Node ID 4a4c8b494732f73ea1e90e6d0b2c782c786cbebf
# Parent  8fa54b9c6c5a22654e3b244e073673a415059897
Add sending date to notify message.

When using SMTP, no date field was set into the message, which causes it to
be
displayed as being send on 1st january 1970 on most MUA.

diff --git a/hgext/notify.py b/hgext/notify.py
--- a/hgext/notify.py
+++ b/hgext/notify.py
@@ -210,6 +210,8 @@ class notifier(object):
             del msg['From']
             msg['From'] = sender

+        msg['Date'] = util.datestr(date=util.makedate(),
+                format="%a, %d %b %Y %H:%M:%S", timezone=True)
         fix_subject()
         fix_sender()

diff --git a/tests/test-notify b/tests/test-notify
--- a/tests/test-notify
+++ b/tests/test-notify
@@ -34,7 +34,8 @@ echo '% pull (minimal config)'
 echo '% pull (minimal config)'
 hg --traceback --cwd b pull ../a 2>&1 | sed -e 's/\(Message-Id:\).*/\1/' \
   -e 's/changeset \([0-9a-f]* *\)in .*test-notif/changeset \1in
test-notif/' \
-  -e 's/^details: .*test-notify/details: test-notify/'
+  -e 's/^details: .*test-notify/details: test-notify/' \
+  -e 's/^Date:.*/Date:/'

 cat <<EOF >> $HGRCPATH
 [notify]
@@ -50,5 +51,6 @@ echo % pull
 echo % pull
 hg --cwd b rollback
 hg --traceback --cwd b pull ../a 2>&1 | sed -e 's/\(Message-Id:\).*/\1/' \
-  -e 's/changeset \([0-9a-f]*\) in .*/changeset \1/'
+  -e 's/changeset \([0-9a-f]*\) in .*/changeset \1/' \
+  -e 's/^Date:.*/Date:/'

diff --git a/tests/test-notify.out b/tests/test-notify.out
--- a/tests/test-notify.out
+++ b/tests/test-notify.out
@@ -13,6 +13,7 @@ adding manifests
 adding manifests
 adding file changes
 added 1 changesets with 1 changes to 1 files
+Date:
 Subject: changeset in test-notify/b: b
 From: test
 X-Hg-Notification: changeset 0647d048b600
@@ -41,6 +42,7 @@ adding manifests
 adding manifests
 adding file changes
 added 1 changesets with 1 changes to 1 files
+Date:
 Subject: b
 From: test at test.com
 X-Hg-Notification: changeset 0647d048b600
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://selenic.com/pipermail/mercurial-devel/attachments/20070524/9d78d2ac/attachment.htm 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: notify-send-date.patch
Type: text/x-patch
Size: 2070 bytes
Desc: not available
Url : http://selenic.com/pipermail/mercurial-devel/attachments/20070524/9d78d2ac/attachment.bin 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: notify-send-date.bundle
Type: application/octet-stream
Size: 1063 bytes
Desc: not available
Url : http://selenic.com/pipermail/mercurial-devel/attachments/20070524/9d78d2ac/attachment.obj 


More information about the Mercurial-devel mailing list