Mercurial > hg-stable
changeset 5823:2a66138c5e7e
keyword: (bugfix) only set changenode for kwtemplater when committing
kwexpand must always obtain changenode from filectx,
otherwise current changenode is expanded in every file.
Also fixes "hg cat <more than 1 file>".
author | Christian Ebert <blacktrash@gmx.net> |
---|---|
date | Wed, 09 Jan 2008 05:18:50 +0100 |
parents | 38b592536a58 |
children | b8e8bd3c82f6 |
files | hgext/keyword.py |
diffstat | 1 files changed, 13 insertions(+), 11 deletions(-) [+] |
line wrap: on
line diff
--- a/hgext/keyword.py Tue Jan 08 06:56:21 2008 +0300 +++ b/hgext/keyword.py Wed Jan 09 05:18:50 2008 +0100 @@ -107,7 +107,7 @@ self.ui = ui self.repo = repo self.matcher = util.matcher(repo.root, inc=inc, exc=exc)[1] - self.node = None + self.commitnode = None self.path = '' kwmaps = self.ui.configitems('keywordmaps') @@ -124,18 +124,20 @@ False, '', False) def substitute(self, node, data, subfunc): - '''Obtains node if missing, and calls given substitution function.''' - if not self.node: + '''Obtains file's changenode if commit node not given, + and calls given substitution function.''' + if self.commitnode: + fnode = self.commitnode + else: c = context.filectx(self.repo, self.path, fileid=node) - self.node = c.node() + fnode = c.node() def kwsub(mobj): '''Substitutes keyword using corresponding template.''' kw = mobj.group(1) self.ct.use_template(self.templates[kw]) self.ui.pushbuffer() - self.ct.show(changenode=self.node, - root=self.repo.root, file=self.path) + self.ct.show(changenode=fnode, root=self.repo.root, file=self.path) return '$%s: %s $' % (kw, templater.firstline(self.ui.popbuffer())) return subfunc(kwsub, data) @@ -228,16 +230,16 @@ '''Overwrites selected files expanding/shrinking keywords.''' ctx = repo.changectx(node) mf = ctx.manifest() - if files is None: - notify = ui.debug # commit + if node is not None: # commit + _kwtemplater.commitnode = node files = [f for f in ctx.files() if mf.has_key(f)] - else: - notify = ui.note # kwexpand/kwshrink + notify = ui.debug + else: # kwexpand/kwshrink + notify = ui.note candidates = [f for f in files if _iskwfile(f, mf.linkf)] if candidates: candidates.sort() action = expand and 'expanding' or 'shrinking' - _kwtemplater.node = node or ctx.node() for f in candidates: fp = repo.file(f, kwmatch=True) data, kwfound = fp.kwctread(mf[f], expand)