Mercurial > hg
comparison mercurial/wireproto.py @ 26444:623743010133
streamclone: move _allowstream() from wireproto
While we're moving things into streamclone.py...
author | Gregory Szorc <gregory.szorc@gmail.com> |
---|---|
date | Fri, 02 Oct 2015 16:24:56 -0700 |
parents | d947086d8973 |
children | fb743268510e |
comparison
equal
deleted
inserted
replaced
26443:d947086d8973 | 26444:623743010133 |
---|---|
562 - change done here will be propagated to both `capabilities` and `hello` | 562 - change done here will be propagated to both `capabilities` and `hello` |
563 command without any other action needed. | 563 command without any other action needed. |
564 """ | 564 """ |
565 # copy to prevent modification of the global list | 565 # copy to prevent modification of the global list |
566 caps = list(wireprotocaps) | 566 caps = list(wireprotocaps) |
567 if _allowstream(repo.ui): | 567 if streamclone.allowservergeneration(repo.ui): |
568 if repo.ui.configbool('server', 'preferuncompressed', False): | 568 if repo.ui.configbool('server', 'preferuncompressed', False): |
569 caps.append('stream-preferred') | 569 caps.append('stream-preferred') |
570 requiredformats = repo.requirements & repo.supportedformats | 570 requiredformats = repo.requirements & repo.supportedformats |
571 # if our local revlogs are just revlogv1, add 'stream' cap | 571 # if our local revlogs are just revlogv1, add 'stream' cap |
572 if not requiredformats - set(('revlogv1',)): | 572 if not requiredformats - set(('revlogv1',)): |
699 | 699 |
700 r = repo.pushkey(encoding.tolocal(namespace), encoding.tolocal(key), | 700 r = repo.pushkey(encoding.tolocal(namespace), encoding.tolocal(key), |
701 encoding.tolocal(old), new) | 701 encoding.tolocal(old), new) |
702 return '%s\n' % int(r) | 702 return '%s\n' % int(r) |
703 | 703 |
704 def _allowstream(ui): | |
705 return ui.configbool('server', 'uncompressed', True, untrusted=True) | |
706 | |
707 @wireprotocommand('stream_out') | 704 @wireprotocommand('stream_out') |
708 def stream(repo, proto): | 705 def stream(repo, proto): |
709 '''If the server supports streaming clone, it advertises the "stream" | 706 '''If the server supports streaming clone, it advertises the "stream" |
710 capability with a value representing the version and flags of the repo | 707 capability with a value representing the version and flags of the repo |
711 it is serving. Client checks to see if it understands the format. | 708 it is serving. Client checks to see if it understands the format. |
712 ''' | 709 ''' |
713 if not _allowstream(repo.ui): | 710 if not streamclone.allowservergeneration(repo.ui): |
714 return '1\n' | 711 return '1\n' |
715 | 712 |
716 def getstream(it): | 713 def getstream(it): |
717 yield '0\n' | 714 yield '0\n' |
718 for chunk in it: | 715 for chunk in it: |