Show More
@@ -115,14 +115,25 b' class sshrepository(remoterepository):' | |||||
115 | return self.pipei |
|
115 | return self.pipei | |
116 |
|
116 | |||
117 | def call(self, cmd, **args): |
|
117 | def call(self, cmd, **args): | |
118 |
|
|
118 | self.do_cmd(cmd, **args) | |
119 | l = r.readline() |
|
119 | return self._recv() | |
|
120 | ||||
|
121 | def _recv(self): | |||
|
122 | l = self.pipei.readline() | |||
120 | self.readerr() |
|
123 | self.readerr() | |
121 | try: |
|
124 | try: | |
122 | l = int(l) |
|
125 | l = int(l) | |
123 | except: |
|
126 | except: | |
124 | self.raise_(util.UnexpectedOutput(_("unexpected response:"), l)) |
|
127 | self.raise_(util.UnexpectedOutput(_("unexpected response:"), l)) | |
125 |
return |
|
128 | return self.pipei.read(l) | |
|
129 | ||||
|
130 | def _send(self, data, flush=False): | |||
|
131 | self.pipeo.write("%d\n" % len(data)) | |||
|
132 | if data: | |||
|
133 | self.pipeo.write(data) | |||
|
134 | if flush: | |||
|
135 | self.pipeo.flush() | |||
|
136 | self.readerr() | |||
126 |
|
137 | |||
127 | def lock(self): |
|
138 | def lock(self): | |
128 | self.call("lock") |
|
139 | self.call("lock") | |
@@ -183,25 +194,22 b' class sshrepository(remoterepository):' | |||||
183 |
|
194 | |||
184 | while 1: |
|
195 | while 1: | |
185 | d = cg.read(4096) |
|
196 | d = cg.read(4096) | |
186 |
if not d: |
|
197 | if not d: | |
187 | self.pipeo.write(str(len(d)) + '\n') |
|
198 | break | |
188 |
self. |
|
199 | self._send(d) | |
189 | self.readerr() |
|
|||
190 |
|
200 | |||
191 | self.pipeo.write('0\n') |
|
201 | self._send("", flush=True) | |
192 | self.pipeo.flush() |
|
|||
193 |
|
202 | |||
194 |
self. |
|
203 | r = self._recv() | |
195 | l = int(self.pipei.readline()) |
|
|||
196 | r = self.pipei.read(l) |
|
|||
197 | if r: |
|
204 | if r: | |
198 | # remote may send "unsynced changes" |
|
205 | # remote may send "unsynced changes" | |
199 | self.raise_(hg.RepoError(_("push failed: %s") % r)) |
|
206 | self.raise_(hg.RepoError(_("push failed: %s") % r)) | |
200 |
|
207 | |||
201 |
self. |
|
208 | r = self._recv() | |
202 | l = int(self.pipei.readline()) |
|
209 | try: | |
203 | r = self.pipei.read(l) |
|
210 | return int(r) | |
204 | return int(r) |
|
211 | except: | |
|
212 | self.raise_(util.UnexpectedOutput(_("unexpected response:"), r)) | |||
205 |
|
213 | |||
206 | def addchangegroup(self, cg, source, url): |
|
214 | def addchangegroup(self, cg, source, url): | |
207 | d = self.call("addchangegroup") |
|
215 | d = self.call("addchangegroup") | |
@@ -209,18 +217,21 b' class sshrepository(remoterepository):' | |||||
209 | self.raise_(repo.RepoError(_("push refused: %s") % d)) |
|
217 | self.raise_(repo.RepoError(_("push refused: %s") % d)) | |
210 | while 1: |
|
218 | while 1: | |
211 | d = cg.read(4096) |
|
219 | d = cg.read(4096) | |
212 |
if not d: |
|
220 | if not d: | |
|
221 | break | |||
213 | self.pipeo.write(d) |
|
222 | self.pipeo.write(d) | |
214 | self.readerr() |
|
223 | self.readerr() | |
215 |
|
224 | |||
216 | self.pipeo.flush() |
|
225 | self.pipeo.flush() | |
217 |
|
226 | |||
218 | self.readerr() |
|
227 | self.readerr() | |
219 |
|
|
228 | r = self._recv() | |
220 | r = self.pipei.read(l) |
|
|||
221 | if not r: |
|
229 | if not r: | |
222 | return 1 |
|
230 | return 1 | |
223 | return int(r) |
|
231 | try: | |
|
232 | return int(r) | |||
|
233 | except: | |||
|
234 | self.raise_(util.UnexpectedOutput(_("unexpected response:"), r)) | |||
224 |
|
235 | |||
225 | def stream_out(self): |
|
236 | def stream_out(self): | |
226 | return self.do_cmd('stream_out') |
|
237 | return self.do_cmd('stream_out') |
@@ -27,6 +27,11 b' r = os.system(sys.argv[2])' | |||||
27 | sys.exit(bool(r)) |
|
27 | sys.exit(bool(r)) | |
28 | EOF |
|
28 | EOF | |
29 |
|
29 | |||
|
30 | cat <<EOF > badhook | |||
|
31 | import sys | |||
|
32 | sys.stdout.write("KABOOM") | |||
|
33 | EOF | |||
|
34 | ||||
30 | echo "# creating 'remote'" |
|
35 | echo "# creating 'remote'" | |
31 | hg init remote |
|
36 | hg init remote | |
32 | cd remote |
|
37 | cd remote | |
@@ -91,13 +96,16 b' hg cat -r tip foo' | |||||
91 |
|
96 | |||
92 | echo z > z |
|
97 | echo z > z | |
93 | hg ci -A -m z -d '1000001 0' z |
|
98 | hg ci -A -m z -d '1000001 0' z | |
|
99 | # a bad, evil hook that prints to stdout | |||
|
100 | echo 'changegroup.stdout = python ../badhook' >> .hg/hgrc | |||
94 |
|
101 | |||
95 | cd ../local |
|
102 | cd ../local | |
96 | echo r > r |
|
103 | echo r > r | |
97 | hg ci -A -m z -d '1000002 0' r |
|
104 | hg ci -A -m z -d '1000002 0' r | |
98 |
|
105 | |||
99 | echo "# push should succeed" |
|
106 | echo "# push should succeed even though it has an unexpected response" | |
100 | hg push |
|
107 | hg push | |
|
108 | hg -R ../remote heads | |||
101 |
|
109 | |||
102 | cd .. |
|
110 | cd .. | |
103 | cat dummylog |
|
111 | cat dummylog |
@@ -70,7 +70,7 b' crosschecking files in changesets and ma' | |||||
70 | checking files |
|
70 | checking files | |
71 | 2 files, 2 changesets, 3 total revisions |
|
71 | 2 files, 2 changesets, 3 total revisions | |
72 | bleah |
|
72 | bleah | |
73 | # push should succeed |
|
73 | # push should succeed even though it has an unexpected response | |
74 | pushing to ssh://user@dummy/remote |
|
74 | pushing to ssh://user@dummy/remote | |
75 | searching for changes |
|
75 | searching for changes | |
76 | note: unsynced remote changes! |
|
76 | note: unsynced remote changes! | |
@@ -78,6 +78,21 b' remote: adding changesets' | |||||
78 | remote: adding manifests |
|
78 | remote: adding manifests | |
79 | remote: adding file changes |
|
79 | remote: adding file changes | |
80 | remote: added 1 changesets with 1 changes to 1 files |
|
80 | remote: added 1 changesets with 1 changes to 1 files | |
|
81 | abort: unexpected response: | |||
|
82 | 'KABOOM1\n' | |||
|
83 | changeset: 3:ac7448082955 | |||
|
84 | tag: tip | |||
|
85 | parent: 1:572896fe480d | |||
|
86 | user: test | |||
|
87 | date: Mon Jan 12 13:46:42 1970 +0000 | |||
|
88 | summary: z | |||
|
89 | ||||
|
90 | changeset: 2:187c6caa0d1e | |||
|
91 | parent: 0:e34318c26897 | |||
|
92 | user: test | |||
|
93 | date: Mon Jan 12 13:46:41 1970 +0000 | |||
|
94 | summary: z | |||
|
95 | ||||
81 | Got arguments 1:user@dummy 2:hg -R nonexistent serve --stdio |
|
96 | Got arguments 1:user@dummy 2:hg -R nonexistent serve --stdio | |
82 | Got arguments 1:user@dummy 2:hg -R remote serve --stdio |
|
97 | Got arguments 1:user@dummy 2:hg -R remote serve --stdio | |
83 | Got arguments 1:user@dummy 2:hg -R remote serve --stdio |
|
98 | Got arguments 1:user@dummy 2:hg -R remote serve --stdio |
General Comments 0
You need to be logged in to leave comments.
Login now