Show More
@@ -139,19 +139,13 b' class kwtemplater(object):' | |||
|
139 | 139 | self.ct = cmdutil.changeset_templater(self.ui, self.repo, |
|
140 | 140 | False, '', False) |
|
141 | 141 | |
|
142 |
def |
|
|
143 | '''Derives changenode from file path and filenode.''' | |
|
144 | # used by kwfilelog.read and kwexpand | |
|
145 | c = self.repo.filectx(path, fileid=fnode) | |
|
146 | return c.node() | |
|
147 | ||
|
148 | def substitute(self, data, path, node, subfunc): | |
|
142 | def substitute(self, data, path, ctx, subfunc): | |
|
149 | 143 | '''Replaces keywords in data with expanded template.''' |
|
150 | 144 | def kwsub(mobj): |
|
151 | 145 | kw = mobj.group(1) |
|
152 | 146 | self.ct.use_template(self.templates[kw]) |
|
153 | 147 | self.ui.pushbuffer() |
|
154 |
self.ct.show( |
|
|
148 | self.ct.show(ctx, root=self.repo.root, file=path) | |
|
155 | 149 | ekw = templatefilters.firstline(self.ui.popbuffer()) |
|
156 | 150 | return '$%s: %s $' % (kw, ekw) |
|
157 | 151 | return subfunc(kwsub, data) |
@@ -159,8 +153,8 b' class kwtemplater(object):' | |||
|
159 | 153 | def expand(self, path, node, data): |
|
160 | 154 | '''Returns data with keywords expanded.''' |
|
161 | 155 | if not self.restrict and self.matcher(path) and not util.binary(data): |
|
162 |
c |
|
|
163 |
return self.substitute(data, path, c |
|
|
156 | ctx = self.repo.filectx(path, fileid=node).changectx() | |
|
157 | return self.substitute(data, path, ctx, self.re_kw.sub) | |
|
164 | 158 | return data |
|
165 | 159 | |
|
166 | 160 | def iskwfile(self, path, flagfunc): |
@@ -177,7 +171,7 b' class kwtemplater(object):' | |||
|
177 | 171 | files = [f for f in ctx.files() if f in mf] |
|
178 | 172 | notify = self.ui.debug |
|
179 | 173 | else: # kwexpand/kwshrink |
|
180 |
ctx = self.repo[ |
|
|
174 | ctx = self.repo[None] | |
|
181 | 175 | mf = ctx.manifest() |
|
182 | 176 | notify = self.ui.note |
|
183 | 177 | candidates = [f for f in files if self.iskwfile(f, ctx.flags)] |
@@ -190,8 +184,9 b' class kwtemplater(object):' | |||
|
190 | 184 | if util.binary(data): |
|
191 | 185 | continue |
|
192 | 186 | if expand: |
|
193 | changenode = node or self.getnode(f, mf[f]) | |
|
194 | data, found = self.substitute(data, f, changenode, | |
|
187 | if node is None: | |
|
188 | ctx = self.repo.filectx(f, fileid=mf[f]).changectx() | |
|
189 | data, found = self.substitute(data, f, ctx, | |
|
195 | 190 | self.re_kw.subn) |
|
196 | 191 | else: |
|
197 | 192 | found = self.re_kw.search(data) |
General Comments 0
You need to be logged in to leave comments.
Login now