1786 """Return util.hooks consists of "(repo, remote, outgoing)" |
1786 """Return util.hooks consists of "(repo, remote, outgoing)" |
1787 functions, which are called before pushing changesets. |
1787 functions, which are called before pushing changesets. |
1788 """ |
1788 """ |
1789 return util.hooks() |
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 def clone(self, remote, heads=[], stream=None): |
1791 def clone(self, remote, heads=[], stream=None): |
1816 '''clone remote repository. |
1792 '''clone remote repository. |
1817 |
1793 |
1818 keyword arguments: |
1794 keyword arguments: |
1819 heads: list of revs to clone (forces use of pull) |
1795 heads: list of revs to clone (forces use of pull) |
1832 stream = remote.capable('stream-preferred') |
1808 stream = remote.capable('stream-preferred') |
1833 |
1809 |
1834 if stream and not heads: |
1810 if stream and not heads: |
1835 # 'stream' means remote revlog format is revlogv1 only |
1811 # 'stream' means remote revlog format is revlogv1 only |
1836 if remote.capable('stream'): |
1812 if remote.capable('stream'): |
1837 self.stream_in(remote, set(('revlogv1',))) |
1813 streamclone.streamin(self, remote, set(('revlogv1',))) |
1838 else: |
1814 else: |
1839 # otherwise, 'streamreqs' contains the remote revlog format |
1815 # otherwise, 'streamreqs' contains the remote revlog format |
1840 streamreqs = remote.capable('streamreqs') |
1816 streamreqs = remote.capable('streamreqs') |
1841 if streamreqs: |
1817 if streamreqs: |
1842 streamreqs = set(streamreqs.split(',')) |
1818 streamreqs = set(streamreqs.split(',')) |
1843 # if we support it, stream in and adjust our requirements |
1819 # if we support it, stream in and adjust our requirements |
1844 if not streamreqs - self.supportedformats: |
1820 if not streamreqs - self.supportedformats: |
1845 self.stream_in(remote, streamreqs) |
1821 streamclone.streamin(self, remote, streamreqs) |
1846 |
1822 |
1847 # internal config: ui.quietbookmarkmove |
1823 # internal config: ui.quietbookmarkmove |
1848 quiet = self.ui.backupconfig('ui', 'quietbookmarkmove') |
1824 quiet = self.ui.backupconfig('ui', 'quietbookmarkmove') |
1849 try: |
1825 try: |
1850 self.ui.setconfig('ui', 'quietbookmarkmove', True, 'clone') |
1826 self.ui.setconfig('ui', 'quietbookmarkmove', True, 'clone') |