##// END OF EJS Templates
notify: optional mail threading based on obsmarker...
Joerg Sonnenberger -
r45117:947e6df4 default
parent child Browse files
Show More
@@ -133,6 +133,15 b' notify.fromauthor'
133 the "From" field of the notification mail. If not set, take the user
133 the "From" field of the notification mail. If not set, take the user
134 from the pushing repo. Default: False.
134 from the pushing repo. Default: False.
135
135
136 notify.reply-to-predecessor (EXPERIMENTAL)
137 If set and the changeset has a predecessor in the repository, try to thread
138 the notification mail with the predecessor. This adds the "In-Reply-To" header
139 to the notification mail with a reference to the predecessor with the smallest
140 revision number. Mail threads can still be torn, especially when changesets
141 are folded.
142
143 This option must be used in combination with ``notify.messageidseed``.
144
136 If set, the following entries will also be used to customize the
145 If set, the following entries will also be used to customize the
137 notifications:
146 notifications:
138
147
@@ -160,6 +169,7 b' from mercurial import ('
160 error,
169 error,
161 logcmdutil,
170 logcmdutil,
162 mail,
171 mail,
172 obsutil,
163 patch,
173 patch,
164 pycompat,
174 pycompat,
165 registrar,
175 registrar,
@@ -219,6 +229,9 b' configitem('
219 b'notify', b'outgoing', default=None,
229 b'notify', b'outgoing', default=None,
220 )
230 )
221 configitem(
231 configitem(
232 b'notify', b'reply-to-predecessor', default=False,
233 )
234 configitem(
222 b'notify', b'sources', default=b'serve',
235 b'notify', b'sources', default=b'serve',
223 )
236 )
224 configitem(
237 configitem(
@@ -281,6 +294,16 b' class notifier(object):'
281 self.merge = self.ui.configbool(b'notify', b'merge')
294 self.merge = self.ui.configbool(b'notify', b'merge')
282 self.showfunc = self.ui.configbool(b'notify', b'showfunc')
295 self.showfunc = self.ui.configbool(b'notify', b'showfunc')
283 self.messageidseed = self.ui.config(b'notify', b'messageidseed')
296 self.messageidseed = self.ui.config(b'notify', b'messageidseed')
297 self.reply = self.ui.configbool(b'notify', b'reply-to-predecessor')
298
299 if self.reply and not self.messageidseed:
300 raise error.Abort(
301 _(
302 b'notify.reply-to-predecessor used without '
303 b'notify.messageidseed'
304 )
305 )
306
284 if self.showfunc is None:
307 if self.showfunc is None:
285 self.showfunc = self.ui.configbool(b'diff', b'showfunc')
308 self.showfunc = self.ui.configbool(b'diff', b'showfunc')
286
309
@@ -437,6 +460,26 b' class notifier(object):'
437 msg['X-Hg-Notification'] = 'changeset %s' % ctx
460 msg['X-Hg-Notification'] = 'changeset %s' % ctx
438 if not msg['Message-Id']:
461 if not msg['Message-Id']:
439 msg['Message-Id'] = messageid(ctx, self.domain, self.messageidseed)
462 msg['Message-Id'] = messageid(ctx, self.domain, self.messageidseed)
463 if self.reply:
464 unfi = self.repo.unfiltered()
465 has_node = unfi.changelog.index.has_node
466 predecessors = [
467 unfi[ctx2]
468 for ctx2 in obsutil.allpredecessors(unfi.obsstore, [ctx.node()])
469 if ctx2 != ctx.node() and has_node(ctx2)
470 ]
471 if predecessors:
472 # There is at least one predecessor, so which to pick?
473 # Ideally, there is a unique root because changesets have
474 # been evolved/rebased one step at a time. In this case,
475 # just picking the oldest known changeset provides a stable
476 # base. It doesn't help when changesets are folded. Any
477 # better solution would require storing more information
478 # in the repository.
479 pred = min(predecessors, key=lambda ctx: ctx.rev())
480 msg['In-Reply-To'] = messageid(
481 pred, self.domain, self.messageidseed
482 )
440 msg['To'] = ', '.join(sorted(subs))
483 msg['To'] = ', '.join(sorted(subs))
441
484
442 msgtext = msg.as_bytes() if pycompat.ispy3 else msg.as_string()
485 msgtext = msg.as_bytes() if pycompat.ispy3 else msg.as_string()
@@ -6,8 +6,15 b''
6 > EOF
6 > EOF
7
7
8 $ cat <<EOF >> $HGRCPATH
8 $ cat <<EOF >> $HGRCPATH
9 > [experimental]
10 > evolution = true
11 >
9 > [extensions]
12 > [extensions]
10 > notify=
13 > notify=
14 > strip=
15 >
16 > [phases]
17 > publish=False
11 >
18 >
12 > [hooks]
19 > [hooks]
13 > incoming.notify = python:hgext.notify.hook
20 > incoming.notify = python:hgext.notify.hook
@@ -15,6 +22,8 b''
15 > [notify]
22 > [notify]
16 > sources = pull
23 > sources = pull
17 > diffstat = False
24 > diffstat = False
25 > reply-to-predecessor = True
26 > messageidseed = notifyseed
18 >
27 >
19 > [usersubs]
28 > [usersubs]
20 > foo@bar = *
29 > foo@bar = *
@@ -151,6 +160,15 b''
151 "From" field of the notification mail. If not set, take the user from the
160 "From" field of the notification mail. If not set, take the user from the
152 pushing repo. Default: False.
161 pushing repo. Default: False.
153
162
163 notify.reply-to-predecessor (EXPERIMENTAL)
164 If set and the changeset has a predecessor in the repository, try to thread
165 the notification mail with the predecessor. This adds the "In-Reply-To"
166 header to the notification mail with a reference to the predecessor with the
167 smallest revision number. Mail threads can still be torn, especially when
168 changesets are folded.
169
170 This option must be used in combination with "notify.messageidseed".
171
154 If set, the following entries will also be used to customize the
172 If set, the following entries will also be used to customize the
155 notifications:
173 notifications:
156
174
@@ -205,7 +223,7 b' pull (minimal config)'
205 adding manifests
223 adding manifests
206 adding file changes
224 adding file changes
207 added 1 changesets with 2 changes to 2 files
225 added 1 changesets with 2 changes to 2 files
208 new changesets 00a13f371396
226 new changesets 00a13f371396 (1 drafts)
209 MIME-Version: 1.0
227 MIME-Version: 1.0
210 Content-Type: text/plain; charset="us-ascii"
228 Content-Type: text/plain; charset="us-ascii"
211 Content-Transfer-Encoding: 7bit
229 Content-Transfer-Encoding: 7bit
@@ -266,7 +284,7 b' pull'
266 adding manifests
284 adding manifests
267 adding file changes
285 adding file changes
268 added 1 changesets with 2 changes to 2 files
286 added 1 changesets with 2 changes to 2 files
269 new changesets 00a13f371396
287 new changesets 00a13f371396 (1 drafts)
270 MIME-Version: 1.0
288 MIME-Version: 1.0
271 Content-Type: text/plain; charset="us-ascii"
289 Content-Type: text/plain; charset="us-ascii"
272 Content-Transfer-Encoding: 7bit
290 Content-Transfer-Encoding: 7bit
@@ -316,7 +334,7 b' pull'
316 adding manifests
334 adding manifests
317 adding file changes
335 adding file changes
318 added 1 changesets with 2 changes to 2 files
336 added 1 changesets with 2 changes to 2 files
319 new changesets 00a13f371396
337 new changesets 00a13f371396 (1 drafts)
320 MIME-Version: 1.0
338 MIME-Version: 1.0
321 Content-Type: text/plain; charset="us-ascii"
339 Content-Type: text/plain; charset="us-ascii"
322 Content-Transfer-Encoding: 7bit
340 Content-Transfer-Encoding: 7bit
@@ -369,7 +387,7 b' test merge'
369 adding manifests
387 adding manifests
370 adding file changes
388 adding file changes
371 added 2 changesets with 0 changes to 0 files
389 added 2 changesets with 0 changes to 0 files
372 new changesets 3332653e1f3c:fccf66cd0c35
390 new changesets 3332653e1f3c:fccf66cd0c35 (2 drafts)
373 MIME-Version: 1.0
391 MIME-Version: 1.0
374 Content-Type: text/plain; charset="us-ascii"
392 Content-Type: text/plain; charset="us-ascii"
375 Content-Transfer-Encoding: 7bit
393 Content-Transfer-Encoding: 7bit
@@ -436,7 +454,7 b' non-ascii content and truncation of mult'
436 adding manifests
454 adding manifests
437 adding file changes
455 adding file changes
438 added 1 changesets with 1 changes to 1 files
456 added 1 changesets with 1 changes to 1 files
439 new changesets 0f25f9c22b4c
457 new changesets 0f25f9c22b4c (1 drafts)
440 MIME-Version: 1.0
458 MIME-Version: 1.0
441 Content-Type: text/plain; charset="us-ascii"
459 Content-Type: text/plain; charset="us-ascii"
442 Content-Transfer-Encoding: 8bit
460 Content-Transfer-Encoding: 8bit
@@ -480,7 +498,7 b' long lines'
480 adding manifests
498 adding manifests
481 adding file changes
499 adding file changes
482 added 1 changesets with 1 changes to 1 files
500 added 1 changesets with 1 changes to 1 files
483 new changesets a846b5f6ebb7
501 new changesets a846b5f6ebb7 (1 drafts)
484 notify: sending 2 subscribers 1 changes
502 notify: sending 2 subscribers 1 changes
485 (run 'hg update' to get a working copy)
503 (run 'hg update' to get a working copy)
486 $ cat b/mbox | "$PYTHON" $TESTDIR/unwrap-message-id.py | "$PYTHON" $TESTTMP/filter.py
504 $ cat b/mbox | "$PYTHON" $TESTDIR/unwrap-message-id.py | "$PYTHON" $TESTTMP/filter.py
@@ -493,7 +511,7 b' long lines'
493 Subject: long line
511 Subject: long line
494 From: test@test.com
512 From: test@test.com
495 X-Hg-Notification: changeset a846b5f6ebb7
513 X-Hg-Notification: changeset a846b5f6ebb7
496 Message-Id: <hg.a846b5f6ebb7.*.*@*> (glob)
514 Message-Id: <hg.e7dc7658565793ff33c797e72b7d1f3799347b042af3c40df6d17c8d5c3e560a@test.com>
497 To: baz@test.com, foo@bar
515 To: baz@test.com, foo@bar
498
516
499 changeset a846b5f6ebb7 in b
517 changeset a846b5f6ebb7 in b
@@ -543,6 +561,8 b' long lines'
543 (branches are permanent and global, did you want a bookmark?)
561 (branches are permanent and global, did you want a bookmark?)
544 $ echo a >> a/a
562 $ echo a >> a/a
545 $ hg --cwd a ci -m test -d '1 0'
563 $ hg --cwd a ci -m test -d '1 0'
564 $ echo a >> a/a
565 $ hg --cwd a ci -m test -d '1 0'
546 $ hg --traceback --cwd b pull ../a | \
566 $ hg --traceback --cwd b pull ../a | \
547 > "$PYTHON" $TESTDIR/unwrap-message-id.py | \
567 > "$PYTHON" $TESTDIR/unwrap-message-id.py | \
548 > "$PYTHON" $TESTTMP/filter.py
568 > "$PYTHON" $TESTTMP/filter.py
@@ -551,8 +571,8 b' long lines'
551 adding changesets
571 adding changesets
552 adding manifests
572 adding manifests
553 adding file changes
573 adding file changes
554 added 1 changesets with 1 changes to 1 files
574 added 2 changesets with 2 changes to 1 files
555 new changesets f7e5aaed4080
575 new changesets f7e5aaed4080:485bf79b9464 (2 drafts)
556 MIME-Version: 1.0
576 MIME-Version: 1.0
557 Content-Type: text/plain; charset="us-ascii"
577 Content-Type: text/plain; charset="us-ascii"
558 Content-Transfer-Encoding: 7bit
578 Content-Transfer-Encoding: 7bit
@@ -561,11 +581,24 b' long lines'
561 Subject: test
581 Subject: test
562 From: test@test.com
582 From: test@test.com
563 X-Hg-Notification: changeset f7e5aaed4080
583 X-Hg-Notification: changeset f7e5aaed4080
564 Message-Id: <hg.f7e5aaed4080.*.*@*> (glob)
584 Message-Id: <hg.12e9ae631e2529e9cfbe7a93be0dd8a401280700640f802a60f20d7be659251d@test.com>
565 To: baz@test.com, foo@bar, notify@example.com
585 To: baz@test.com, foo@bar, notify@example.com
566
586
567 changeset f7e5aaed4080 in b
587 changeset f7e5aaed4080 in b
568 description: test
588 description: test
589 MIME-Version: 1.0
590 Content-Type: text/plain; charset="us-ascii"
591 Content-Transfer-Encoding: 7bit
592 X-Test: foo
593 Date: * (glob)
594 Subject: test
595 From: test@test.com
596 X-Hg-Notification: changeset 485bf79b9464
597 Message-Id: <hg.15281d60c27d9d5fb70435d33ebc24cb5aa580f2535988dcb9923c26e8bc5c47@test.com>
598 To: baz@test.com, foo@bar, notify@example.com
599
600 changeset 485bf79b9464 in b
601 description: test
569 (run 'hg update' to get a working copy)
602 (run 'hg update' to get a working copy)
570
603
571 revset selection: don't send to address that waits for mails
604 revset selection: don't send to address that waits for mails
@@ -584,7 +617,7 b' from different branch'
584 adding manifests
617 adding manifests
585 adding file changes
618 adding file changes
586 added 1 changesets with 0 changes to 0 files (+1 heads)
619 added 1 changesets with 0 changes to 0 files (+1 heads)
587 new changesets 645eb6690ecf
620 new changesets 645eb6690ecf (1 drafts)
588 MIME-Version: 1.0
621 MIME-Version: 1.0
589 Content-Type: text/plain; charset="us-ascii"
622 Content-Type: text/plain; charset="us-ascii"
590 Content-Transfer-Encoding: 7bit
623 Content-Transfer-Encoding: 7bit
@@ -593,7 +626,7 b' from different branch'
593 Subject: test
626 Subject: test
594 From: test@test.com
627 From: test@test.com
595 X-Hg-Notification: changeset 645eb6690ecf
628 X-Hg-Notification: changeset 645eb6690ecf
596 Message-Id: <hg.645eb6690ecf.*.*@*> (glob)
629 Message-Id: <hg.ba26b2c63e7deb44e86c934aeea147edde12a11b6ac94bda103dcab5028dc928@test.com>
597 To: baz@test.com, foo@bar
630 To: baz@test.com, foo@bar
598
631
599 changeset 645eb6690ecf in b
632 changeset 645eb6690ecf in b
@@ -616,7 +649,7 b' default template:'
616 Subject: changeset in b: default template
649 Subject: changeset in b: default template
617 From: test@test.com
650 From: test@test.com
618 X-Hg-Notification: changeset 5cd4346eed47
651 X-Hg-Notification: changeset 5cd4346eed47
619 Message-Id: <hg.5cd4346eed47.*.*@*> (glob)
652 Message-Id: <hg.8caa7941b24fc673d10910cb072e2d167362a3c5111cafefa47190d9b831f0a3@test.com>
620 To: baz@test.com, foo@bar
653 To: baz@test.com, foo@bar
621
654
622 changeset 5cd4346eed47 in $TESTTMP/b
655 changeset 5cd4346eed47 in $TESTTMP/b
@@ -647,7 +680,7 b' with style:'
647 Subject: with style
680 Subject: with style
648 From: test@test.com
681 From: test@test.com
649 X-Hg-Notification: changeset ec8d9d852f56
682 X-Hg-Notification: changeset ec8d9d852f56
650 Message-Id: <hg.ec8d9d852f56.*.*@*> (glob)
683 Message-Id: <hg.ccd5049818a6a277251189ce1d6d0cca10723d58214199e7178894adb99ed918@test.com>
651 To: baz@test.com, foo@bar
684 To: baz@test.com, foo@bar
652
685
653 changeset ec8d9d852f56
686 changeset ec8d9d852f56
@@ -672,7 +705,7 b' with template (overrides style):'
672 Subject: 14721b538ae3: with template
705 Subject: 14721b538ae3: with template
673 From: test@test.com
706 From: test@test.com
674 X-Hg-Notification: changeset 14721b538ae3
707 X-Hg-Notification: changeset 14721b538ae3
675 Message-Id: <hg.14721b538ae3.*.*@*> (glob)
708 Message-Id: <hg.7edb9765307a5a24528f3964672e794e2d21f2479e96c099bf52e02abd17b3a2@test.com>
676 To: baz@test.com, foo@bar
709 To: baz@test.com, foo@bar
677
710
678 with template
711 with template
@@ -695,6 +728,8 b' showfunc diff'
695 > EOF
728 > EOF
696 $ hg commit -Am addfunction
729 $ hg commit -Am addfunction
697 adding f1
730 adding f1
731 $ hg debugobsolete eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee b86bc16ff894f057d023b306936f290954857187
732 1 new obsolescence markers
698 $ hg --cwd ../b pull ../a | \
733 $ hg --cwd ../b pull ../a | \
699 > "$PYTHON" $TESTDIR/unwrap-message-id.py
734 > "$PYTHON" $TESTDIR/unwrap-message-id.py
700 pulling from ../a
735 pulling from ../a
@@ -703,7 +738,8 b' showfunc diff'
703 adding manifests
738 adding manifests
704 adding file changes
739 adding file changes
705 added 1 changesets with 1 changes to 1 files
740 added 1 changesets with 1 changes to 1 files
706 new changesets b86bc16ff894
741 1 new obsolescence markers
742 new changesets b86bc16ff894 (1 drafts)
707 MIME-Version: 1.0
743 MIME-Version: 1.0
708 Content-Type: text/plain; charset="us-ascii"
744 Content-Type: text/plain; charset="us-ascii"
709 Content-Transfer-Encoding: 7bit
745 Content-Transfer-Encoding: 7bit
@@ -711,7 +747,7 b' showfunc diff'
711 Subject: addfunction
747 Subject: addfunction
712 From: test@test.com
748 From: test@test.com
713 X-Hg-Notification: changeset b86bc16ff894
749 X-Hg-Notification: changeset b86bc16ff894
714 Message-Id: <hg.b86bc16ff894.*.*@*> (glob)
750 Message-Id: <hg.4c7cacfbbd6ba170656be0c8fc0d7599bd925c0d545b836816be9983e6d08448@test.com>
715 To: baz@test.com, foo@bar
751 To: baz@test.com, foo@bar
716
752
717 changeset b86bc16ff894
753 changeset b86bc16ff894
@@ -739,6 +775,9 b' showfunc diff'
739 > }
775 > }
740 > EOF
776 > EOF
741 $ hg commit -m changefunction
777 $ hg commit -m changefunction
778 $ hg debugobsolete 485bf79b9464197b2ed2debd0b16252ad64ed458 e81040e9838c704d8bf17658cb11758f24e40b6b
779 1 new obsolescence markers
780 obsoleted 1 changesets
742 $ hg --cwd ../b --config notify.showfunc=True pull ../a | \
781 $ hg --cwd ../b --config notify.showfunc=True pull ../a | \
743 > "$PYTHON" $TESTDIR/unwrap-message-id.py
782 > "$PYTHON" $TESTDIR/unwrap-message-id.py
744 pulling from ../a
783 pulling from ../a
@@ -747,7 +786,9 b' showfunc diff'
747 adding manifests
786 adding manifests
748 adding file changes
787 adding file changes
749 added 1 changesets with 1 changes to 1 files
788 added 1 changesets with 1 changes to 1 files
750 new changesets e81040e9838c
789 1 new obsolescence markers
790 obsoleted 1 changesets
791 new changesets e81040e9838c (1 drafts)
751 MIME-Version: 1.0
792 MIME-Version: 1.0
752 Content-Type: text/plain; charset="us-ascii"
793 Content-Type: text/plain; charset="us-ascii"
753 Content-Transfer-Encoding: 7bit
794 Content-Transfer-Encoding: 7bit
@@ -755,7 +796,8 b' showfunc diff'
755 Subject: changefunction
796 Subject: changefunction
756 From: test@test.com
797 From: test@test.com
757 X-Hg-Notification: changeset e81040e9838c
798 X-Hg-Notification: changeset e81040e9838c
758 Message-Id: <hg.e81040e9838c.*.*@*> (glob)
799 Message-Id: <hg.99b80bf1c5d0bf8f8a7e60107c1aa1da367a5943b2a70a8b36517d701557edff@test.com>
800 In-Reply-To: <hg.15281d60c27d9d5fb70435d33ebc24cb5aa580f2535988dcb9923c26e8bc5c47@test.com>
759 To: baz@test.com, foo@bar
801 To: baz@test.com, foo@bar
760
802
761 changeset e81040e9838c
803 changeset e81040e9838c
@@ -774,3 +816,50 b' showfunc diff'
774 + return a + b + c + e;
816 + return a + b + c + e;
775 }
817 }
776 (run 'hg update' to get a working copy)
818 (run 'hg update' to get a working copy)
819
820 Retry the In-Reply-To, but make sure the oldest known change is older.
821 This can happen when folding commits that have been rebased by another user.
822
823 $ hg --cwd ../b strip tip
824 saved backup bundle to $TESTTMP/b/.hg/strip-backup/e81040e9838c-10aad4de-backup.hg
825 $ hg debugobsolete f7e5aaed408029cfe9890318245e87ef44739fdd e81040e9838c704d8bf17658cb11758f24e40b6b
826 1 new obsolescence markers
827 obsoleted 1 changesets
828 $ hg --cwd ../b --config notify.showfunc=True pull ../a | \
829 > "$PYTHON" $TESTDIR/unwrap-message-id.py
830 pulling from ../a
831 searching for changes
832 adding changesets
833 adding manifests
834 adding file changes
835 added 1 changesets with 1 changes to 1 files
836 2 new obsolescence markers
837 obsoleted 2 changesets
838 new changesets e81040e9838c (1 drafts)
839 MIME-Version: 1.0
840 Content-Type: text/plain; charset="us-ascii"
841 Content-Transfer-Encoding: 7bit
842 Date: * (glob)
843 Subject: changefunction
844 From: test@test.com
845 X-Hg-Notification: changeset e81040e9838c
846 Message-Id: <hg.99b80bf1c5d0bf8f8a7e60107c1aa1da367a5943b2a70a8b36517d701557edff@test.com>
847 In-Reply-To: <hg.12e9ae631e2529e9cfbe7a93be0dd8a401280700640f802a60f20d7be659251d@test.com>
848 To: baz@test.com, foo@bar
849
850 changeset e81040e9838c
851 diffs (12 lines):
852
853 diff -r b86bc16ff894 -r e81040e9838c f1
854 --- a/f1 Thu Jan 01 00:00:00 1970 +0000
855 +++ b/f1 Thu Jan 01 00:00:00 1970 +0000
856 @@ -2,6 +2,6 @@ int main() {
857 int a = 0;
858 int b = 1;
859 int c = 2;
860 - int d = 3;
861 - return a + b + c + d;
862 + int e = 3;
863 + return a + b + c + e;
864 }
865 (run 'hg update' to get a working copy)
General Comments 0
You need to be logged in to leave comments. Login now