Mercurial > public > mercurial-scm > hg-stable
comparison mercurial/cmdutil.py @ 31181:1ec89cf0ea49
templatekw: move defaulttmpl constant from changeset_templater
These templates are used when rendering inner lists of some template keywords,
so it makes sense to define them in templatekw. This allows us to reuse them
to create a templateformatter knowing changectx.
author | Yuya Nishihara <yuya@tcha.org> |
---|---|
date | Sat, 25 Feb 2017 16:38:26 +0900 |
parents | 48a8b2e5fe31 |
children | 3af9a9628ecf |
comparison
equal
deleted
inserted
replaced
31180:e64b70c96338 | 31181:1ec89cf0ea49 |
---|---|
1440 class changeset_templater(changeset_printer): | 1440 class changeset_templater(changeset_printer): |
1441 '''format changeset information.''' | 1441 '''format changeset information.''' |
1442 | 1442 |
1443 def __init__(self, ui, repo, matchfn, diffopts, tmpl, mapfile, buffered): | 1443 def __init__(self, ui, repo, matchfn, diffopts, tmpl, mapfile, buffered): |
1444 changeset_printer.__init__(self, ui, repo, matchfn, diffopts, buffered) | 1444 changeset_printer.__init__(self, ui, repo, matchfn, diffopts, buffered) |
1445 defaulttempl = { | |
1446 'parent': '{rev}:{node|formatnode} ', | |
1447 'manifest': '{rev}:{node|formatnode}', | |
1448 'file_copy': '{name} ({source})', | |
1449 'envvar': '{key}={value}', | |
1450 'extra': '{key}={value|stringescape}' | |
1451 } | |
1452 # filecopy is preserved for compatibility reasons | |
1453 defaulttempl['filecopy'] = defaulttempl['file_copy'] | |
1454 assert not (tmpl and mapfile) | 1445 assert not (tmpl and mapfile) |
1446 defaulttempl = templatekw.defaulttempl | |
1455 if mapfile: | 1447 if mapfile: |
1456 self.t = templater.templater.frommapfile(mapfile, | 1448 self.t = templater.templater.frommapfile(mapfile, |
1457 cache=defaulttempl) | 1449 cache=defaulttempl) |
1458 else: | 1450 else: |
1459 self.t = formatter.maketemplater(ui, 'changeset', tmpl, | 1451 self.t = formatter.maketemplater(ui, 'changeset', tmpl, |