Mercurial > public > mercurial-scm > hg
comparison mercurial/streamclone.py @ 35491:ded3a63f305b
streamclone: move wire protocol status code from wireproto command
This consolidates the code for the streaming clone wire protocol format
into streamclone.py. It also eliminates a generator wrapper, which might
make streaming clones slightly faster.
Differential Revision: https://phab.mercurial-scm.org/D1754
author | Gregory Szorc <gregory.szorc@gmail.com> |
---|---|
date | Sun, 24 Dec 2017 11:46:13 -0700 |
parents | 0407a51b9d8c |
children | cfdccd560b66 |
comparison
equal
deleted
inserted
replaced
35490:784a85c87c22 | 35491:ded3a63f305b |
---|---|
233 return len(entries), total_bytes, emitrevlogdata() | 233 return len(entries), total_bytes, emitrevlogdata() |
234 | 234 |
235 def generatev1wireproto(repo): | 235 def generatev1wireproto(repo): |
236 """Emit content for version 1 of streaming clone suitable for the wire. | 236 """Emit content for version 1 of streaming clone suitable for the wire. |
237 | 237 |
238 This is the data output from ``generatev1()`` with a header line | 238 This is the data output from ``generatev1()`` with 2 header lines. The |
239 indicating file count and byte size. | 239 first line indicates overall success. The 2nd contains the file count and |
240 """ | 240 byte size of payload. |
241 filecount, bytecount, it = generatev1(repo) | 241 |
242 The success line contains "0" for success, "1" for stream generation not | |
243 allowed, and "2" for error locking the repository (possibly indicating | |
244 a permissions error for the server process). | |
245 """ | |
246 if not allowservergeneration(repo): | |
247 yield '1\n' | |
248 return | |
249 | |
250 try: | |
251 filecount, bytecount, it = generatev1(repo) | |
252 except error.LockError: | |
253 yield '2\n' | |
254 return | |
255 | |
256 # Indicates successful response. | |
257 yield '0\n' | |
242 yield '%d %d\n' % (filecount, bytecount) | 258 yield '%d %d\n' % (filecount, bytecount) |
243 for chunk in it: | 259 for chunk in it: |
244 yield chunk | 260 yield chunk |
245 | 261 |
246 def generatebundlev1(repo, compression='UN'): | 262 def generatebundlev1(repo, compression='UN'): |