##// END OF EJS Templates
streamclone: move stream_in() from localrepo...
Gregory Szorc -
r26442:ef8d27f5 default
parent child Browse files
Show More
@@ -1788,30 +1788,6 b' class localrepository(object):'
1788 1788 """
1789 1789 return util.hooks()
1790 1790
1791 def stream_in(self, remote, remotereqs):
1792 # Save remote branchmap. We will use it later
1793 # to speed up branchcache creation
1794 rbranchmap = None
1795 if remote.capable("branchmap"):
1796 rbranchmap = remote.branchmap()
1797
1798 fp = remote.stream_out()
1799 l = fp.readline()
1800 try:
1801 resp = int(l)
1802 except ValueError:
1803 raise error.ResponseError(
1804 _('unexpected response from remote server:'), l)
1805 if resp == 1:
1806 raise util.Abort(_('operation forbidden by server'))
1807 elif resp == 2:
1808 raise util.Abort(_('locking the remote repository failed'))
1809 elif resp != 0:
1810 raise util.Abort(_('the server sent an unknown error code'))
1811
1812 streamclone.applyremotedata(self, remotereqs, rbranchmap, fp)
1813 return len(self.heads()) + 1
1814
1815 1791 def clone(self, remote, heads=[], stream=None):
1816 1792 '''clone remote repository.
1817 1793
@@ -1834,7 +1810,7 b' class localrepository(object):'
1834 1810 if stream and not heads:
1835 1811 # 'stream' means remote revlog format is revlogv1 only
1836 1812 if remote.capable('stream'):
1837 self.stream_in(remote, set(('revlogv1',)))
1813 streamclone.streamin(self, remote, set(('revlogv1',)))
1838 1814 else:
1839 1815 # otherwise, 'streamreqs' contains the remote revlog format
1840 1816 streamreqs = remote.capable('streamreqs')
@@ -1842,7 +1818,7 b' class localrepository(object):'
1842 1818 streamreqs = set(streamreqs.split(','))
1843 1819 # if we support it, stream in and adjust our requirements
1844 1820 if not streamreqs - self.supportedformats:
1845 self.stream_in(remote, streamreqs)
1821 streamclone.streamin(self, remote, streamreqs)
1846 1822
1847 1823 # internal config: ui.quietbookmarkmove
1848 1824 quiet = self.ui.backupconfig('ui', 'quietbookmarkmove')
@@ -7,11 +7,38 b''
7 7
8 8 from __future__ import absolute_import
9 9
10 from .i18n import _
10 11 from . import (
11 12 branchmap,
13 error,
12 14 exchange,
15 util,
13 16 )
14 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
41
15 42 def applyremotedata(repo, remotereqs, remotebranchmap, fp):
16 43 """Apply stream clone data to a repository.
17 44
General Comments 0
You need to be logged in to leave comments. Login now