Mercurial > hg-stable
changeset 1913:74cf2b2f43d4
fix some things people wanted to be cleaner.
rename --map-file to --style.
no more -t alias for --template.
update docs.
rename template entry in map files to changelog.
if --verbose, use changelog_verbose if there, else changelog.
author | Vadim Gelfer <vadim.gelfer@gmail.com> |
---|---|
date | Sat, 04 Mar 2006 12:40:10 -0800 |
parents | b288b4bb8448 |
children | a5bf0030df5f |
files | doc/hg.1.txt mercurial/commands.py mercurial/templater.py templates/map-log.compact templates/map-log.verbose |
diffstat | 5 files changed, 48 insertions(+), 37 deletions(-) [+] |
line wrap: on
line diff
--- a/doc/hg.1.txt Tue Feb 28 07:24:54 2006 -0800 +++ b/doc/hg.1.txt Sat Mar 04 12:40:10 2006 -0800 @@ -296,9 +296,9 @@ options: -b, --branches show branches - --map-file <file> display using template map file -r, --rev <rev> show only heads which are descendants of rev - -t, --template <tpl> display using template + --style <style> display using style map file + --template <tpl> display using template identify:: Print a short summary of the current state of the repo. @@ -338,10 +338,10 @@ options: -M, --no-merges do not show merges - --map-file <file> display using template map file -n, --newest-first show newest records first -p, --patch show patch - -t, --template <tpl> display using template + --style <style> display using style map file + --template <tpl> display using template aliases: in @@ -389,12 +389,12 @@ -b, --branch show branches -k, --keyword <str> search for keywords -l, --limit <num> print no more than this many changes - --map-file <file> display using template map file -M, --no-merges do not show merges -m, --only-merges only show merges -r, --rev <A> show the specified revision or range -p, --patch show patch - -t, --template <tpl> display using template + --style <style> display using style map file + --template <tpl> display using template aliases: history @@ -413,10 +413,10 @@ options: -M, --no-merges do not show merges - --map-file <file> display using template map file -p, --patch show patch -n, --newest-first show newest records first - -t, --template <tpl> display using template + --style <style> display using style map file + --template <tpl> display using template aliases: out @@ -425,8 +425,8 @@ options: -b, --branches show branches - --map-file <file> display using template map file - -t, --template <tpl> display using template + --style <style> display using style map file + --template <tpl> display using template paths [NAME]:: Show definition of symbolic path name NAME. If no name is given, show @@ -635,9 +635,9 @@ options: -b, --branches show branches - --map-file <file> display using template map file -p, --patch show patch - -t, --template <tpl> display using template + --style <style> display using style map file + --template <tpl> display using template unbundle <file>:: (EXPERIMENTAL)
--- a/mercurial/commands.py Tue Feb 28 07:24:54 2006 -0800 +++ b/mercurial/commands.py Sat Mar 04 12:40:10 2006 -0800 @@ -341,13 +341,15 @@ '''use templater module to format changeset information.''' def __init__(self, ui, repo, mapfile): - self.t = templater.templater(mapfile, templater.common_filters) + self.t = templater.templater(mapfile, templater.common_filters, + cache={'parent': '{rev}:{node|short} ', + 'manifest': '{rev}:{node|short}'}) self.ui = ui self.repo = repo def use_template(self, t): '''set template string to use''' - self.t.cache['template'] = t + self.t.cache['changelog'] = t def write(self, thing): '''write expanded template. @@ -396,7 +398,11 @@ yield self.t(noname, **args) return if name not in self.t: - yield ' '.join(values) + if isinstance(values[0], str): + yield ' '.join(values) + else: + for v in values: + yield dict(v, **args) return startname = 'start_' + names if startname in self.t: @@ -483,7 +489,11 @@ } try: - self.write(self.t('template', **props)) + if self.ui.verbose and 'changelog_verbose' in self.t: + key = 'changelog_verbose' + else: + key = 'changelog' + self.write(self.t(key, **props)) except KeyError, inst: raise util.Abort(_("%s: no key named '%s'") % (self.t.mapfile, inst.args[0])) @@ -560,7 +570,7 @@ def show_changeset(ui, repo, opts): '''show one changeset. uses template or regular display. caller - can pass in 'map_file' and 'template' options in opts.''' + can pass in 'style' and 'template' options in opts.''' tmpl = opts.get('template') if tmpl: @@ -568,7 +578,7 @@ else: tmpl = ui.config('ui', 'logtemplate') if tmpl: tmpl = templater.parsestring(tmpl) - mapfile = opts.get('map_file') or ui.config('ui', 'logmap') + mapfile = opts.get('style') or ui.config('ui', 'logmap') if tmpl or mapfile: if mapfile: if not os.path.isfile(mapfile): @@ -2655,9 +2665,9 @@ "heads": (heads, [('b', 'branches', None, _('show branches')), - ('', 'map-file', '', _('display using template map file')), + ('', 'style', '', _('display using template map file')), ('r', 'rev', '', _('show only heads which are descendants of rev')), - ('t', 'template', '', _('display with template'))], + ('', 'template', '', _('display with template'))], _('hg heads [-b] [-r <rev>]')), "help": (help_, [], _('hg help [COMMAND]')), "identify|id": (identify, [], _('hg identify')), @@ -2672,10 +2682,10 @@ _('hg import [-f] [-p NUM] [-b BASE] PATCH...')), "incoming|in": (incoming, [('M', 'no-merges', None, _('do not show merges')), - ('', 'map-file', '', _('display using template map file')), + ('', 'style', '', _('display using template map file')), ('n', 'newest-first', None, _('show newest record first')), ('p', 'patch', None, _('show patch')), - ('t', 'template', '', _('display with template'))], + ('', 'template', '', _('display with template'))], _('hg incoming [-p] [-n] [-M] [SOURCE]')), "^init": (init, [], _('hg init [DEST]')), "locate": @@ -2697,24 +2707,24 @@ ('l', 'limit', '', _('limit number of changes displayed')), ('r', 'rev', [], _('show the specified revision or range')), ('M', 'no-merges', None, _('do not show merges')), - ('', 'map-file', '', _('display using template map file')), + ('', 'style', '', _('display using template map file')), ('m', 'only-merges', None, _('show only merges')), ('p', 'patch', None, _('show patch')), - ('t', 'template', '', _('display with template'))], + ('', 'template', '', _('display with template'))], _('hg log [-I] [-X] [-r REV]... [-p] [FILE]')), "manifest": (manifest, [], _('hg manifest [REV]')), "outgoing|out": (outgoing, [('M', 'no-merges', None, _('do not show merges')), ('p', 'patch', None, _('show patch')), - ('', 'map-file', '', _('display using template map file')), + ('', 'style', '', _('display using template map file')), ('n', 'newest-first', None, _('show newest record first')), - ('t', 'template', '', _('display with template'))], + ('', 'template', '', _('display with template'))], _('hg outgoing [-p] [-n] [-M] [DEST]')), "^parents": (parents, [('b', 'branches', None, _('show branches')), - ('', 'map-file', '', _('display using template map file')), - ('t', 'template', '', _('display with template'))], + ('', 'style', '', _('display using template map file')), + ('', 'template', '', _('display with template'))], _('hg parents [-b] [REV]')), "paths": (paths, [], _('hg paths [NAME]')), "^pull": @@ -2776,7 +2786,7 @@ _('name to show in web pages (default: working dir)')), ('', 'pid-file', '', _('name of file to write process ID to')), ('', 'stdio', None, _('for remote clients')), - ('t', 'templates', '', _('web templates to use')), + ('', 'templates', '', _('web templates to use')), ('', 'style', '', _('template style to use')), ('6', 'ipv6', None, _('use IPv6 in addition to IPv4'))], _('hg serve [OPTION]...')), @@ -2805,9 +2815,9 @@ "tip": (tip, [('b', 'branches', None, _('show branches')), - ('', 'map-file', '', _('display using template map file')), + ('', 'style', '', _('display using template map file')), ('p', 'patch', None, _('show patch')), - ('t', 'template', '', _('display with template'))], + ('', 'template', '', _('display with template'))], _('hg [-b] [-p] tip')), "unbundle": (unbundle, @@ -2818,11 +2828,11 @@ "^update|up|checkout|co": (update, [('b', 'branch', '', _('checkout the head of a specific branch')), - ('', 'map-file', '', _('display using template map file')), + ('', 'style', '', _('display using template map file')), ('m', 'merge', None, _('allow merging of branches')), ('C', 'clean', None, _('overwrite locally modified files')), ('f', 'force', None, _('force a merge with outstanding changes')), - ('t', 'template', '', _('display with template'))], + ('', 'template', '', _('display with template'))], _('hg update [-b TAG] [-m] [-C] [-f] [REV]')), "verify": (verify, [], _('hg verify')), "version": (show_version, [], _('hg version')),
--- a/mercurial/templater.py Tue Feb 28 07:24:54 2006 -0800 +++ b/mercurial/templater.py Sat Mar 04 12:40:10 2006 -0800 @@ -59,7 +59,7 @@ filter uses function to transform value. syntax is {key|filter1|filter2|...}.''' - def __init__(self, mapfile, filters={}, defaults={}): + def __init__(self, mapfile, filters={}, cache={}): '''set up template engine. mapfile is name of file to read map definitions from. filters is dict of functions. each transforms a value into another. @@ -69,7 +69,8 @@ self.map = {} self.base = (mapfile and os.path.dirname(mapfile)) or '' self.filters = filters - self.defaults = defaults + self.defaults = {} + self.cache = cache if not mapfile: return
--- a/templates/map-log.compact Tue Feb 28 07:24:54 2006 -0800 +++ b/templates/map-log.compact Sat Mar 04 12:40:10 2006 -0800 @@ -1,4 +1,4 @@ -template = '{rev}{tags}{parents} {node|short} {date|isodate} {author|user}\n {desc|firstline|strip}\n\n' +changelog = '{rev}{tags}{parents} {node|short} {date|isodate} {author|user}\n {desc|firstline|strip}\n\n' start_tags = '[' tag = '{tag},' last_tag = '{tag}]'
--- a/templates/map-log.verbose Tue Feb 28 07:24:54 2006 -0800 +++ b/templates/map-log.verbose Sat Mar 04 12:40:10 2006 -0800 @@ -1,4 +1,4 @@ -template = 'changeset: {rev}:{node}\n{tags}{parents}{manifest}user: {author}\ndate: {date|date}\nfiles: {files}\n{file_adds}{file_dels}description:\n{desc|strip}\n\n\n' +changelog = 'changeset: {rev}:{node}\n{tags}{parents}{manifest}user: {author}\ndate: {date|date}\nfiles: {files}\n{file_adds}{file_dels}description:\n{desc|strip}\n\n\n' start_file_adds = 'files+: ' file_add = ' {file_add}' end_file_adds = '\n'