Mercurial > public > mercurial-scm > hg
comparison mercurial/wireproto.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 | 7d2292416046 |
children | 8cdb671dbd0b |
comparison
equal
deleted
inserted
replaced
35490:784a85c87c22 | 35491:ded3a63f305b |
---|---|
952 def stream(repo, proto): | 952 def stream(repo, proto): |
953 '''If the server supports streaming clone, it advertises the "stream" | 953 '''If the server supports streaming clone, it advertises the "stream" |
954 capability with a value representing the version and flags of the repo | 954 capability with a value representing the version and flags of the repo |
955 it is serving. Client checks to see if it understands the format. | 955 it is serving. Client checks to see if it understands the format. |
956 ''' | 956 ''' |
957 if not streamclone.allowservergeneration(repo): | 957 return streamres(streamclone.generatev1wireproto(repo)) |
958 return '1\n' | |
959 | |
960 def getstream(it): | |
961 yield '0\n' | |
962 for chunk in it: | |
963 yield chunk | |
964 | |
965 try: | |
966 # LockError may be raised before the first result is yielded. Don't | |
967 # emit output until we're sure we got the lock successfully. | |
968 it = streamclone.generatev1wireproto(repo) | |
969 return streamres(gen=getstream(it)) | |
970 except error.LockError: | |
971 return '2\n' | |
972 | 958 |
973 @wireprotocommand('unbundle', 'heads') | 959 @wireprotocommand('unbundle', 'heads') |
974 def unbundle(repo, proto, heads): | 960 def unbundle(repo, proto, heads): |
975 their_heads = decodelist(heads) | 961 their_heads = decodelist(heads) |
976 | 962 |