##// END OF EJS Templates
notify: add option for deterministic message-id generation...
Joerg Sonnenberger -
r43174:d26a6706 default
parent child Browse files
Show More
@@ -82,6 +82,12 b' notify.strip'
82
82
83 notify.domain
83 notify.domain
84 Default email domain for sender or recipients with no explicit domain.
84 Default email domain for sender or recipients with no explicit domain.
85 It is also used for the domain part of the ``Message-Id`` when using
86 ``notify.messageidseed``.
87
88 notify.messageidseed
89 Create deterministic ``Message-Id`` headers for the mails based on the seed
90 and the revision identifier of the first commit in the changeset.
85
91
86 notify.style
92 notify.style
87 Style file to use when formatting emails.
93 Style file to use when formatting emails.
@@ -144,6 +150,7 b' from __future__ import absolute_import'
144 import email.errors as emailerrors
150 import email.errors as emailerrors
145 import email.parser as emailparser
151 import email.parser as emailparser
146 import fnmatch
152 import fnmatch
153 import hashlib
147 import socket
154 import socket
148 import time
155 import time
149
156
@@ -183,6 +190,9 b" configitem('notify', 'diffstat',"
183 configitem('notify', 'domain',
190 configitem('notify', 'domain',
184 default=None,
191 default=None,
185 )
192 )
193 configitem('notify', 'messageidseed',
194 default=None,
195 )
186 configitem('notify', 'fromauthor',
196 configitem('notify', 'fromauthor',
187 default=None,
197 default=None,
188 )
198 )
@@ -268,6 +278,7 b' class notifier(object):'
268 self.subs = self.subscribers()
278 self.subs = self.subscribers()
269 self.merge = self.ui.configbool('notify', 'merge')
279 self.merge = self.ui.configbool('notify', 'merge')
270 self.showfunc = self.ui.configbool('notify', 'showfunc')
280 self.showfunc = self.ui.configbool('notify', 'showfunc')
281 self.messageidseed = self.ui.config('notify', 'messageidseed')
271 if self.showfunc is None:
282 if self.showfunc is None:
272 self.showfunc = self.ui.configbool('diff', 'showfunc')
283 self.showfunc = self.ui.configbool('diff', 'showfunc')
273
284
@@ -412,10 +423,7 b' class notifier(object):'
412
423
413 msg[r'X-Hg-Notification'] = r'changeset %s' % ctx
424 msg[r'X-Hg-Notification'] = r'changeset %s' % ctx
414 if not msg[r'Message-Id']:
425 if not msg[r'Message-Id']:
415 msg[r'Message-Id'] = encoding.strfromlocal(
426 msg[r'Message-Id'] = messageid(ctx, self.domain, self.messageidseed)
416 '<hg.%s.%d.%d@%s>' % (ctx, int(time.time()),
417 hash(self.repo.root),
418 encoding.strtolocal(socket.getfqdn())))
419 msg[r'To'] = encoding.strfromlocal(', '.join(sorted(subs)))
427 msg[r'To'] = encoding.strfromlocal(', '.join(sorted(subs)))
420
428
421 msgtext = encoding.strtolocal(msg.as_string())
429 msgtext = encoding.strtolocal(msg.as_string())
@@ -517,3 +525,16 b' def hook(ui, repo, hooktype, node=None, '
517
525
518 if count:
526 if count:
519 n.send(ctx, count, data)
527 n.send(ctx, count, data)
528
529 def messageid(ctx, domain, messageidseed):
530 if domain and messageidseed:
531 host = domain
532 else:
533 host = encoding.strtolocal(socket.getfqdn())
534 if messageidseed:
535 messagehash = hashlib.sha512(ctx.hex() + messageidseed)
536 messageid = '<hg.%s@%s>' % (messagehash.hexdigest()[:64], host)
537 else:
538 messageid = '<hg.%s.%d.%d@%s>' % (ctx, int(time.time()),
539 hash(ctx.repo().root), host)
540 return encoding.strfromlocal(messageid)
@@ -99,7 +99,13 b''
99 "/long/path/repository" into "repository". Default: 0.
99 "/long/path/repository" into "repository". Default: 0.
100
100
101 notify.domain
101 notify.domain
102 Default email domain for sender or recipients with no explicit domain.
102 Default email domain for sender or recipients with no explicit domain. It is
103 also used for the domain part of the "Message-Id" when using
104 "notify.messageidseed".
105
106 notify.messageidseed
107 Create deterministic "Message-Id" headers for the mails based on the seed
108 and the revision identifier of the first commit in the changeset.
103
109
104 notify.style
110 notify.style
105 Style file to use when formatting emails.
111 Style file to use when formatting emails.
@@ -190,7 +196,7 b' the python call below wraps continuation'
190 of the very long subject line
196 of the very long subject line
191 pull (minimal config)
197 pull (minimal config)
192
198
193 $ hg --traceback --cwd b pull ../a | "$PYTHON" $TESTTMP/filter.py
199 $ hg --traceback --cwd b --config notify.domain=example.com --config notify.messageidseed=example pull ../a | "$PYTHON" $TESTTMP/filter.py
194 pulling from ../a
200 pulling from ../a
195 searching for changes
201 searching for changes
196 adding changesets
202 adding changesets
@@ -203,10 +209,10 b' pull (minimal config)'
203 Content-Transfer-Encoding: 7bit
209 Content-Transfer-Encoding: 7bit
204 Date: * (glob)
210 Date: * (glob)
205 Subject: changeset in $TESTTMP/b: b
211 Subject: changeset in $TESTTMP/b: b
206 From: test
212 From: test@example.com
207 X-Hg-Notification: changeset 00a13f371396
213 X-Hg-Notification: changeset 00a13f371396
208 Message-Id: <*> (glob)
214 Message-Id: <hg.ba3098a36bd4c297288d16788623a841f81f618ea961a0f0fd65de7eb1191b66@example.com>
209 To: baz, foo@bar
215 To: baz@example.com, foo@bar
210
216
211 changeset 00a13f371396 in $TESTTMP/b
217 changeset 00a13f371396 in $TESTTMP/b
212 details: $TESTTMP/b?cmd=changeset;node=00a13f371396
218 details: $TESTTMP/b?cmd=changeset;node=00a13f371396
General Comments 0
You need to be logged in to leave comments. Login now