255 re_kw = self.rekwexp |
255 re_kw = self.rekwexp |
256 if expand: |
256 if expand: |
257 msg = _('overwriting %s expanding keywords\n') |
257 msg = _('overwriting %s expanding keywords\n') |
258 else: |
258 else: |
259 msg = _('overwriting %s shrinking keywords\n') |
259 msg = _('overwriting %s shrinking keywords\n') |
260 lctx = ctx |
|
261 for f in candidates: |
260 for f in candidates: |
262 if self.restrict: |
261 if self.restrict: |
263 data = self.repo.file(f).read(mf[f]) |
262 data = self.repo.file(f).read(mf[f]) |
264 else: |
263 else: |
265 data = self.repo.wread(f) |
264 data = self.repo.wread(f) |
266 if util.binary(data): |
265 if util.binary(data): |
267 continue |
266 continue |
268 if expand: |
267 if expand: |
269 if lookup: |
268 if lookup: |
270 lctx = self.linkctx(f, mf[f]) |
269 ctx = self.linkctx(f, mf[f]) |
271 data, found = self.substitute(data, f, lctx, re_kw.subn) |
270 data, found = self.substitute(data, f, ctx, re_kw.subn) |
272 elif self.restrict: |
271 elif self.restrict: |
273 found = re_kw.search(data) |
272 found = re_kw.search(data) |
274 else: |
273 else: |
275 data, found = _shrinktext(data, re_kw.subn) |
274 data, found = _shrinktext(data, re_kw.subn) |
276 if found: |
275 if found: |
277 self.ui.note(msg % f) |
276 self.ui.note(msg % f) |
278 self.repo.wwrite(f, data, ctx.flags(f)) |
277 fp = self.repo.wopener(f, "wb", atomictemp=True) |
|
278 fp.write(data) |
|
279 fp.close() |
279 if kwcmd: |
280 if kwcmd: |
280 self.repo.dirstate.normal(f) |
281 self.repo.dirstate.normal(f) |
281 elif self.record: |
282 elif self.record: |
282 self.repo.dirstate.normallookup(f) |
283 self.repo.dirstate.normallookup(f) |
283 |
284 |