Show More
@@ -106,6 +106,7 b' class notifier(object):' | |||||
106 | self.stripcount = int(self.ui.config('notify', 'strip', 0)) |
|
106 | self.stripcount = int(self.ui.config('notify', 'strip', 0)) | |
107 | self.root = self.strip(self.repo.root) |
|
107 | self.root = self.strip(self.repo.root) | |
108 | self.domain = self.ui.config('notify', 'domain') |
|
108 | self.domain = self.ui.config('notify', 'domain') | |
|
109 | self.charsets = mail._charsets(self.ui) | |||
109 | self.subs = self.subscribers() |
|
110 | self.subs = self.subscribers() | |
110 |
|
111 | |||
111 | mapfile = self.ui.config('notify', 'style') |
|
112 | mapfile = self.ui.config('notify', 'style') | |
@@ -156,7 +157,8 b' class notifier(object):' | |||||
156 | if fnmatch.fnmatch(self.repo.root, pat): |
|
157 | if fnmatch.fnmatch(self.repo.root, pat): | |
157 | for user in users.split(','): |
|
158 | for user in users.split(','): | |
158 | subs[self.fixmail(user)] = 1 |
|
159 | subs[self.fixmail(user)] = 1 | |
159 |
|
|
160 | subs = util.sort(subs) | |
|
161 | return [mail.addressencode(self.ui, s, self.charsets) for s in subs] | |||
160 |
|
162 | |||
161 | def url(self, path=None): |
|
163 | def url(self, path=None): | |
162 | return self.ui.config('web', 'baseurl') + (path or self.root) |
|
164 | return self.ui.config('web', 'baseurl') + (path or self.root) | |
@@ -180,10 +182,16 b' class notifier(object):' | |||||
180 | p = email.Parser.Parser() |
|
182 | p = email.Parser.Parser() | |
181 | msg = p.parsestr(data) |
|
183 | msg = p.parsestr(data) | |
182 |
|
184 | |||
183 |
|
|
185 | # store sender and subject | |
|
186 | sender, subject = msg['From'], msg['Subject'] | |||
|
187 | # create fresh mime message from msg body | |||
|
188 | text = msg.get_payload() | |||
|
189 | # for notification prefer readability over data precision | |||
|
190 | msg = mail.mimeencode(self.ui, text, self.charsets) | |||
|
191 | ||||
|
192 | def fix_subject(subject): | |||
184 | '''try to make subject line exist and be useful.''' |
|
193 | '''try to make subject line exist and be useful.''' | |
185 |
|
194 | |||
186 | subject = msg['Subject'] |
|
|||
187 | if not subject: |
|
195 | if not subject: | |
188 | if count > 1: |
|
196 | if count > 1: | |
189 | subject = _('%s: %d new changesets') % (self.root, count) |
|
197 | subject = _('%s: %d new changesets') % (self.root, count) | |
@@ -194,23 +202,20 b' class notifier(object):' | |||||
194 | maxsubject = int(self.ui.config('notify', 'maxsubject', 67)) |
|
202 | maxsubject = int(self.ui.config('notify', 'maxsubject', 67)) | |
195 | if maxsubject and len(subject) > maxsubject: |
|
203 | if maxsubject and len(subject) > maxsubject: | |
196 | subject = subject[:maxsubject-3] + '...' |
|
204 | subject = subject[:maxsubject-3] + '...' | |
197 | del msg['Subject'] |
|
205 | msg['Subject'] = mail.headencode(self.ui, subject, self.charsets) | |
198 | msg['Subject'] = subject |
|
|||
199 |
|
206 | |||
200 | def fix_sender(): |
|
207 | def fix_sender(sender): | |
201 | '''try to make message have proper sender.''' |
|
208 | '''try to make message have proper sender.''' | |
202 |
|
209 | |||
203 | sender = msg['From'] |
|
|||
204 | if not sender: |
|
210 | if not sender: | |
205 | sender = self.ui.config('email', 'from') or self.ui.username() |
|
211 | sender = self.ui.config('email', 'from') or self.ui.username() | |
206 | if '@' not in sender or '@localhost' in sender: |
|
212 | if '@' not in sender or '@localhost' in sender: | |
207 | sender = self.fixmail(sender) |
|
213 | sender = self.fixmail(sender) | |
208 | del msg['From'] |
|
214 | msg['From'] = mail.addressencode(self.ui, sender, self.charsets) | |
209 | msg['From'] = sender |
|
|||
210 |
|
215 | |||
211 | msg['Date'] = util.datestr(format="%a, %d %b %Y %H:%M:%S %1%2") |
|
216 | msg['Date'] = util.datestr(format="%a, %d %b %Y %H:%M:%S %1%2") | |
212 | fix_subject() |
|
217 | fix_subject(subject) | |
213 | fix_sender() |
|
218 | fix_sender(sender) | |
214 |
|
219 | |||
215 | msg['X-Hg-Notification'] = 'changeset ' + short(node) |
|
220 | msg['X-Hg-Notification'] = 'changeset ' + short(node) | |
216 | if not msg['Message-Id']: |
|
221 | if not msg['Message-Id']: |
@@ -104,7 +104,7 b' diffstat = False' | |||||
104 | EOF |
|
104 | EOF | |
105 |
|
105 | |||
106 | echo % pull from bundle |
|
106 | echo % pull from bundle | |
107 |
hg pull -u ../kw.hg 2>&1 | sed -e '/^ |
|
107 | hg pull -u ../kw.hg 2>&1 | sed -e '/^Content-Type:/,/^diffs (/ d' | |
108 |
|
108 | |||
109 | echo % remove notify config |
|
109 | echo % remove notify config | |
110 | sed -e '/\[hooks\]/,$ d' $HGRCPATH > $HGRCPATH.nonotify |
|
110 | sed -e '/\[hooks\]/,$ d' $HGRCPATH > $HGRCPATH.nonotify |
@@ -11,6 +11,9 b' adding changesets' | |||||
11 | adding manifests |
|
11 | adding manifests | |
12 | adding file changes |
|
12 | adding file changes | |
13 | added 2 changesets with 2 changes to 1 files |
|
13 | added 2 changesets with 2 changes to 1 files | |
|
14 | Content-Type: text/plain; charset="us-ascii" | |||
|
15 | MIME-Version: 1.0 | |||
|
16 | Content-Transfer-Encoding: 7bit | |||
14 | Date: |
|
17 | Date: | |
15 | Subject: test-notify-changegroup/a: 2 new changesets |
|
18 | Subject: test-notify-changegroup/a: 2 new changesets | |
16 | From: test |
|
19 | From: test |
@@ -14,6 +14,9 b' adding changesets' | |||||
14 | adding manifests |
|
14 | adding manifests | |
15 | adding file changes |
|
15 | adding file changes | |
16 | added 1 changesets with 1 changes to 1 files |
|
16 | added 1 changesets with 1 changes to 1 files | |
|
17 | Content-Type: text/plain; charset="us-ascii" | |||
|
18 | MIME-Version: 1.0 | |||
|
19 | Content-Transfer-Encoding: 7bit | |||
17 | Date: |
|
20 | Date: | |
18 | Subject: changeset in test-notify/b: b |
|
21 | Subject: changeset in test-notify/b: b | |
19 | From: test |
|
22 | From: test | |
@@ -45,6 +48,9 b' adding changesets' | |||||
45 | adding manifests |
|
48 | adding manifests | |
46 | adding file changes |
|
49 | adding file changes | |
47 | added 1 changesets with 1 changes to 1 files |
|
50 | added 1 changesets with 1 changes to 1 files | |
|
51 | Content-Type: text/plain; charset="us-ascii" | |||
|
52 | MIME-Version: 1.0 | |||
|
53 | Content-Transfer-Encoding: 7bit | |||
48 | Date: |
|
54 | Date: | |
49 | Subject: b |
|
55 | Subject: b | |
50 | From: test@test.com |
|
56 | From: test@test.com | |
@@ -72,6 +78,9 b' adding changesets' | |||||
72 | adding manifests |
|
78 | adding manifests | |
73 | adding file changes |
|
79 | adding file changes | |
74 | added 1 changesets with 1 changes to 1 files |
|
80 | added 1 changesets with 1 changes to 1 files | |
|
81 | Content-Type: text/plain; charset="us-ascii" | |||
|
82 | MIME-Version: 1.0 | |||
|
83 | Content-Transfer-Encoding: 7bit | |||
75 | Date: |
|
84 | Date: | |
76 | Subject: b |
|
85 | Subject: b | |
77 | From: test@test.com |
|
86 | From: test@test.com |
General Comments 0
You need to be logged in to leave comments.
Login now