163 if not self.restrict and self.matcher(path) and not util.binary(data): |
163 if not self.restrict and self.matcher(path) and not util.binary(data): |
164 changenode = self.getnode(path, node) |
164 changenode = self.getnode(path, node) |
165 return self.substitute(data, path, changenode, self.re_kw.sub) |
165 return self.substitute(data, path, changenode, self.re_kw.sub) |
166 return data |
166 return data |
167 |
167 |
168 def iskwfile(self, path, islink): |
168 def iskwfile(self, path, flagfunc): |
169 '''Returns true if path matches [keyword] pattern |
169 '''Returns true if path matches [keyword] pattern |
170 and is not a symbolic link. |
170 and is not a symbolic link. |
171 Caveat: localrepository._link fails on Windows.''' |
171 Caveat: localrepository._link fails on Windows.''' |
172 return self.matcher(path) and not islink(path) |
172 return self.matcher(path) and not 'l' in flagfunc(path) |
173 |
173 |
174 def overwrite(self, node, expand, files): |
174 def overwrite(self, node, expand, files): |
175 '''Overwrites selected files expanding/shrinking keywords.''' |
175 '''Overwrites selected files expanding/shrinking keywords.''' |
176 if node is not None: # commit |
176 if node is not None: # commit |
177 ctx = self.repo[node] |
177 ctx = self.repo[node] |
178 mf = ctx.manifest() |
178 mf = ctx.manifest() |
179 files = [f for f in ctx.files() if f in mf] |
179 files = [f for f in ctx.files() if f in mf] |
180 notify = self.ui.debug |
180 notify = self.ui.debug |
181 else: # kwexpand/kwshrink |
181 else: # kwexpand/kwshrink |
182 ctx = self.repo['.'] |
182 ctx = self.repo['.'] |
183 mf = ctx.manifest() |
|
184 notify = self.ui.note |
183 notify = self.ui.note |
185 candidates = [f for f in files if self.iskwfile(f, mf.linkf)] |
184 candidates = [f for f in files if self.iskwfile(f, ctx.flags)] |
186 if candidates: |
185 if candidates: |
187 self.restrict = True # do not expand when reading |
186 self.restrict = True # do not expand when reading |
188 candidates.sort() |
187 candidates.sort() |
189 action = expand and 'expanding' or 'shrinking' |
188 action = expand and 'expanding' or 'shrinking' |
190 for f in candidates: |
189 for f in candidates: |
387 files = modified + added + clean |
386 files = modified + added + clean |
388 if opts.get('untracked'): |
387 if opts.get('untracked'): |
389 files += unknown |
388 files += unknown |
390 files.sort() |
389 files.sort() |
391 wctx = repo[None] |
390 wctx = repo[None] |
392 islink = lambda p: 'l' in wctx.flags(p) |
391 kwfiles = [f for f in files if kwt.iskwfile(f, wctx.flags)] |
393 kwfiles = [f for f in files if kwt.iskwfile(f, islink)] |
|
394 cwd = pats and repo.getcwd() or '' |
392 cwd = pats and repo.getcwd() or '' |
395 kwfstats = not opts.get('ignore') and (('K', kwfiles),) or () |
393 kwfstats = not opts.get('ignore') and (('K', kwfiles),) or () |
396 if opts.get('all') or opts.get('ignore'): |
394 if opts.get('all') or opts.get('ignore'): |
397 kwfstats += (('I', [f for f in files if f not in kwfiles]),) |
395 kwfstats += (('I', [f for f in files if f not in kwfiles]),) |
398 for char, filenames in kwfstats: |
396 for char, filenames in kwfstats: |