##// END OF EJS Templates
streamclone: move payload header line consumption...
Gregory Szorc -
r26468:19bbd53a default
parent child Browse files
Show More
@@ -127,9 +127,16 b' def maybeperformlegacystreamclone(pullop'
127 elif resp != 0:
127 elif resp != 0:
128 raise util.Abort(_('the server sent an unknown error code'))
128 raise util.Abort(_('the server sent an unknown error code'))
129
129
130 l = fp.readline()
131 try:
132 filecount, bytecount = map(int, l.split(' ', 1))
133 except (ValueError, TypeError):
134 raise error.ResponseError(
135 _('unexpected response from remote server:'), l)
136
130 lock = repo.lock()
137 lock = repo.lock()
131 try:
138 try:
132 consumev1(repo, fp)
139 consumev1(repo, fp, filecount, bytecount)
133
140
134 # new requirements = old non-format requirements +
141 # new requirements = old non-format requirements +
135 # new format-related remote requirements
142 # new format-related remote requirements
@@ -215,7 +222,7 b' def generatev1(repo):'
215 finally:
222 finally:
216 svfs.mustaudit = oldaudit
223 svfs.mustaudit = oldaudit
217
224
218 def consumev1(repo, fp):
225 def consumev1(repo, fp, filecount, bytecount):
219 """Apply the contents from version 1 of a streaming clone file handle.
226 """Apply the contents from version 1 of a streaming clone file handle.
220
227
221 This takes the output from "streamout" and applies it to the specified
228 This takes the output from "streamout" and applies it to the specified
@@ -227,21 +234,15 b' def consumev1(repo, fp):'
227 lock = repo.lock()
234 lock = repo.lock()
228 try:
235 try:
229 repo.ui.status(_('streaming all changes\n'))
236 repo.ui.status(_('streaming all changes\n'))
230 l = fp.readline()
231 try:
232 total_files, total_bytes = map(int, l.split(' ', 1))
233 except (ValueError, TypeError):
234 raise error.ResponseError(
235 _('unexpected response from remote server:'), l)
236 repo.ui.status(_('%d files to transfer, %s of data\n') %
237 repo.ui.status(_('%d files to transfer, %s of data\n') %
237 (total_files, util.bytecount(total_bytes)))
238 (filecount, util.bytecount(bytecount)))
238 handled_bytes = 0
239 handled_bytes = 0
239 repo.ui.progress(_('clone'), 0, total=total_bytes)
240 repo.ui.progress(_('clone'), 0, total=bytecount)
240 start = time.time()
241 start = time.time()
241
242
242 tr = repo.transaction(_('clone'))
243 tr = repo.transaction(_('clone'))
243 try:
244 try:
244 for i in xrange(total_files):
245 for i in xrange(filecount):
245 # XXX doesn't support '\n' or '\r' in filenames
246 # XXX doesn't support '\n' or '\r' in filenames
246 l = fp.readline()
247 l = fp.readline()
247 try:
248 try:
@@ -257,8 +258,7 b' def consumev1(repo, fp):'
257 ofp = repo.svfs(store.decodedir(name), 'w')
258 ofp = repo.svfs(store.decodedir(name), 'w')
258 for chunk in util.filechunkiter(fp, limit=size):
259 for chunk in util.filechunkiter(fp, limit=size):
259 handled_bytes += len(chunk)
260 handled_bytes += len(chunk)
260 repo.ui.progress(_('clone'), handled_bytes,
261 repo.ui.progress(_('clone'), handled_bytes, total=bytecount)
261 total=total_bytes)
262 ofp.write(chunk)
262 ofp.write(chunk)
263 ofp.close()
263 ofp.close()
264 tr.close()
264 tr.close()
@@ -273,7 +273,7 b' def consumev1(repo, fp):'
273 elapsed = 0.001
273 elapsed = 0.001
274 repo.ui.progress(_('clone'), None)
274 repo.ui.progress(_('clone'), None)
275 repo.ui.status(_('transferred %s in %.1f seconds (%s/sec)\n') %
275 repo.ui.status(_('transferred %s in %.1f seconds (%s/sec)\n') %
276 (util.bytecount(total_bytes), elapsed,
276 (util.bytecount(bytecount), elapsed,
277 util.bytecount(total_bytes / elapsed)))
277 util.bytecount(bytecount / elapsed)))
278 finally:
278 finally:
279 lock.release()
279 lock.release()
General Comments 0
You need to be logged in to leave comments. Login now