Mercurial > hg-stable
changeset 12920:1fab4970354e
keyword: function to look up changectx for expansion
Similarly rename variable in kwtemplater.overwrite().
author | Christian Ebert <blacktrash@gmx.net> |
---|---|
date | Wed, 03 Nov 2010 14:37:41 +0100 |
parents | 0071c8fc2fa6 |
children | 6b6e7da9bccd |
files | hgext/keyword.py |
diffstat | 1 files changed, 8 insertions(+), 4 deletions(-) [+] |
line wrap: on
line diff
--- a/hgext/keyword.py Tue Nov 02 11:25:52 2010 +0100 +++ b/hgext/keyword.py Wed Nov 03 14:37:41 2010 +0100 @@ -191,10 +191,14 @@ return '$%s: %s $' % (kw, ekw) return subfunc(kwsub, data) + def linkctx(self, path, fileid): + '''Similar to filelog.linkrev, but returns a changectx.''' + return self.repo.filectx(path, fileid=fileid).changectx() + def expand(self, path, node, data): '''Returns data with keywords expanded.''' if not self.restrict and self.match(path) and not util.binary(data): - ctx = self.repo.filectx(path, fileid=node).changectx() + ctx = self.linkctx(path, node) return self.substitute(data, path, ctx, self.re_kw.sub) return data @@ -212,7 +216,7 @@ kwcmd = self.restrict and lookup # kwexpand/kwshrink if self.restrict or expand and lookup: mf = ctx.manifest() - fctx = ctx + lctx = ctx subn = (self.restrict or rekw) and self.re_kw.subn or self.re_kwexp.subn msg = (expand and _('overwriting %s expanding keywords\n') or _('overwriting %s shrinking keywords\n')) @@ -225,8 +229,8 @@ continue if expand: if lookup: - fctx = self.repo.filectx(f, fileid=mf[f]).changectx() - data, found = self.substitute(data, f, fctx, subn) + lctx = self.linkctx(f, mf[f]) + data, found = self.substitute(data, f, lctx, subn) elif self.restrict: found = self.re_kw.search(data) else: