# HG changeset patch # User Christian Ebert # Date 1226700060 -3600 # Node ID 7d5c8c734b746ae5e40c5e0002cba007c693d449 # Parent 5cf987b0f3a1da6e430113ac6e18ef2e10daad31# Parent a93358a05b8034a7ccc0961d10826eac99bdbcdf Merge with stable diff -r 5cf987b0f3a1 -r 7d5c8c734b74 hgkw/keyword.py --- a/hgkw/keyword.py Mon Nov 03 23:16:39 2008 +0100 +++ b/hgkw/keyword.py Fri Nov 14 23:01:00 2008 +0100 @@ -141,19 +141,13 @@ self.ct = cmdutil.changeset_templater(self.ui, self.repo, False, '', False) - def getnode(self, path, fnode): - '''Derives changenode from file path and filenode.''' - # used by kwfilelog.read and kwexpand - c = self.repo.filectx(path, fileid=fnode) - return c.node() - - def substitute(self, data, path, node, subfunc): + def substitute(self, data, path, ctx, subfunc): '''Replaces keywords in data with expanded template.''' def kwsub(mobj): kw = mobj.group(1) self.ct.use_template(self.templates[kw]) self.ui.pushbuffer() - self.ct.show(changenode=node, root=self.repo.root, file=path) + self.ct.show(ctx, root=self.repo.root, file=path) ekw = templatefilters.firstline(self.ui.popbuffer()) return '$%s: %s $' % (kw, ekw) return subfunc(kwsub, data) @@ -161,8 +155,8 @@ def expand(self, path, node, data): '''Returns data with keywords expanded.''' if not self.restrict and self.matcher(path) and not util.binary(data): - changenode = self.getnode(path, node) - return self.substitute(data, path, changenode, self.re_kw.sub) + ctx = self.repo.filectx(path, fileid=node).changectx() + return self.substitute(data, path, ctx, self.re_kw.sub) return data def iskwfile(self, path, flagfunc): @@ -179,7 +173,7 @@ files = [f for f in ctx.files() if f in mf] notify = self.ui.debug else: # kwexpand/kwshrink - ctx = self.repo['.'] + ctx = self.repo[None] mf = ctx.manifest() notify = self.ui.note candidates = [f for f in files if self.iskwfile(f, ctx.flags)] @@ -192,8 +186,9 @@ if util.binary(data): continue if expand: - changenode = node or self.getnode(f, mf[f]) - data, found = self.substitute(data, f, changenode, + if node is None: + ctx = self.repo.filectx(f, fileid=mf[f]).changectx() + data, found = self.substitute(data, f, ctx, self.re_kw.subn) else: found = self.re_kw.search(data)