hgext/notify.py
changeset 15654 2a7fa7c641d8
parent 15561 ca572e94d8e7
child 16500 8436a4e21417
--- a/hgext/notify.py	Thu Dec 15 16:23:26 2011 +0100
+++ b/hgext/notify.py	Thu Dec 15 13:57:54 2011 +0100
@@ -108,6 +108,11 @@
 notify.mbox
   If set, append mails to this mbox file instead of sending. Default: None.
 
+notify.fromauthor
+  If set, use the first committer of the changegroup for the "From" field of
+  the notification mail. If not set, take the user from the pushing repo.
+  Default: False.
+
 If set, the following entries will also be used to customize the notifications:
 
 email.from
@@ -338,11 +343,14 @@
     ui.pushbuffer()
     data = ''
     count = 0
+    author = ''
     if hooktype == 'changegroup' or hooktype == 'outgoing':
         start, end = ctx.rev(), len(repo)
         for rev in xrange(start, end):
             if n.node(repo[rev]):
                 count += 1
+                if not author:
+                    author = repo[rev].user()
             else:
                 data += ui.popbuffer()
                 ui.note(_('notify: suppressing notification for merge %d:%s\n') %
@@ -360,5 +368,9 @@
         n.diff(ctx)
 
     data += ui.popbuffer()
+    fromauthor = ui.config('notify', 'fromauthor')
+    if author and fromauthor:
+        data = '\n'.join(['From: %s' % author, data])
+
     if count:
         n.send(ctx, count, data)