1199
1199
self._transport.put_bytes_non_atomic(
1200
1200
self._filename, self.HEADER, mode=self._file_mode)
1202
def _load_data(self, fp):
1204
history = self._history
1206
self.check_header(fp)
1207
# readlines reads the whole file at once:
1208
# bad for transports like http, good for local disk
1209
# we save 60 ms doing this one change (
1210
# from calling readline each time to calling
1212
# probably what we want for nice behaviour on
1213
# http is a incremental readlines that yields, or
1214
# a check for local vs non local indexes,
1215
history_top = len(history) - 1
1216
for line in fp.readlines():
1218
if len(rec) < 5 or rec[-1] != ':':
1220
# FIXME: in the future we should determine if its a
1221
# short write - and ignore it
1222
# or a different failure, and raise. RBC 20060407
1227
for value in rec[4:-1]:
1229
# uncompressed reference
1230
parent_id = value[1:]
1232
parent_id = history[int(value)]
1233
parents.append(parent_id)
1234
except (IndexError, ValueError), e:
1235
# The parent could not be decoded to get its parent row. This
1236
# at a minimum will cause this row to have wrong parents, or
1237
# even to apply a delta to the wrong base and decode
1238
# incorrectly. its therefore not usable, and because we have
1239
# encountered a situation where a new knit index had this
1240
# corrupt we can't asssume that no other rows referring to the
1241
# index of this record actually mean the subsequent uncorrupt
1243
raise errors.KnitCorrupt(self._filename,
1244
"line %r: %s" % (rec, e))
1246
version_id, options, pos, size = rec[:4]
1247
version_id = version_id
1249
# See self._cache_version
1250
# only want the _history index to reference the 1st
1251
# index entry for version_id
1252
if version_id not in cache:
1255
history.append(version_id)
1257
index = cache[version_id][5]
1258
cache[version_id] = (version_id,
1264
# end self._cache_version
1266
1202
def get_graph(self):
1267
1203
return [(vid, idx[4]) for vid, idx in self._cache.iteritems()]