def update(self, bugid, newstate, ctx): '''update bugzilla bug with reference to changeset.''' def webroot(root): '''strip leading prefix of repo root and turn into url-safe path.''' count = int(self.ui.config('bugzilla', 'strip')) root = util.pconvert(root) while count > 0: c = root.find('/') if c == -1: break root = root[c + 1:] count -= 1 return root mapfile = None tmpl = self.ui.config('bugzilla', 'template') if not tmpl: mapfile = self.ui.config('bugzilla', 'style') if not mapfile and not tmpl: tmpl = _('changeset {node|short} in repo {root} refers ' 'to bug {bug}.\ndetails:\n\t{desc|tabindent}') spec = logcmdutil.templatespec(tmpl, mapfile) t = logcmdutil.changesettemplater(self.ui, self.repo, spec) self.ui.pushbuffer() t.show(ctx, changes=ctx.changeset(), bug=str(bugid), hgweb=self.ui.config('web', 'baseurl'), root=self.repo.root, webroot=webroot(self.repo.root)) data = self.ui.popbuffer() self.bzdriver.updatebug(bugid, newstate, data, stringutil.email(ctx.user()))
def __init__(self, ui, repo, hooktype): self.ui = ui cfg = self.ui.config(b'notify', b'config') if cfg: self.ui.readconfig(cfg, sections=[b'usersubs', b'reposubs']) self.repo = repo self.stripcount = int(self.ui.config(b'notify', b'strip')) self.root = self.strip(self.repo.root) self.domain = self.ui.config(b'notify', b'domain') self.mbox = self.ui.config(b'notify', b'mbox') self.test = self.ui.configbool(b'notify', b'test') self.charsets = mail._charsets(self.ui) self.subs = self.subscribers() self.merge = self.ui.configbool(b'notify', b'merge') self.showfunc = self.ui.configbool(b'notify', b'showfunc') self.messageidseed = self.ui.config(b'notify', b'messageidseed') if self.showfunc is None: self.showfunc = self.ui.configbool(b'diff', b'showfunc') mapfile = None template = self.ui.config(b'notify', hooktype) or self.ui.config( b'notify', b'template') if not template: mapfile = self.ui.config(b'notify', b'style') if not mapfile and not template: template = deftemplates.get(hooktype) or single_template spec = logcmdutil.templatespec(template, mapfile) self.t = logcmdutil.changesettemplater(self.ui, self.repo, spec)