##// 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 127 elif resp != 0:
128 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 137 lock = repo.lock()
131 138 try:
132 consumev1(repo, fp)
139 consumev1(repo, fp, filecount, bytecount)
133 140
134 141 # new requirements = old non-format requirements +
135 142 # new format-related remote requirements
@@ -215,7 +222,7 b' def generatev1(repo):'
215 222 finally:
216 223 svfs.mustaudit = oldaudit
217 224
218 def consumev1(repo, fp):
225 def consumev1(repo, fp, filecount, bytecount):
219 226 """Apply the contents from version 1 of a streaming clone file handle.
220 227
221 228 This takes the output from "streamout" and applies it to the specified
@@ -227,21 +234,15 b' def consumev1(repo, fp):'
227 234 lock = repo.lock()
228 235 try:
229 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 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 239 handled_bytes = 0
239 repo.ui.progress(_('clone'), 0, total=total_bytes)
240 repo.ui.progress(_('clone'), 0, total=bytecount)
240 241 start = time.time()
241 242
242 243 tr = repo.transaction(_('clone'))
243 244 try:
244 for i in xrange(total_files):
245 for i in xrange(filecount):
245 246 # XXX doesn't support '\n' or '\r' in filenames
246 247 l = fp.readline()
247 248 try:
@@ -257,8 +258,7 b' def consumev1(repo, fp):'
257 258 ofp = repo.svfs(store.decodedir(name), 'w')
258 259 for chunk in util.filechunkiter(fp, limit=size):
259 260 handled_bytes += len(chunk)
260 repo.ui.progress(_('clone'), handled_bytes,
261 total=total_bytes)
261 repo.ui.progress(_('clone'), handled_bytes, total=bytecount)
262 262 ofp.write(chunk)
263 263 ofp.close()
264 264 tr.close()
@@ -273,7 +273,7 b' def consumev1(repo, fp):'
273 273 elapsed = 0.001
274 274 repo.ui.progress(_('clone'), None)
275 275 repo.ui.status(_('transferred %s in %.1f seconds (%s/sec)\n') %
276 (util.bytecount(total_bytes), elapsed,
277 util.bytecount(total_bytes / elapsed)))
276 (util.bytecount(bytecount), elapsed,
277 util.bytecount(bytecount / elapsed)))
278 278 finally:
279 279 lock.release()
General Comments 0
You need to be logged in to leave comments. Login now