111 self.ui = ui |
111 self.ui = ui |
112 self.repo = repo |
112 self.repo = repo |
113 self.t = expand or None |
113 self.t = expand or None |
114 self.path = path |
114 self.path = path |
115 self.node = node |
115 self.node = node |
116 self.debug = self.ui.debugflag |
|
117 |
116 |
118 kwmaps = self.ui.configitems('keywordmaps') |
117 kwmaps = self.ui.configitems('keywordmaps') |
119 if kwmaps: # override default templates |
118 if kwmaps: # override default templates |
120 kwmaps = [(k, templater.parsestring(v, quoted=False)) |
119 kwmaps = [(k, templater.parsestring(v, quoted=False)) |
121 for (k, v) in kwmaps] |
120 for (k, v) in kwmaps] |
136 self.t.show(changenode=self.node, root=self.repo.root, file=self.path) |
135 self.t.show(changenode=self.node, root=self.repo.root, file=self.path) |
137 keywordsub = templater.firstline(self.ui.popbuffer()) |
136 keywordsub = templater.firstline(self.ui.popbuffer()) |
138 return '$%s: %s $' % (kw, keywordsub) |
137 return '$%s: %s $' % (kw, keywordsub) |
139 |
138 |
140 def substitute(self, node, data, subfunc): |
139 def substitute(self, node, data, subfunc): |
141 '''Obtains node if missing. |
140 '''Obtains node if missing, and calls given substitution function.''' |
142 Ensures consistent templates regardless of ui.debugflag. |
|
143 Calls given substitution function.''' |
|
144 if not self.node: |
141 if not self.node: |
145 c = context.filectx(self.repo, self.path, fileid=node) |
142 c = context.filectx(self.repo, self.path, fileid=node) |
146 self.node = c.node() |
143 self.node = c.node() |
147 self.ui.debugflag = False |
144 return subfunc(self.kwsub, data) |
148 result = subfunc(self.kwsub, data) |
|
149 self.ui.debugflag = self.debug |
|
150 return result |
|
151 |
145 |
152 def expand(self, node, data): |
146 def expand(self, node, data): |
153 '''Returns data with keywords expanded.''' |
147 '''Returns data with keywords expanded.''' |
154 if util.binary(data): |
148 if util.binary(data): |
155 return data |
149 return data |