def lookuptemplate(ui, topic, tmpl): # looks like a literal template? if '{' in tmpl: return tmpl, None # perhaps a stock style? if not os.path.split(tmpl)[0]: mapname = (templater.templatepath('map-cmdline.' + tmpl) or templater.templatepath(tmpl)) if mapname and os.path.isfile(mapname): return None, mapname # perhaps it's a reference to [templates] t = ui.config('templates', tmpl) if t: try: tmpl = templater.unquotestring(t) except SyntaxError: tmpl = t return tmpl, None if tmpl == 'list': ui.write(_("available styles: %s\n") % templater.stylelist()) raise util.Abort(_("specify a template")) # perhaps it's a path to a map or a template if ('/' in tmpl or '\\' in tmpl) and os.path.isfile(tmpl): # is it a mapfile for a style? if os.path.basename(tmpl).startswith("map-"): return None, os.path.realpath(tmpl) tmpl = open(tmpl).read() return tmpl, None # constant string? return tmpl, None
def show_changeset(ui, repo, opts, buffered=False, matchfn=False): """show one changeset using template or regular display. Display format will be the first non-empty hit of: 1. option 'template' 2. option 'style' 3. [ui] setting 'logtemplate' 4. [ui] setting 'style' If all of these values are either the unset or the empty string, regular display via changeset_printer() is done. """ # options patch = False if opts.get('patch'): patch = matchfn or matchall(repo) tmpl = opts.get('template') style = None if tmpl: tmpl = templater.parsestring(tmpl, quoted=False) else: style = opts.get('style') # ui settings if not (tmpl or style): tmpl = ui.config('ui', 'logtemplate') if tmpl: tmpl = templater.parsestring(tmpl) else: style = util.expandpath(ui.config('ui', 'style', '')) if not (tmpl or style): return changeset_printer(ui, repo, patch, opts, buffered) mapfile = None if style and not tmpl: mapfile = style if not os.path.split(mapfile)[0]: mapname = (templater.templatepath('map-cmdline.' + mapfile) or templater.templatepath(mapfile)) if mapname: mapfile = mapname try: t = changeset_templater(ui, repo, patch, opts, mapfile, buffered) except SyntaxError, inst: raise util.Abort(inst.args[0])
def show_changeset(ui, repo, opts, buffered=False): """show one changeset using template or regular display. Display format will be the first non-empty hit of: 1. option 'template' 2. option 'style' 3. [ui] setting 'logtemplate' 4. [ui] setting 'style' If all of these values are either the unset or the empty string, regular display via changeset_printer() is done. """ # options patch = False if opts.get('patch') or opts.get('stat'): patch = matchall(repo) tmpl = opts.get('template') style = None if tmpl: tmpl = templater.parsestring(tmpl, quoted=False) else: style = opts.get('style') # ui settings if not (tmpl or style): tmpl = ui.config('ui', 'logtemplate') if tmpl: tmpl = templater.parsestring(tmpl) else: style = util.expandpath(ui.config('ui', 'style', '')) if not (tmpl or style): return changeset_printer(ui, repo, patch, opts, buffered) mapfile = None if style and not tmpl: mapfile = style if not os.path.split(mapfile)[0]: mapname = (templater.templatepath('map-cmdline.' + mapfile) or templater.templatepath(mapfile)) if mapname: mapfile = mapname try: t = changeset_templater(ui, repo, patch, opts, mapfile, buffered) except SyntaxError, inst: raise util.Abort(inst.args[0])