comparison mercurial/cmdutil.py @ 10061:9e2ab10728a2

Make {file_copies} usable as a --template key Before this, to display file copies in templates, you had to write something like {file_copies%filecopy}. For some reason, the {file_copy} subtemplate was used by default but not defined by default in changeset_templater, while styles were already using it. Here we define {file_copy} in changeset_templater, and change the templater to handle formatting strings like {file_copies%filecopy} with already expanded keys (in this case {file_copies}), for backward compatibility.
author Patrick Mezard <pmezard@gmail.com>
date Sun, 13 Dec 2009 18:06:24 +0100
parents f780b1098efc
children 27457d31ae3f
comparison
equal deleted inserted replaced
10060:f780b1098efc 10061:9e2ab10728a2
755 '''format changeset information.''' 755 '''format changeset information.'''
756 756
757 def __init__(self, ui, repo, patch, diffopts, mapfile, buffered): 757 def __init__(self, ui, repo, patch, diffopts, mapfile, buffered):
758 changeset_printer.__init__(self, ui, repo, patch, diffopts, buffered) 758 changeset_printer.__init__(self, ui, repo, patch, diffopts, buffered)
759 formatnode = ui.debugflag and (lambda x: x) or (lambda x: x[:12]) 759 formatnode = ui.debugflag and (lambda x: x) or (lambda x: x[:12])
760 defaulttempl = {
761 'parent': '{rev}:{node|formatnode} ',
762 'manifest': '{rev}:{node|formatnode}',
763 'file_copy': '{name} ({source})',
764 'extra': '{key}={value|stringescape}'
765 }
766 # filecopy is preserved for compatibility reasons
767 defaulttempl['filecopy'] = defaulttempl['file_copy']
760 self.t = templater.templater(mapfile, {'formatnode': formatnode}, 768 self.t = templater.templater(mapfile, {'formatnode': formatnode},
761 cache={ 769 cache=defaulttempl)
762 'parent': '{rev}:{node|formatnode} ',
763 'manifest': '{rev}:{node|formatnode}',
764 'filecopy': '{name} ({source})',
765 'extra': '{key}={value|stringescape}'})
766 self.cache = {} 770 self.cache = {}
767 771
768 def use_template(self, t): 772 def use_template(self, t):
769 '''set template string to use''' 773 '''set template string to use'''
770 self.t.cache['changeset'] = t 774 self.t.cache['changeset'] = t