Show More
@@ -1909,59 +1909,63 b' class localrepository(repo.repository):' | |||||
1909 |
|
1909 | |||
1910 |
|
1910 | |||
1911 | def stream_in(self, remote, requirements): |
|
1911 | def stream_in(self, remote, requirements): | |
1912 | fp = remote.stream_out() |
|
1912 | lock = self.lock() | |
1913 | l = fp.readline() |
|
|||
1914 | try: |
|
1913 | try: | |
1915 |
|
|
1914 | fp = remote.stream_out() | |
1916 | except ValueError: |
|
|||
1917 | raise error.ResponseError( |
|
|||
1918 | _('Unexpected response from remote server:'), l) |
|
|||
1919 | if resp == 1: |
|
|||
1920 | raise util.Abort(_('operation forbidden by server')) |
|
|||
1921 | elif resp == 2: |
|
|||
1922 | raise util.Abort(_('locking the remote repository failed')) |
|
|||
1923 | elif resp != 0: |
|
|||
1924 | raise util.Abort(_('the server sent an unknown error code')) |
|
|||
1925 | self.ui.status(_('streaming all changes\n')) |
|
|||
1926 | l = fp.readline() |
|
|||
1927 | try: |
|
|||
1928 | total_files, total_bytes = map(int, l.split(' ', 1)) |
|
|||
1929 | except (ValueError, TypeError): |
|
|||
1930 | raise error.ResponseError( |
|
|||
1931 | _('Unexpected response from remote server:'), l) |
|
|||
1932 | self.ui.status(_('%d files to transfer, %s of data\n') % |
|
|||
1933 | (total_files, util.bytecount(total_bytes))) |
|
|||
1934 | start = time.time() |
|
|||
1935 | for i in xrange(total_files): |
|
|||
1936 | # XXX doesn't support '\n' or '\r' in filenames |
|
|||
1937 | l = fp.readline() |
|
1915 | l = fp.readline() | |
1938 | try: |
|
1916 | try: | |
1939 |
|
|
1917 | resp = int(l) | |
1940 | size = int(size) |
|
1918 | except ValueError: | |
|
1919 | raise error.ResponseError( | |||
|
1920 | _('Unexpected response from remote server:'), l) | |||
|
1921 | if resp == 1: | |||
|
1922 | raise util.Abort(_('operation forbidden by server')) | |||
|
1923 | elif resp == 2: | |||
|
1924 | raise util.Abort(_('locking the remote repository failed')) | |||
|
1925 | elif resp != 0: | |||
|
1926 | raise util.Abort(_('the server sent an unknown error code')) | |||
|
1927 | self.ui.status(_('streaming all changes\n')) | |||
|
1928 | l = fp.readline() | |||
|
1929 | try: | |||
|
1930 | total_files, total_bytes = map(int, l.split(' ', 1)) | |||
1941 | except (ValueError, TypeError): |
|
1931 | except (ValueError, TypeError): | |
1942 | raise error.ResponseError( |
|
1932 | raise error.ResponseError( | |
1943 | _('Unexpected response from remote server:'), l) |
|
1933 | _('Unexpected response from remote server:'), l) | |
1944 | self.ui.debug('adding %s (%s)\n' % (name, util.bytecount(size))) |
|
1934 | self.ui.status(_('%d files to transfer, %s of data\n') % | |
1945 | # for backwards compat, name was partially encoded |
|
1935 | (total_files, util.bytecount(total_bytes))) | |
1946 | ofp = self.sopener(store.decodedir(name), 'w') |
|
1936 | start = time.time() | |
1947 | for chunk in util.filechunkiter(fp, limit=size): |
|
1937 | for i in xrange(total_files): | |
1948 | ofp.write(chunk) |
|
1938 | # XXX doesn't support '\n' or '\r' in filenames | |
1949 |
|
|
1939 | l = fp.readline() | |
1950 | elapsed = time.time() - start |
|
1940 | try: | |
1951 | if elapsed <= 0: |
|
1941 | name, size = l.split('\0', 1) | |
1952 | elapsed = 0.001 |
|
1942 | size = int(size) | |
1953 | self.ui.status(_('transferred %s in %.1f seconds (%s/sec)\n') % |
|
1943 | except (ValueError, TypeError): | |
1954 | (util.bytecount(total_bytes), elapsed, |
|
1944 | raise error.ResponseError( | |
1955 | util.bytecount(total_bytes / elapsed))) |
|
1945 | _('Unexpected response from remote server:'), l) | |
|
1946 | self.ui.debug('adding %s (%s)\n' % (name, util.bytecount(size))) | |||
|
1947 | # for backwards compat, name was partially encoded | |||
|
1948 | ofp = self.sopener(store.decodedir(name), 'w') | |||
|
1949 | for chunk in util.filechunkiter(fp, limit=size): | |||
|
1950 | ofp.write(chunk) | |||
|
1951 | ofp.close() | |||
|
1952 | elapsed = time.time() - start | |||
|
1953 | if elapsed <= 0: | |||
|
1954 | elapsed = 0.001 | |||
|
1955 | self.ui.status(_('transferred %s in %.1f seconds (%s/sec)\n') % | |||
|
1956 | (util.bytecount(total_bytes), elapsed, | |||
|
1957 | util.bytecount(total_bytes / elapsed))) | |||
1956 |
|
1958 | |||
1957 | # new requirements = old non-format requirements + new format-related |
|
1959 | # new requirements = old non-format requirements + new format-related | |
1958 | # requirements from the streamed-in repository |
|
1960 | # requirements from the streamed-in repository | |
1959 | requirements.update(set(self.requirements) - self.supportedformats) |
|
1961 | requirements.update(set(self.requirements) - self.supportedformats) | |
1960 | self._applyrequirements(requirements) |
|
1962 | self._applyrequirements(requirements) | |
1961 | self._writerequirements() |
|
1963 | self._writerequirements() | |
1962 |
|
1964 | |||
1963 | self.invalidate() |
|
1965 | self.invalidate() | |
1964 | return len(self.heads()) + 1 |
|
1966 | return len(self.heads()) + 1 | |
|
1967 | finally: | |||
|
1968 | lock.release() | |||
1965 |
|
1969 | |||
1966 | def clone(self, remote, heads=[], stream=False): |
|
1970 | def clone(self, remote, heads=[], stream=False): | |
1967 | '''clone remote repository. |
|
1971 | '''clone remote repository. |
General Comments 0
You need to be logged in to leave comments.
Login now