diff -r 3e57838f5434 -r f7b34429edb7 hgkw/keyword.py --- a/hgkw/keyword.py Mon Oct 25 19:21:06 2010 +0100 +++ b/hgkw/keyword.py Mon Oct 25 19:21:06 2010 +0100 @@ -205,10 +205,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.rekw().sub) return data @@ -226,7 +230,7 @@ kwcmd = self.restrict and lookup # kwexpand/kwshrink if self.restrict or expand and lookup: mf = ctx.manifest() - fctx = ctx + lctx = ctx re_kw = (self.restrict or rekw) and self.rekw() or self.rekwexp() msg = (expand and _('overwriting %s expanding keywords\n') or _('overwriting %s shrinking keywords\n')) @@ -239,8 +243,8 @@ continue if expand: if lookup: - fctx = self.repo.filectx(f, fileid=mf[f]).changectx() - data, found = self.substitute(data, f, fctx, re_kw.subn) + lctx = self.linkctx(f, mf[f]) + data, found = self.substitute(data, f, lctx, re_kw.subn) elif self.restrict: found = re_kw.search(data) else: