66 # push changes to, they can manage their own subscriptions. |
66 # push changes to, they can manage their own subscriptions. |
67 |
67 |
68 from mercurial.demandload import * |
68 from mercurial.demandload import * |
69 from mercurial.i18n import gettext as _ |
69 from mercurial.i18n import gettext as _ |
70 from mercurial.node import * |
70 from mercurial.node import * |
71 demandload(globals(), 'mercurial:commands,patch,templater,util,mail') |
71 demandload(globals(), 'mercurial:commands,patch,cmdutil,templater,util,mail') |
72 demandload(globals(), 'email.Parser fnmatch socket time') |
72 demandload(globals(), 'email.Parser fnmatch socket time') |
73 |
73 |
74 # template for single changeset can include email headers. |
74 # template for single changeset can include email headers. |
75 single_template = ''' |
75 single_template = ''' |
76 Subject: changeset in {webroot}: {desc|firstline|strip} |
76 Subject: changeset in {webroot}: {desc|firstline|strip} |
105 self.ui.readsections(cfg, 'usersubs', 'reposubs') |
105 self.ui.readsections(cfg, 'usersubs', 'reposubs') |
106 self.repo = repo |
106 self.repo = repo |
107 self.stripcount = int(self.ui.config('notify', 'strip', 0)) |
107 self.stripcount = int(self.ui.config('notify', 'strip', 0)) |
108 self.root = self.strip(self.repo.root) |
108 self.root = self.strip(self.repo.root) |
109 self.domain = self.ui.config('notify', 'domain') |
109 self.domain = self.ui.config('notify', 'domain') |
110 self.sio = templater.stringio() |
110 self.sio = cmdutil.stringio() |
111 self.subs = self.subscribers() |
111 self.subs = self.subscribers() |
112 |
112 |
113 mapfile = self.ui.config('notify', 'style') |
113 mapfile = self.ui.config('notify', 'style') |
114 template = (self.ui.config('notify', hooktype) or |
114 template = (self.ui.config('notify', hooktype) or |
115 self.ui.config('notify', 'template')) |
115 self.ui.config('notify', 'template')) |
116 self.t = templater.changeset_templater(self.ui, self.repo, mapfile, |
116 self.t = cmdutil.changeset_templater(self.ui, self.repo, mapfile, |
117 self.sio) |
117 self.sio) |
118 if not mapfile and not template: |
118 if not mapfile and not template: |
119 template = deftemplates.get(hooktype) or single_template |
119 template = deftemplates.get(hooktype) or single_template |
120 if template: |
120 if template: |
121 template = templater.parsestring(template, quoted=False) |
121 template = templater.parsestring(template, quoted=False) |
235 |
235 |
236 def diff(self, node, ref): |
236 def diff(self, node, ref): |
237 maxdiff = int(self.ui.config('notify', 'maxdiff', 300)) |
237 maxdiff = int(self.ui.config('notify', 'maxdiff', 300)) |
238 if maxdiff == 0: |
238 if maxdiff == 0: |
239 return |
239 return |
240 fp = templater.stringio() |
240 fp = cmdutil.stringio() |
241 prev = self.repo.changelog.parents(node)[0] |
241 prev = self.repo.changelog.parents(node)[0] |
242 patch.diff(self.repo, prev, ref, fp=fp) |
242 patch.diff(self.repo, prev, ref, fp=fp) |
243 difflines = fp.getvalue().splitlines(1) |
243 difflines = fp.getvalue().splitlines(1) |
244 if self.ui.configbool('notify', 'diffstat', True): |
244 if self.ui.configbool('notify', 'diffstat', True): |
245 s = patch.diffstat(difflines) |
245 s = patch.diffstat(difflines) |