[Pkg-bazaar-commits] ./bzr/unstable r431: - stat cache is written in utf-8 to accomodate non-ascii
Martin Pool
mbp at sourcefrog.net
Fri Apr 10 08:19:56 UTC 2009
------------------------------------------------------------
revno: 431
committer: Martin Pool <mbp at sourcefrog.net>
timestamp: Tue 2005-05-10 16:13:49 +1000
message:
- stat cache is written in utf-8 to accomodate non-ascii
filenames
modified:
bzrlib/atomicfile.py
bzrlib/statcache.py
-------------- next part --------------
=== modified file 'bzrlib/atomicfile.py'
--- a/bzrlib/atomicfile.py 2005-05-10 06:07:16 +0000
+++ b/bzrlib/atomicfile.py 2005-05-10 06:13:49 +0000
@@ -24,11 +24,10 @@
Open this as for a regular file, then use commit() to move into
place or abort() to cancel.
- You may wish to wrap this in a codecs.EncodedFile to do unicode
- encoding.
+ An encoding can be specified; otherwise the default is ascii.
"""
- def __init__(self, filename, mode='wb'):
+ def __init__(self, filename, mode='wb', encoding=None):
if mode != 'wb' and mode != 'wt':
raise ValueError("invalid AtomicFile mode %r" % mode)
@@ -38,6 +37,11 @@
self.realfilename = filename
self.f = open(self.tmpfilename, mode)
+
+ if encoding:
+ import codecs
+ self.f = codecs.EncodedFile(self.f, encoding)
+
self.write = self.f.write
self.closed = property(self.f.closed)
=== modified file 'bzrlib/statcache.py'
--- a/bzrlib/statcache.py 2005-05-10 06:07:16 +0000
+++ b/bzrlib/statcache.py 2005-05-10 06:13:49 +0000
@@ -72,7 +72,7 @@
def write_cache(branch, entry_iter):
from atomicfile import AtomicFile
- outf = AtomicFile(branch.controlfilename('work-cache.tmp'), 'wb')
+ outf = AtomicFile(branch.controlfilename('work-cache'), 'w', 'utf-8')
try:
for entry in entry_iter:
outf.write(entry[0] + ' ' + entry[1] + ' ')
@@ -89,7 +89,7 @@
cache = {}
try:
- cachefile = branch.controlfile('work-cache', 'rb')
+ cachefile = branch.controlfile('work-cache', 'r')
except IOError:
return cache
More information about the Pkg-bazaar-commits
mailing list