Show More
@@ -125,7 +125,7 b' class kwtemplater(object):' | |||||
125 | def __init__(self, ui, repo): |
|
125 | def __init__(self, ui, repo): | |
126 | self.ui = ui |
|
126 | self.ui = ui | |
127 | self.repo = repo |
|
127 | self.repo = repo | |
128 |
self.match |
|
128 | self.match = match.match(repo.root, '', [], | |
129 |
|
|
129 | kwtools['inc'], kwtools['exc']) | |
130 | self.restrict = kwtools['hgcmd'] in restricted.split() |
|
130 | self.restrict = kwtools['hgcmd'] in restricted.split() | |
131 |
|
131 | |||
@@ -155,7 +155,7 b' class kwtemplater(object):' | |||||
155 |
|
155 | |||
156 | def expand(self, path, node, data): |
|
156 | def expand(self, path, node, data): | |
157 | '''Returns data with keywords expanded.''' |
|
157 | '''Returns data with keywords expanded.''' | |
158 |
if not self.restrict and self.match |
|
158 | if not self.restrict and self.match(path) and not util.binary(data): | |
159 | ctx = self.repo.filectx(path, fileid=node).changectx() |
|
159 | ctx = self.repo.filectx(path, fileid=node).changectx() | |
160 | return self.substitute(data, path, ctx, self.re_kw.sub) |
|
160 | return self.substitute(data, path, ctx, self.re_kw.sub) | |
161 | return data |
|
161 | return data | |
@@ -164,7 +164,7 b' class kwtemplater(object):' | |||||
164 | '''Returns true if path matches [keyword] pattern |
|
164 | '''Returns true if path matches [keyword] pattern | |
165 | and is not a symbolic link. |
|
165 | and is not a symbolic link. | |
166 | Caveat: localrepository._link fails on Windows.''' |
|
166 | Caveat: localrepository._link fails on Windows.''' | |
167 |
return self.match |
|
167 | return self.match(path) and not 'l' in flagfunc(path) | |
168 |
|
168 | |||
169 | def overwrite(self, node, expand, files): |
|
169 | def overwrite(self, node, expand, files): | |
170 | '''Overwrites selected files expanding/shrinking keywords.''' |
|
170 | '''Overwrites selected files expanding/shrinking keywords.''' | |
@@ -204,13 +204,13 b' class kwtemplater(object):' | |||||
204 |
|
204 | |||
205 | def shrink(self, fname, text): |
|
205 | def shrink(self, fname, text): | |
206 | '''Returns text with all keyword substitutions removed.''' |
|
206 | '''Returns text with all keyword substitutions removed.''' | |
207 |
if self.match |
|
207 | if self.match(fname) and not util.binary(text): | |
208 | return self.shrinktext(text) |
|
208 | return self.shrinktext(text) | |
209 | return text |
|
209 | return text | |
210 |
|
210 | |||
211 | def shrinklines(self, fname, lines): |
|
211 | def shrinklines(self, fname, lines): | |
212 | '''Returns lines with keyword substitutions removed.''' |
|
212 | '''Returns lines with keyword substitutions removed.''' | |
213 |
if self.match |
|
213 | if self.match(fname): | |
214 | text = ''.join(lines) |
|
214 | text = ''.join(lines) | |
215 | if not util.binary(text): |
|
215 | if not util.binary(text): | |
216 | return self.shrinktext(text).splitlines(True) |
|
216 | return self.shrinktext(text).splitlines(True) | |
@@ -253,8 +253,8 b' def _status(ui, repo, kwt, unknown, *pat' | |||||
253 | '''Bails out if [keyword] configuration is not active. |
|
253 | '''Bails out if [keyword] configuration is not active. | |
254 | Returns status of working directory.''' |
|
254 | Returns status of working directory.''' | |
255 | if kwt: |
|
255 | if kwt: | |
256 |
match |
|
256 | match = cmdutil.match(repo, pats, opts) | |
257 |
return repo.status(match=match |
|
257 | return repo.status(match=match, unknown=unknown, clean=True) | |
258 | if ui.configitems('keyword'): |
|
258 | if ui.configitems('keyword'): | |
259 | raise util.Abort(_('[keyword] patterns cannot match')) |
|
259 | raise util.Abort(_('[keyword] patterns cannot match')) | |
260 | raise util.Abort(_('no [keyword] patterns configured')) |
|
260 | raise util.Abort(_('no [keyword] patterns configured')) | |
@@ -497,14 +497,14 b' def reposetup(ui, repo):' | |||||
497 | '''Monkeypatch patch.diff to avoid expansion except when |
|
497 | '''Monkeypatch patch.diff to avoid expansion except when | |
498 | comparing against working dir.''' |
|
498 | comparing against working dir.''' | |
499 | if node2 is not None: |
|
499 | if node2 is not None: | |
500 |
kwt.match |
|
500 | kwt.match = util.never | |
501 | elif node1 is not None and node1 != repo['.'].node(): |
|
501 | elif node1 is not None and node1 != repo['.'].node(): | |
502 | kwt.restrict = True |
|
502 | kwt.restrict = True | |
503 | return orig(repo, node1, node2, match, changes, opts) |
|
503 | return orig(repo, node1, node2, match, changes, opts) | |
504 |
|
504 | |||
505 | def kwweb_skip(orig, web, req, tmpl): |
|
505 | def kwweb_skip(orig, web, req, tmpl): | |
506 | '''Wraps webcommands.x turning off keyword expansion.''' |
|
506 | '''Wraps webcommands.x turning off keyword expansion.''' | |
507 |
kwt.match |
|
507 | kwt.match = util.never | |
508 | return orig(web, req, tmpl) |
|
508 | return orig(web, req, tmpl) | |
509 |
|
509 | |||
510 | repo.__class__ = kwrepo |
|
510 | repo.__class__ = kwrepo |
General Comments 0
You need to be logged in to leave comments.
Login now