203 ct.show(ctx, root=self.repo.root, file=path) |
203 ct.show(ctx, root=self.repo.root, file=path) |
204 ekw = templatefilters.firstline(self.ui.popbuffer()) |
204 ekw = templatefilters.firstline(self.ui.popbuffer()) |
205 return '$%s: %s $' % (kw, ekw) |
205 return '$%s: %s $' % (kw, ekw) |
206 return subfunc(kwsub, data) |
206 return subfunc(kwsub, data) |
207 |
207 |
|
208 def linkctx(self, path, fileid): |
|
209 '''Similar to filelog.linkrev, but returns a changectx.''' |
|
210 return self.repo.filectx(path, fileid=fileid).changectx() |
|
211 |
208 def expand(self, path, node, data): |
212 def expand(self, path, node, data): |
209 '''Returns data with keywords expanded.''' |
213 '''Returns data with keywords expanded.''' |
210 if not self.restrict and self.match(path) and not util.binary(data): |
214 if not self.restrict and self.match(path) and not util.binary(data): |
211 ctx = self.repo.filectx(path, fileid=node).changectx() |
215 ctx = self.linkctx(path, node) |
212 return self.substitute(data, path, ctx, self.rekw().sub) |
216 return self.substitute(data, path, ctx, self.rekw().sub) |
213 return data |
217 return data |
214 |
218 |
215 def iskwfile(self, cand, ctx): |
219 def iskwfile(self, cand, ctx): |
216 '''Returns subset of candidates which are configured for keyword |
220 '''Returns subset of candidates which are configured for keyword |
224 if not candidates: |
228 if not candidates: |
225 return |
229 return |
226 kwcmd = self.restrict and lookup # kwexpand/kwshrink |
230 kwcmd = self.restrict and lookup # kwexpand/kwshrink |
227 if self.restrict or expand and lookup: |
231 if self.restrict or expand and lookup: |
228 mf = ctx.manifest() |
232 mf = ctx.manifest() |
229 fctx = ctx |
233 lctx = ctx |
230 re_kw = (self.restrict or rekw) and self.rekw() or self.rekwexp() |
234 re_kw = (self.restrict or rekw) and self.rekw() or self.rekwexp() |
231 msg = (expand and _('overwriting %s expanding keywords\n') |
235 msg = (expand and _('overwriting %s expanding keywords\n') |
232 or _('overwriting %s shrinking keywords\n')) |
236 or _('overwriting %s shrinking keywords\n')) |
233 for f in candidates: |
237 for f in candidates: |
234 if self.restrict: |
238 if self.restrict: |
237 data = self.repo.wread(f) |
241 data = self.repo.wread(f) |
238 if util.binary(data): |
242 if util.binary(data): |
239 continue |
243 continue |
240 if expand: |
244 if expand: |
241 if lookup: |
245 if lookup: |
242 fctx = self.repo.filectx(f, fileid=mf[f]).changectx() |
246 lctx = self.linkctx(f, mf[f]) |
243 data, found = self.substitute(data, f, fctx, re_kw.subn) |
247 data, found = self.substitute(data, f, lctx, re_kw.subn) |
244 elif self.restrict: |
248 elif self.restrict: |
245 found = re_kw.search(data) |
249 found = re_kw.search(data) |
246 else: |
250 else: |
247 data, found = _shrinktext(data, re_kw.subn) |
251 data, found = _shrinktext(data, re_kw.subn) |
248 if found: |
252 if found: |