Show More
@@ -205,4 +205,5 b' def unbundle(repo, req):' | |||||
205 |
|
205 | |||
206 | def stream_out(repo, req): |
|
206 | def stream_out(repo, req): | |
207 | req.respond(HTTP_OK, HGTYPE) |
|
207 | req.respond(HTTP_OK, HGTYPE) | |
208 |
streamclone.stream_out(repo, |
|
208 | for chunk in streamclone.stream_out(repo, untrusted=True): | |
|
209 | req.write(chunk) |
@@ -204,4 +204,6 b' class sshserver(object):' | |||||
204 | os.unlink(tempname) |
|
204 | os.unlink(tempname) | |
205 |
|
205 | |||
206 | def do_stream_out(self): |
|
206 | def do_stream_out(self): | |
207 |
streamclone.stream_out(self.repo |
|
207 | for chunk in streamclone.stream_out(self.repo): | |
|
208 | self.fout.write(chunk) | |||
|
209 | self.fout.flush() |
@@ -51,12 +51,12 b' def walkrepo(root):' | |||||
51 | # |
|
51 | # | |
52 | # server writes out raw file data. |
|
52 | # server writes out raw file data. | |
53 |
|
53 | |||
54 |
def stream_out(repo, |
|
54 | def stream_out(repo, untrusted=False): | |
55 | '''stream out all metadata files in repository. |
|
55 | '''stream out all metadata files in repository. | |
56 | writes to file-like object, must support write() and optional flush().''' |
|
56 | writes to file-like object, must support write() and optional flush().''' | |
57 |
|
57 | |||
58 | if not repo.ui.configbool('server', 'uncompressed', untrusted=untrusted): |
|
58 | if not repo.ui.configbool('server', 'uncompressed', untrusted=untrusted): | |
59 |
|
|
59 | yield '1\n' | |
60 | return |
|
60 | return | |
61 |
|
61 | |||
62 | # get consistent snapshot of repo. lock during scan so lock not |
|
62 | # get consistent snapshot of repo. lock during scan so lock not | |
@@ -67,10 +67,10 b' def stream_out(repo, fileobj, untrusted=' | |||||
67 | repolock = repo.lock() |
|
67 | repolock = repo.lock() | |
68 | except (lock.LockHeld, lock.LockUnavailable), inst: |
|
68 | except (lock.LockHeld, lock.LockUnavailable), inst: | |
69 | repo.ui.warn('locking the repository failed: %s\n' % (inst,)) |
|
69 | repo.ui.warn('locking the repository failed: %s\n' % (inst,)) | |
70 |
|
|
70 | yield '2\n' | |
71 | return |
|
71 | return | |
72 |
|
72 | |||
73 |
|
|
73 | yield '0\n' | |
74 | repo.ui.debug('scanning\n') |
|
74 | repo.ui.debug('scanning\n') | |
75 | entries = [] |
|
75 | entries = [] | |
76 | total_bytes = 0 |
|
76 | total_bytes = 0 | |
@@ -83,11 +83,9 b' def stream_out(repo, fileobj, untrusted=' | |||||
83 |
|
83 | |||
84 | repo.ui.debug('%d files, %d bytes to transfer\n' % |
|
84 | repo.ui.debug('%d files, %d bytes to transfer\n' % | |
85 | (len(entries), total_bytes)) |
|
85 | (len(entries), total_bytes)) | |
86 |
|
|
86 | yield '%d %d\n' % (len(entries), total_bytes) | |
87 | for name, size in entries: |
|
87 | for name, size in entries: | |
88 | repo.ui.debug('sending %s (%d bytes)\n' % (name, size)) |
|
88 | repo.ui.debug('sending %s (%d bytes)\n' % (name, size)) | |
89 |
|
|
89 | yield '%s\0%d\n' % (name, size) | |
90 | for chunk in util.filechunkiter(repo.sopener(name), limit=size): |
|
90 | for chunk in util.filechunkiter(repo.sopener(name), limit=size): | |
91 |
|
|
91 | yield chunk | |
92 | flush = getattr(fileobj, 'flush', None) |
|
|||
93 | if flush: flush() |
|
General Comments 0
You need to be logged in to leave comments.
Login now