60
60
def _relpath(self, fileid):
61
61
return super(CompressedTextStore, self)._relpath(fileid, ['gz'])
63
def add(self, f, fileid):
64
"""Add contents of a file into the store.
66
f -- An open file, or file-like object."""
67
# TODO: implement an add_multi which can do some of it's
68
# own piplelining, and possible take advantage of
69
# transport.put_multi(). The problem is that
70
# entries potentially need to be compressed as they
71
# are received, which implies translation, which
72
# means it isn't as straightforward as we would like.
63
def _add(self, fn, f):
73
64
from cStringIO import StringIO
74
65
from bzrlib.osutils import pumpfile
76
mutter("add store entry %r" % (fileid))
77
67
if isinstance(f, basestring):
80
fn = self._relpath(fileid)
81
if self._transport.has(fn):
82
raise BzrError("store %r already contains id %r" % (self._transport.base, fileid))
86
self._transport.mkdir(hash_prefix(fileid))
91
71
gf = gzip.GzipFile(mode='wb', fileobj=sio)
92
72
# if pumpfile handles files that don't fit in ram,