391
391
transport.put(name + INDEX_SUFFIX + '.tmp', self.transport.get(self._index._filename),)
392
392
# copy the data file
393
transport.put(name + DATA_SUFFIX, self._data._open_file())
394
# rename the copied index into place
395
transport.rename(name + INDEX_SUFFIX + '.tmp', name + INDEX_SUFFIX)
393
f = self._data._open_file()
395
transport.put(name + DATA_SUFFIX, f)
398
# move the copied index into place
399
transport.move(name + INDEX_SUFFIX + '.tmp', name + INDEX_SUFFIX)
397
401
def create_empty(self, name, transport, mode=None):
398
402
return KnitVersionedFile(name, transport, factory=self.factory, delta=self.delta, create=True)
1045
1049
pb.update('read knit index', count, total)
1046
1050
fp = self._transport.get(self._filename)
1047
self.check_header(fp)
1048
# readlines reads the whole file at once:
1049
# bad for transports like http, good for local disk
1050
# we save 60 ms doing this one change (
1051
# from calling readline each time to calling
1053
# probably what we want for nice behaviour on
1054
# http is a incremental readlines that yields, or
1055
# a check for local vs non local indexes,
1056
for l in fp.readlines():
1058
if len(rec) < 5 or rec[-1] != ':':
1060
# FIXME: in the future we should determine if its a
1061
# short write - and ignore it
1062
# or a different failure, and raise. RBC 20060407
1066
#pb.update('read knit index', count, total)
1067
# See self._parse_parents
1069
for value in rec[4:-1]:
1071
# uncompressed reference
1072
parents.append(value[1:])
1052
self.check_header(fp)
1053
# readlines reads the whole file at once:
1054
# bad for transports like http, good for local disk
1055
# we save 60 ms doing this one change (
1056
# from calling readline each time to calling
1058
# probably what we want for nice behaviour on
1059
# http is a incremental readlines that yields, or
1060
# a check for local vs non local indexes,
1061
for l in fp.readlines():
1063
if len(rec) < 5 or rec[-1] != ':':
1065
# FIXME: in the future we should determine if its a
1066
# short write - and ignore it
1067
# or a different failure, and raise. RBC 20060407
1071
#pb.update('read knit index', count, total)
1072
# See self._parse_parents
1074
for value in rec[4:-1]:
1076
# uncompressed reference
1077
parents.append(value[1:])
1079
# this is 15/4000ms faster than isinstance,
1081
# this function is called thousands of times a
1082
# second so small variations add up.
1083
assert value.__class__ is str
1084
parents.append(self._history[int(value)])
1085
# end self._parse_parents
1086
# self._cache_version(rec[0],
1087
# rec[1].split(','),
1091
# --- self._cache_version
1092
# only want the _history index to reference the 1st
1093
# index entry for version_id
1095
if version_id not in self._cache:
1096
index = len(self._history)
1097
self._history.append(version_id)
1074
# this is 15/4000ms faster than isinstance,
1076
# this function is called thousands of times a
1077
# second so small variations add up.
1078
assert value.__class__ is str
1079
parents.append(self._history[int(value)])
1080
# end self._parse_parents
1081
# self._cache_version(rec[0],
1082
# rec[1].split(','),
1086
# --- self._cache_version
1087
# only want the _history index to reference the 1st
1088
# index entry for version_id
1090
if version_id not in self._cache:
1091
index = len(self._history)
1092
self._history.append(version_id)
1094
index = self._cache[version_id][5]
1095
self._cache[version_id] = (version_id,
1101
# --- self._cache_version
1099
index = self._cache[version_id][5]
1100
self._cache[version_id] = (version_id,
1106
# --- self._cache_version
1102
1109
except NoSuchFile, e:
1103
1110
if mode != 'w' or not create: