910
911
options.append('fulltext')
911
# get mixed annotation + content and feed it into the
913
store_lines = self.factory.lower_fulltext(content)
914
size, bytes = self._data._record_to_data(version_id, digest,
912
# isinstance is slower and we have no hierarchy.
913
if self.factory.__class__ == KnitPlainFactory:
914
# Use the already joined bytes saving iteration time in
916
size, bytes = self._data._record_to_data(version_id, digest,
919
# get mixed annotation + content and feed it into the
921
store_lines = self.factory.lower_fulltext(content)
922
size, bytes = self._data._record_to_data(version_id, digest,
917
925
access_memo = self._data.add_raw_records([size], bytes)[0]
918
926
self._index.add_versions(
1972
1980
def _open_file(self):
1973
1981
return self._access.open_file()
1975
def _record_to_data(self, version_id, digest, lines):
1983
def _record_to_data(self, version_id, digest, lines, dense_lines=None):
1976
1984
"""Convert version_id, digest, lines into a raw data block.
1986
:param dense_lines: The bytes of lines but in a denser form. For
1987
instance, if lines is a list of 1000 bytestrings each ending in \n,
1988
dense_lines may be a list with one line in it, containing all the
1989
1000's lines and their \n's. Using dense_lines if it is already
1990
known is a win because the string join to create bytes in this
1991
function spends less time resizing the final string.
1978
1992
:return: (len, a StringIO instance with the raw data ready to read.)
1980
bytes = (''.join(chain(
1994
# Note: using a string copy here increases memory pressure with e.g.
1995
# ISO's, but it is about 3 seconds faster on a 1.2Ghz intel machine
1996
# when doing the initial commit of a mozilla tree. RBC 20070921
1997
bytes = ''.join(chain(
1981
1998
["version %s %d %s\n" % (version_id,
1985
["end %s\n" % version_id])))
2001
dense_lines or lines,
2002
["end %s\n" % version_id]))
1986
2003
assert bytes.__class__ == str
1987
2004
compressed_bytes = bytes_to_gzip(bytes)
1988
2005
return len(compressed_bytes), compressed_bytes