Show More
@@ -106,6 +106,7 b' class notifier(object):' | |||
|
106 | 106 | self.stripcount = int(self.ui.config('notify', 'strip', 0)) |
|
107 | 107 | self.root = self.strip(self.repo.root) |
|
108 | 108 | self.domain = self.ui.config('notify', 'domain') |
|
109 | self.charsets = mail._charsets(self.ui) | |
|
109 | 110 | self.subs = self.subscribers() |
|
110 | 111 | |
|
111 | 112 | mapfile = self.ui.config('notify', 'style') |
@@ -156,7 +157,8 b' class notifier(object):' | |||
|
156 | 157 | if fnmatch.fnmatch(self.repo.root, pat): |
|
157 | 158 | for user in users.split(','): |
|
158 | 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 | 163 | def url(self, path=None): |
|
162 | 164 | return self.ui.config('web', 'baseurl') + (path or self.root) |
@@ -180,10 +182,16 b' class notifier(object):' | |||
|
180 | 182 | p = email.Parser.Parser() |
|
181 | 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 | 193 | '''try to make subject line exist and be useful.''' |
|
185 | 194 | |
|
186 | subject = msg['Subject'] | |
|
187 | 195 | if not subject: |
|
188 | 196 | if count > 1: |
|
189 | 197 | subject = _('%s: %d new changesets') % (self.root, count) |
@@ -194,23 +202,20 b' class notifier(object):' | |||
|
194 | 202 | maxsubject = int(self.ui.config('notify', 'maxsubject', 67)) |
|
195 | 203 | if maxsubject and len(subject) > maxsubject: |
|
196 | 204 | subject = subject[:maxsubject-3] + '...' |
|
197 | del msg['Subject'] | |
|
198 | msg['Subject'] = subject | |
|
205 | msg['Subject'] = mail.headencode(self.ui, subject, self.charsets) | |
|
199 | 206 | |
|
200 | def fix_sender(): | |
|
207 | def fix_sender(sender): | |
|
201 | 208 | '''try to make message have proper sender.''' |
|
202 | 209 | |
|
203 | sender = msg['From'] | |
|
204 | 210 | if not sender: |
|
205 | 211 | sender = self.ui.config('email', 'from') or self.ui.username() |
|
206 | 212 | if '@' not in sender or '@localhost' in sender: |
|
207 | 213 | sender = self.fixmail(sender) |
|
208 | del msg['From'] | |
|
209 | msg['From'] = sender | |
|
214 | msg['From'] = mail.addressencode(self.ui, sender, self.charsets) | |
|
210 | 215 | |
|
211 | 216 | msg['Date'] = util.datestr(format="%a, %d %b %Y %H:%M:%S %1%2") |
|
212 | fix_subject() | |
|
213 | fix_sender() | |
|
217 | fix_subject(subject) | |
|
218 | fix_sender(sender) | |
|
214 | 219 | |
|
215 | 220 | msg['X-Hg-Notification'] = 'changeset ' + short(node) |
|
216 | 221 | if not msg['Message-Id']: |
@@ -104,7 +104,7 b' diffstat = False' | |||
|
104 | 104 | EOF |
|
105 | 105 | |
|
106 | 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 | 109 | echo % remove notify config |
|
110 | 110 | sed -e '/\[hooks\]/,$ d' $HGRCPATH > $HGRCPATH.nonotify |
@@ -11,6 +11,9 b' adding changesets' | |||
|
11 | 11 | adding manifests |
|
12 | 12 | adding file changes |
|
13 | 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 | 17 | Date: |
|
15 | 18 | Subject: test-notify-changegroup/a: 2 new changesets |
|
16 | 19 | From: test |
@@ -14,6 +14,9 b' adding changesets' | |||
|
14 | 14 | adding manifests |
|
15 | 15 | adding file changes |
|
16 | 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 | 20 | Date: |
|
18 | 21 | Subject: changeset in test-notify/b: b |
|
19 | 22 | From: test |
@@ -45,6 +48,9 b' adding changesets' | |||
|
45 | 48 | adding manifests |
|
46 | 49 | adding file changes |
|
47 | 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 | 54 | Date: |
|
49 | 55 | Subject: b |
|
50 | 56 | From: test@test.com |
@@ -72,6 +78,9 b' adding changesets' | |||
|
72 | 78 | adding manifests |
|
73 | 79 | adding file changes |
|
74 | 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 | 84 | Date: |
|
76 | 85 | Subject: b |
|
77 | 86 | From: test@test.com |
General Comments 0
You need to be logged in to leave comments.
Login now