def maketemplater(ui, repo, tmpl): try: t = cmdutil.changeset_templater(ui, repo, False, None, tmpl, None, False) except SyntaxError as inst: raise util.Abort(inst.args[0]) return t
def kwsub(mobj): kw = mobj.group(1) ct = cmdutil.changeset_templater(self.ui, self.repo, False, None, self.templates[kw], "", False) self.ui.pushbuffer() ct.show(ctx, root=self.repo.root, file=path) ekw = templatefilters.firstline(self.ui.popbuffer()) return "$%s: %s $" % (kw, ekw)
def update(self, bugid, 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', 0)) root = util.pconvert(root) while count > 0: c = root.find('/') if c == -1: break root = root[c+1:] count -= 1 return root mapfile = self.ui.config('bugzilla', 'style') tmpl = self.ui.config('bugzilla', 'template') t = cmdutil.changeset_templater(self.ui, self.repo, False, None, mapfile, False) if not mapfile and not tmpl: tmpl = _('changeset {node|short} in repo {root} refers ' 'to bug {bug}.\ndetails:\n\t{desc|tabindent}') if tmpl: tmpl = templater.parsestring(tmpl, quoted=False) t.use_template(tmpl) 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.add_comment(bugid, data, util.email(ctx.user()))
def maketemplater(ui, repo, tmpl): try: t = cmdutil.changeset_templater(ui, repo, False, None, tmpl, None, False) except SyntaxError as inst: raise error.Abort(inst.args[0]) return t
def __init__(self, ui, repo, hooktype): self.ui = ui cfg = self.ui.config('notify', 'config') if cfg: self.ui.readconfig(cfg, sections=['usersubs', 'reposubs']) self.repo = repo self.stripcount = int(self.ui.config('notify', 'strip', 0)) self.root = self.strip(self.repo.root) self.domain = self.ui.config('notify', 'domain') self.mbox = self.ui.config('notify', 'mbox') self.test = self.ui.configbool('notify', 'test', True) self.charsets = mail._charsets(self.ui) self.subs = self.subscribers() self.merge = self.ui.configbool('notify', 'merge', True) mapfile = self.ui.config('notify', 'style') template = (self.ui.config('notify', hooktype) or self.ui.config('notify', 'template')) self.t = cmdutil.changeset_templater(self.ui, self.repo, False, None, mapfile, False) if not mapfile and not template: template = deftemplates.get(hooktype) or single_template if template: template = templater.parsestring(template, quoted=False) self.t.use_template(template)
def show(ui, repo, view=None, template=None): """show various repository information A requested view of repository data is displayed. If no view is requested, the list of available views is shown and the command aborts. .. note:: There are no backwards compatibility guarantees for the output of this command. Output may change in any future Mercurial release. Consumers wanting stable command output should specify a template via ``-T/--template``. List of available views: """ if ui.plain() and not template: hint = _('invoke with -T/--template to control output format') raise error.Abort(_('must specify a template in plain mode'), hint=hint) views = showview._table if not view: ui.pager('show') # TODO consider using formatter here so available views can be # rendered to custom format. ui.write(_('available views:\n')) ui.write('\n') for name, func in sorted(views.items()): ui.write(('%s\n') % func.__doc__) ui.write('\n') raise error.Abort(_('no view requested'), hint=_('use "hg show VIEW" to choose a view')) # TODO use same logic as dispatch to perform prefix matching. if view not in views: raise error.Abort(_('unknown view: %s') % view, hint=_('run "hg show" to see available views')) template = template or 'show' fn = views[view] ui.pager('show') if fn._fmtopic: fmtopic = 'show%s' % fn._fmtopic with ui.formatter(fmtopic, {'template': template}) as fm: return fn(ui, repo, fm) elif fn._csettopic: ref = 'show%s' % fn._csettopic spec = formatter.lookuptemplate(ui, ref, template) displayer = cmdutil.changeset_templater(ui, repo, spec, buffered=True) return fn(ui, repo, displayer) else: return fn(ui, repo)
def __init__(self, ui, repo): self.ui = ui self.repo = repo self.ciaurl = self.ui.config('cia', 'url', 'http://cia.vc') self.user = self.ui.config('cia', 'user') self.project = self.ui.config('cia', 'project') self.module = self.ui.config('cia', 'module') self.diffstat = self.ui.configbool('cia', 'diffstat') self.emailfrom = self.ui.config('email', 'from') self.dryrun = self.ui.configbool('cia', 'test') self.url = self.ui.config('web', 'baseurl') # Default to -1 for backward compatibility self.stripcount = int(self.ui.config('cia', 'strip', -1)) self.root = self.strip(self.repo.root) style = self.ui.config('cia', 'style') template = self.ui.config('cia', 'template') if not template: template = self.diffstat and self.dstemplate or self.deftemplate template = templater.parsestring(template, quoted=False) t = cmdutil.changeset_templater(self.ui, self.repo, False, None, style, False) t.use_template(template) self.templater = t
def maketemplater(ui, repo, tmpl): tmpl = templater.parsestring(tmpl, quoted=False) try: t = cmdutil.changeset_templater(ui, repo, False, None, tmpl, None, False) except SyntaxError, inst: raise util.Abort(inst.args[0])
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', 0)) root = util.pconvert(root) while count > 0: c = root.find('/') if c == -1: break root = root[c + 1:] count -= 1 return root mapfile = self.ui.config('bugzilla', 'style') tmpl = self.ui.config('bugzilla', 'template') t = cmdutil.changeset_templater(self.ui, self.repo, False, None, mapfile, False) if not mapfile and not tmpl: tmpl = _('changeset {node|short} in repo {root} refers ' 'to bug {bug}.\ndetails:\n\t{desc|tabindent}') if tmpl: tmpl = templater.parsestring(tmpl, quoted=False) t.use_template(tmpl) 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.updatebug(bugid, newstate, data, util.email(ctx.user()))
def kwsub(mobj): kw = mobj.group(1) ct = cmdutil.changeset_templater(self.ui, self.repo, False, None, self.templates[kw], '', False) self.ui.pushbuffer() ct.show(ctx, root=self.repo.root, file=path) ekw = templatefilters.firstline(self.ui.popbuffer()) return '$%s: %s $' % (kw, ekw)
def showwork(ui, repo, fm): """changesets that aren't finished""" # TODO support date-based limiting when calling revset. revs = repo.revs('sort(_underway(), topo)') revdag = graphmod.dagwalker(repo, revs) displayer = cmdutil.changeset_templater(ui, repo, None, None, tmpl=fm._t.load(fm._topic), mapfile=None, buffered=True) ui.setconfig('experimental', 'graphshorten', True) cmdutil.displaygraph(ui, repo, revdag, displayer, graphmod.asciiedges)
def __init__(self, ui, repo): self.ui = ui self.repo = repo self.match = match.match(repo.root, '', [], kwtools['inc'], kwtools['exc']) self.restrict = kwtools['hgcmd'] in restricted.split() kwmaps = self.ui.configitems('keywordmaps') if kwmaps: # override default templates self.templates = dict((k, templater.parsestring(v, False)) for k, v in kwmaps) escaped = map(re.escape, self.templates.keys()) kwpat = r'\$(%s)(: [^$\n\r]*? )??\$' % '|'.join(escaped) self.re_kw = re.compile(kwpat) templatefilters.filters['utcdate'] = utcdate self.ct = cmdutil.changeset_templater(self.ui, self.repo, False, None, '', False)
def __init__(self, ui, repo, inc, exc): self.ui = ui self.repo = repo self.matcher = util.matcher(repo.root, inc=inc, exc=exc)[1] self.restrict = kwtools['hgcmd'] in restricted.split() kwmaps = self.ui.configitems('keywordmaps') if kwmaps: # override default templates kwmaps = [(k, templater.parsestring(v, quoted=False)) for (k, v) in kwmaps] self.templates = dict(kwmaps) escaped = map(re.escape, self.templates.keys()) kwpat = r'\$(%s)(: [^$\n\r]*? )??\$' % '|'.join(escaped) self.re_kw = re.compile(kwpat) templatefilters.filters['utcdate'] = utcdate self.ct = cmdutil.changeset_templater(self.ui, self.repo, False, '', False)
def __init__(self, ui, repo): self.ui = ui self.repo = repo self.match = match.match(repo.root, '', [], kwtools['inc'], kwtools['exc']) self.restrict = kwtools['hgcmd'] in restricted.split() kwmaps = self.ui.configitems('keywordmaps') if kwmaps: # override default templates self.templates = dict( (k, templater.parsestring(v, False)) for k, v in kwmaps) escaped = map(re.escape, self.templates.keys()) kwpat = r'\$(%s)(: [^$\n\r]*? )??\$' % '|'.join(escaped) self.re_kw = re.compile(kwpat) templatefilters.filters['utcdate'] = utcdate self.ct = cmdutil.changeset_templater(self.ui, self.repo, False, None, '', False)
def __init__(self, ui, repo): self.ui = ui self.repo = repo self.ciaurl = self.ui.config("cia", "url", "http://cia.vc") self.user = self.ui.config("cia", "user") self.project = self.ui.config("cia", "project") self.module = self.ui.config("cia", "module") self.diffstat = self.ui.configbool("cia", "diffstat") self.emailfrom = self.ui.config("email", "from") self.dryrun = self.ui.configbool("cia", "test") self.url = self.ui.config("web", "baseurl") style = self.ui.config("cia", "style") template = self.ui.config("cia", "template") if not template: template = self.diffstat and self.dstemplate or self.deftemplate template = templater.parsestring(template, quoted=False) t = cmdutil.changeset_templater(self.ui, self.repo, False, None, style, False) t.use_template(template) self.templater = t
def __init__(self, ui, repo): self.ui = ui self.repo = repo self.ciaurl = self.ui.config("cia", "url", "http://cia.vc") self.user = self.ui.config("cia", "user") self.project = self.ui.config("cia", "project") self.module = self.ui.config("cia", "module") self.diffstat = self.ui.configbool("cia", "diffstat") self.emailfrom = self.ui.config("email", "from") self.dryrun = self.ui.configbool("cia", "test") self.url = self.ui.config("web", "baseurl") # Default to -1 for backward compatibility self.stripcount = int(self.ui.config("cia", "strip", -1)) self.root = self.strip(self.repo.root) style = self.ui.config("cia", "style") template = self.ui.config("cia", "template") if not template: template = self.diffstat and self.dstemplate or self.deftemplate template = templater.parsestring(template, quoted=False) t = cmdutil.changeset_templater(self.ui, self.repo, False, None, template, style, False) self.templater = t
def maketemplater(ui, repo, tmpl): return cmdutil.changeset_templater(ui, repo, False, None, tmpl, None, False)