changeset 4005:656e06eebda7

replace filehandle version of wwrite with wwritedata
author Matt Mackall <mpm@selenic.com>
date Fri, 29 Dec 2006 20:04:31 -0600
parents c83c35f2f4e2
children 67982d3ee76c
files hgext/extdiff.py mercurial/archival.py mercurial/localrepo.py mercurial/merge.py
diffstat 4 files changed, 9 insertions(+), 8 deletions(-) [+]
line wrap: on
line diff
--- a/hgext/extdiff.py	Fri Dec 29 20:04:31 2006 -0600
+++ b/hgext/extdiff.py	Fri Dec 29 20:04:31 2006 -0600
@@ -73,7 +73,8 @@
             destdir = os.path.dirname(dest)
             if not os.path.isdir(destdir):
                 os.makedirs(destdir)
-            repo.wwrite(wfn, repo.file(fn).read(mf[fn]), open(dest, 'w'))
+            data = repo.wwritedata(wfn, repo.file(wfn).read(mf[wfn]))
+            open(dest, 'w').write(data)
         return dirname
 
     def snapshot_wdir(files):
--- a/mercurial/archival.py	Fri Dec 29 20:04:31 2006 -0600
+++ b/mercurial/archival.py	Fri Dec 29 20:04:31 2006 -0600
@@ -154,9 +154,7 @@
     def write(name, mode, data):
         if matchfn and not matchfn(name): return
         if decode:
-            fp = cStringIO.StringIO()
-            repo.wwrite(name, data, fp)
-            data = fp.getvalue()
+            data = repo.wwritedata(name, data)
         archiver.addfile(name, mode, data)
 
     ctx = repo.changectx(node)
--- a/mercurial/localrepo.py	Fri Dec 29 20:04:31 2006 -0600
+++ b/mercurial/localrepo.py	Fri Dec 29 20:04:31 2006 -0600
@@ -505,12 +505,13 @@
             data = self.wopener(filename, 'r').read()
         return self._filter("encode", filename, data)
 
-    def wwrite(self, filename, data, fd=None):
+    def wwrite(self, filename, data):
         data = self._filter("decode", filename, data)
-        if fd:
-            return fd.write(data)
         return self.wopener(filename, 'w').write(data)
 
+    def wwritedata(self, filename, data):
+        return self._filter("decode", filename, data)
+
     def transaction(self):
         tr = self.transhandle
         if tr != None and tr.running():
--- a/mercurial/merge.py	Fri Dec 29 20:04:31 2006 -0600
+++ b/mercurial/merge.py	Fri Dec 29 20:04:31 2006 -0600
@@ -20,8 +20,9 @@
     def temp(prefix, ctx):
         pre = "%s~%s." % (os.path.basename(ctx.path()), prefix)
         (fd, name) = tempfile.mkstemp(prefix=pre)
+        data = repo.wwritedata(ctx.path(), ctx.data())
         f = os.fdopen(fd, "wb")
-        repo.wwrite(ctx.path(), ctx.data(), f)
+        f.write(data)
         f.close()
         return name