Show More
@@ -107,7 +107,7 b' class kwtemplater(object):' | |||||
107 | self.ui = ui |
|
107 | self.ui = ui | |
108 | self.repo = repo |
|
108 | self.repo = repo | |
109 | self.matcher = util.matcher(repo.root, inc=inc, exc=exc)[1] |
|
109 | self.matcher = util.matcher(repo.root, inc=inc, exc=exc)[1] | |
110 | self.node = None |
|
110 | self.commitnode = None | |
111 | self.path = '' |
|
111 | self.path = '' | |
112 |
|
112 | |||
113 | kwmaps = self.ui.configitems('keywordmaps') |
|
113 | kwmaps = self.ui.configitems('keywordmaps') | |
@@ -124,18 +124,20 b' class kwtemplater(object):' | |||||
124 | False, '', False) |
|
124 | False, '', False) | |
125 |
|
125 | |||
126 | def substitute(self, node, data, subfunc): |
|
126 | def substitute(self, node, data, subfunc): | |
127 | '''Obtains node if missing, and calls given substitution function.''' |
|
127 | '''Obtains file's changenode if commit node not given, | |
128 | if not self.node: |
|
128 | and calls given substitution function.''' | |
|
129 | if self.commitnode: | |||
|
130 | fnode = self.commitnode | |||
|
131 | else: | |||
129 | c = context.filectx(self.repo, self.path, fileid=node) |
|
132 | c = context.filectx(self.repo, self.path, fileid=node) | |
130 |
|
|
133 | fnode = c.node() | |
131 |
|
134 | |||
132 | def kwsub(mobj): |
|
135 | def kwsub(mobj): | |
133 | '''Substitutes keyword using corresponding template.''' |
|
136 | '''Substitutes keyword using corresponding template.''' | |
134 | kw = mobj.group(1) |
|
137 | kw = mobj.group(1) | |
135 | self.ct.use_template(self.templates[kw]) |
|
138 | self.ct.use_template(self.templates[kw]) | |
136 | self.ui.pushbuffer() |
|
139 | self.ui.pushbuffer() | |
137 |
self.ct.show(changenode=self. |
|
140 | self.ct.show(changenode=fnode, root=self.repo.root, file=self.path) | |
138 | root=self.repo.root, file=self.path) |
|
|||
139 | return '$%s: %s $' % (kw, templater.firstline(self.ui.popbuffer())) |
|
141 | return '$%s: %s $' % (kw, templater.firstline(self.ui.popbuffer())) | |
140 |
|
142 | |||
141 | return subfunc(kwsub, data) |
|
143 | return subfunc(kwsub, data) | |
@@ -228,16 +230,16 b' def _overwrite(ui, repo, node=None, expa' | |||||
228 | '''Overwrites selected files expanding/shrinking keywords.''' |
|
230 | '''Overwrites selected files expanding/shrinking keywords.''' | |
229 | ctx = repo.changectx(node) |
|
231 | ctx = repo.changectx(node) | |
230 | mf = ctx.manifest() |
|
232 | mf = ctx.manifest() | |
231 |
if |
|
233 | if node is not None: # commit | |
232 | notify = ui.debug # commit |
|
234 | _kwtemplater.commitnode = node | |
233 | files = [f for f in ctx.files() if mf.has_key(f)] |
|
235 | files = [f for f in ctx.files() if mf.has_key(f)] | |
234 | else: |
|
236 | notify = ui.debug | |
235 |
|
|
237 | else: # kwexpand/kwshrink | |
|
238 | notify = ui.note | |||
236 | candidates = [f for f in files if _iskwfile(f, mf.linkf)] |
|
239 | candidates = [f for f in files if _iskwfile(f, mf.linkf)] | |
237 | if candidates: |
|
240 | if candidates: | |
238 | candidates.sort() |
|
241 | candidates.sort() | |
239 | action = expand and 'expanding' or 'shrinking' |
|
242 | action = expand and 'expanding' or 'shrinking' | |
240 | _kwtemplater.node = node or ctx.node() |
|
|||
241 | for f in candidates: |
|
243 | for f in candidates: | |
242 | fp = repo.file(f, kwmatch=True) |
|
244 | fp = repo.file(f, kwmatch=True) | |
243 | data, kwfound = fp.kwctread(mf[f], expand) |
|
245 | data, kwfound = fp.kwctread(mf[f], expand) |
General Comments 0
You need to be logged in to leave comments.
Login now