Show More
@@ -49,7 +49,10 b' class webproto(object):' | |||||
49 | break |
|
49 | break | |
50 | self.req.write(z.compress(chunk)) |
|
50 | self.req.write(z.compress(chunk)) | |
51 | self.req.write(z.flush()) |
|
51 | self.req.write(z.flush()) | |
52 |
|
52 | def sendstream(self, source): | ||
|
53 | self.req.respond(HTTP_OK, HGTYPE) | |||
|
54 | for chunk in source: | |||
|
55 | self.req.write(chunk) | |||
53 | def respond(self, s): |
|
56 | def respond(self, s): | |
54 | self.req.respond(HTTP_OK, HGTYPE, length=len(s)) |
|
57 | self.req.respond(HTTP_OK, HGTYPE, length=len(s)) | |
55 | self.response = s |
|
58 | self.response = s |
@@ -114,11 +114,3 b' def unbundle(repo, req):' | |||||
114 | finally: |
|
114 | finally: | |
115 | fp.close() |
|
115 | fp.close() | |
116 | os.unlink(tempname) |
|
116 | os.unlink(tempname) | |
117 |
|
||||
118 | def stream_out(repo, req): |
|
|||
119 | req.respond(HTTP_OK, HGTYPE) |
|
|||
120 | try: |
|
|||
121 | for chunk in streamclone.stream_out(repo): |
|
|||
122 | yield chunk |
|
|||
123 | except streamclone.StreamException, inst: |
|
|||
124 | yield str(inst) |
|
@@ -67,6 +67,11 b' class sshserver(object):' | |||||
67 |
|
67 | |||
68 | self.fout.flush() |
|
68 | self.fout.flush() | |
69 |
|
69 | |||
|
70 | def sendstream(self, source): | |||
|
71 | for chunk in source: | |||
|
72 | self.fout.write(chunk) | |||
|
73 | self.fout.flush() | |||
|
74 | ||||
70 | def serve_forever(self): |
|
75 | def serve_forever(self): | |
71 | try: |
|
76 | try: | |
72 | while self.serve_one(): |
|
77 | while self.serve_one(): | |
@@ -177,12 +182,3 b' class sshserver(object):' | |||||
177 | finally: |
|
182 | finally: | |
178 | fp.close() |
|
183 | fp.close() | |
179 | os.unlink(tempname) |
|
184 | os.unlink(tempname) | |
180 |
|
||||
181 | def do_stream_out(self): |
|
|||
182 | try: |
|
|||
183 | for chunk in streamclone.stream_out(self.repo): |
|
|||
184 | self.fout.write(chunk) |
|
|||
185 | self.fout.flush() |
|
|||
186 | except streamclone.StreamException, inst: |
|
|||
187 | self.fout.write(str(inst)) |
|
|||
188 | self.fout.flush() |
|
@@ -7,7 +7,7 b'' | |||||
7 |
|
7 | |||
8 | from i18n import _ |
|
8 | from i18n import _ | |
9 | from node import bin, hex |
|
9 | from node import bin, hex | |
10 | import urllib |
|
10 | import urllib, streamclone | |
11 | import pushkey as pushkey_ |
|
11 | import pushkey as pushkey_ | |
12 |
|
12 | |||
13 | def dispatch(repo, proto, command): |
|
13 | def dispatch(repo, proto, command): | |
@@ -77,6 +77,12 b' def pushkey(repo, proto, namespace, key,' | |||||
77 | r = pushkey_.push(repo, namespace, key, old, new) |
|
77 | r = pushkey_.push(repo, namespace, key, old, new) | |
78 | return '%s\n' % int(r) |
|
78 | return '%s\n' % int(r) | |
79 |
|
79 | |||
|
80 | def stream(repo, proto): | |||
|
81 | try: | |||
|
82 | proto.sendstream(streamclone.stream_out(repo)) | |||
|
83 | except streamclone.StreamException, inst: | |||
|
84 | return str(inst) | |||
|
85 | ||||
80 | commands = { |
|
86 | commands = { | |
81 | 'between': (between, 'pairs'), |
|
87 | 'between': (between, 'pairs'), | |
82 | 'branchmap': (branchmap, ''), |
|
88 | 'branchmap': (branchmap, ''), | |
@@ -87,4 +93,5 b' commands = {' | |||||
87 | 'listkeys': (listkeys, 'namespace'), |
|
93 | 'listkeys': (listkeys, 'namespace'), | |
88 | 'lookup': (lookup, 'key'), |
|
94 | 'lookup': (lookup, 'key'), | |
89 | 'pushkey': (pushkey, 'namespace key old new'), |
|
95 | 'pushkey': (pushkey, 'namespace key old new'), | |
|
96 | 'stream_out': (stream, ''), | |||
90 | } |
|
97 | } |
General Comments 0
You need to be logged in to leave comments.
Login now