diff --git a/hgext/extdiff.py b/hgext/extdiff.py --- a/hgext/extdiff.py +++ b/hgext/extdiff.py @@ -73,7 +73,8 @@ def dodiff(ui, repo, diffcmd, diffopts, 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): diff --git a/mercurial/archival.py b/mercurial/archival.py --- a/mercurial/archival.py +++ b/mercurial/archival.py @@ -154,9 +154,7 @@ def archive(repo, dest, node, kind, deco 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) diff --git a/mercurial/localrepo.py b/mercurial/localrepo.py --- a/mercurial/localrepo.py +++ b/mercurial/localrepo.py @@ -505,12 +505,13 @@ class localrepository(repo.repository): 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(): diff --git a/mercurial/merge.py b/mercurial/merge.py --- a/mercurial/merge.py +++ b/mercurial/merge.py @@ -20,8 +20,9 @@ def filemerge(repo, fw, fo, wctx, mctx): 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