##// END OF EJS Templates
clone: put streaming clones in a transaction...
Durham Goode -
r20880:925c2d60 default
parent child Browse files
Show More
@@ -2021,26 +2021,36 b' class localrepository(object):'
2021 handled_bytes = 0
2021 handled_bytes = 0
2022 self.ui.progress(_('clone'), 0, total=total_bytes)
2022 self.ui.progress(_('clone'), 0, total=total_bytes)
2023 start = time.time()
2023 start = time.time()
2024 for i in xrange(total_files):
2024
2025 # XXX doesn't support '\n' or '\r' in filenames
2025 tr = self.transaction(_('clone'))
2026 l = fp.readline()
2026 try:
2027 try:
2027 for i in xrange(total_files):
2028 name, size = l.split('\0', 1)
2028 # XXX doesn't support '\n' or '\r' in filenames
2029 size = int(size)
2029 l = fp.readline()
2030 except (ValueError, TypeError):
2030 try:
2031 raise error.ResponseError(
2031 name, size = l.split('\0', 1)
2032 _('unexpected response from remote server:'), l)
2032 size = int(size)
2033 if self.ui.debugflag:
2033 except (ValueError, TypeError):
2034 self.ui.debug('adding %s (%s)\n' %
2034 raise error.ResponseError(
2035 (name, util.bytecount(size)))
2035 _('unexpected response from remote server:'), l)
2036 # for backwards compat, name was partially encoded
2036 if self.ui.debugflag:
2037 ofp = self.sopener(store.decodedir(name), 'w')
2037 self.ui.debug('adding %s (%s)\n' %
2038 for chunk in util.filechunkiter(fp, limit=size):
2038 (name, util.bytecount(size)))
2039 handled_bytes += len(chunk)
2039 # for backwards compat, name was partially encoded
2040 self.ui.progress(_('clone'), handled_bytes,
2040 ofp = self.sopener(store.decodedir(name), 'w')
2041 total=total_bytes)
2041 for chunk in util.filechunkiter(fp, limit=size):
2042 ofp.write(chunk)
2042 handled_bytes += len(chunk)
2043 ofp.close()
2043 self.ui.progress(_('clone'), handled_bytes,
2044 total=total_bytes)
2045 ofp.write(chunk)
2046 ofp.close()
2047 tr.close()
2048 finally:
2049 tr.release()
2050
2051 # Writing straight to files circumvented the inmemory caches
2052 self.invalidate()
2053
2044 elapsed = time.time() - start
2054 elapsed = time.time() - start
2045 if elapsed <= 0:
2055 if elapsed <= 0:
2046 elapsed = 0.001
2056 elapsed = 0.001
General Comments 0
You need to be logged in to leave comments. Login now