Mercurial > public > mercurial-scm > hg
comparison mercurial/streamclone.py @ 26442:ef8d27f53204
streamclone: move stream_in() from localrepo
Another basic content move. The underscore from the function name was
removed to comply with naming standards.
author | Gregory Szorc <gregory.szorc@gmail.com> |
---|---|
date | Fri, 02 Oct 2015 15:58:24 -0700 |
parents | 56527b886d1d |
children | d947086d8973 |
comparison
equal
deleted
inserted
replaced
26441:56527b886d1d | 26442:ef8d27f53204 |
---|---|
5 # This software may be used and distributed according to the terms of the | 5 # This software may be used and distributed according to the terms of the |
6 # GNU General Public License version 2 or any later version. | 6 # GNU General Public License version 2 or any later version. |
7 | 7 |
8 from __future__ import absolute_import | 8 from __future__ import absolute_import |
9 | 9 |
10 from .i18n import _ | |
10 from . import ( | 11 from . import ( |
11 branchmap, | 12 branchmap, |
13 error, | |
12 exchange, | 14 exchange, |
15 util, | |
13 ) | 16 ) |
17 | |
18 def streamin(repo, remote, remotereqs): | |
19 # Save remote branchmap. We will use it later | |
20 # to speed up branchcache creation | |
21 rbranchmap = None | |
22 if remote.capable("branchmap"): | |
23 rbranchmap = remote.branchmap() | |
24 | |
25 fp = remote.stream_out() | |
26 l = fp.readline() | |
27 try: | |
28 resp = int(l) | |
29 except ValueError: | |
30 raise error.ResponseError( | |
31 _('unexpected response from remote server:'), l) | |
32 if resp == 1: | |
33 raise util.Abort(_('operation forbidden by server')) | |
34 elif resp == 2: | |
35 raise util.Abort(_('locking the remote repository failed')) | |
36 elif resp != 0: | |
37 raise util.Abort(_('the server sent an unknown error code')) | |
38 | |
39 applyremotedata(repo, remotereqs, rbranchmap, fp) | |
40 return len(repo.heads()) + 1 | |
14 | 41 |
15 def applyremotedata(repo, remotereqs, remotebranchmap, fp): | 42 def applyremotedata(repo, remotereqs, remotebranchmap, fp): |
16 """Apply stream clone data to a repository. | 43 """Apply stream clone data to a repository. |
17 | 44 |
18 "remotereqs" is a set of requirements to handle the incoming data. | 45 "remotereqs" is a set of requirements to handle the incoming data. |