changeset 15083:6e069366e27c

keyword: use wopener(..., atomictemp=True) to overwrite
author Christian Ebert <blacktrash@gmx.net>
date Sun, 11 Sep 2011 12:20:39 +0100
parents d23dfcbb8840
children 110d6804bfc6
files hgext/keyword.py
diffstat 1 files changed, 5 insertions(+), 7 deletions(-) [+]
line wrap: on
line diff
--- a/hgext/keyword.py	Sat Sep 10 17:59:47 2011 -0500
+++ b/hgext/keyword.py	Sun Sep 11 12:20:39 2011 +0100
@@ -257,7 +257,6 @@
             msg = _('overwriting %s expanding keywords\n')
         else:
             msg = _('overwriting %s shrinking keywords\n')
-        lctx = ctx
         for f in candidates:
             if self.restrict:
                 data = self.repo.file(f).read(mf[f])
@@ -267,18 +266,17 @@
                 continue
             if expand:
                 if lookup:
-                    lctx = self.linkctx(f, mf[f])
-                data, found = self.substitute(data, f, lctx, re_kw.subn)
+                    ctx = self.linkctx(f, mf[f])
+                data, found = self.substitute(data, f, ctx, re_kw.subn)
             elif self.restrict:
                 found = re_kw.search(data)
             else:
                 data, found = _shrinktext(data, re_kw.subn)
             if found:
                 self.ui.note(msg % f)
-                fpath = self.repo.wjoin(f)
-                mode = os.lstat(fpath).st_mode
-                self.repo.wwrite(f, data, ctx.flags(f))
-                os.chmod(fpath, mode)
+                fp = self.repo.wopener(f, "wb", atomictemp=True)
+                fp.write(data)
+                fp.close()
                 if kwcmd:
                     self.repo.dirstate.normal(f)
                 elif self.record: