##// END OF EJS Templates
keyword: use wopener(..., atomictemp=True) to overwrite
Christian Ebert -
r15083:6e069366 default
parent child Browse files
Show More
@@ -257,7 +257,6 b' class kwtemplater(object):'
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])
@@ -267,18 +266,17 b' class kwtemplater(object):'
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 fpath = self.repo.wjoin(f)
277 fp = self.repo.wopener(f, "wb", atomictemp=True)
279 mode = os.lstat(fpath).st_mode
278 fp.write(data)
280 self.repo.wwrite(f, data, ctx.flags(f))
279 fp.close()
281 os.chmod(fpath, mode)
282 if kwcmd:
280 if kwcmd:
283 self.repo.dirstate.normal(f)
281 self.repo.dirstate.normal(f)
284 elif self.record:
282 elif self.record:
General Comments 0
You need to be logged in to leave comments. Login now