##// END OF EJS Templates
bundle2: read the whole bundle from stream on abort...
Pierre-Yves David -
r20892:6fe95448 default
parent child Browse files
Show More
@@ -130,8 +130,11 b' The matching of a part to its handler is'
130 130 part type is used to know if a part is mandatory or advisory. If the Part type
131 131 contains any uppercase char it is considered mandatory. When no handler is
132 132 known for a Mandatory part, the process is aborted and an exception is raised.
133 If the part is advisory and no handler is known, the part is ignored.
134
133 If the part is advisory and no handler is known, the part is ignored. When the
134 process is aborted, the full bundle is still read from the stream to keep the
135 channel usable. But none of the part read from an abort are processed. In the
136 future, dropping the stream may become an option for channel we do not care to
137 preserve.
135 138 """
136 139
137 140 import util
@@ -205,23 +208,29 b' def processbundle(repo, stream):'
205 208 # - replace this is a init function soon.
206 209 # - exception catching
207 210 unbundler.params
208 for part in unbundler:
209 parttype = part.type
210 # part key are matched lower case
211 key = parttype.lower()
212 try:
213 handler = parthandlermapping[key]
214 ui.debug('found an handler for part %r\n' % parttype)
215 except KeyError:
216 if key != parttype: # mandatory parts
211 iterparts = iter(unbundler)
212 try:
213 for part in iterparts:
214 parttype = part.type
215 # part key are matched lower case
216 key = parttype.lower()
217 try:
218 handler = parthandlermapping[key]
219 ui.debug('found an handler for part %r\n' % parttype)
220 except KeyError:
221 if key != parttype: # mandatory parts
222 # todo:
223 # - use a more precise exception
224 raise
225 ui.debug('ignoring unknown advisory part %r\n' % key)
217 226 # todo:
218 # - use a more precise exception
219 # - consume the bundle2 stream anyway.
220 raise
221 ui.debug('ignoring unknown advisory part %r\n' % key)
222 # todo: consume the part (once we use streamed parts)
223 continue
224 handler(repo, part)
227 # - consume the part once we use streaming
228 continue
229 handler(repo, part)
230 except Exception:
231 for part in iterparts:
232 pass # consume the bundle content
233 raise
225 234
226 235 class bundle20(object):
227 236 """represent an outgoing bundle2 container
@@ -72,9 +72,13 b' Create an extension to test bundle2 API'
72 72 > def cmdunbundle2(ui, repo):
73 73 > """process a bundle2 stream from stdin on the current repo"""
74 74 > try:
75 > bundle2.processbundle(repo, sys.stdin)
76 > except KeyError, exc:
77 > raise util.Abort('missing support for %s' % exc)
75 > try:
76 > bundle2.processbundle(repo, sys.stdin)
77 > except KeyError, exc:
78 > raise util.Abort('missing support for %s' % exc)
79 > finally:
80 > remains = sys.stdin.read()
81 > ui.write('%i unread bytes\n' % len(remains))
78 82 >
79 83 > @command('statbundle2', [], '')
80 84 > def cmdstatbundle2(ui, repo):
@@ -385,6 +389,7 b' Process the bundle'
385 389 ignoring unknown advisory part 'test:math'
386 390 part header size: 0
387 391 end of bundle2 stream
392 0 unread bytes
388 393
389 394
390 395 $ hg bundle2 --parts --unknown ../unknown.hg2
@@ -394,5 +399,6 b' Process the bundle'
394 399 Patali Dirapata, Cromda Cromda Ripalo, Pata Pata, Ko Ko Ko
395 400 Bokoro Dipoulito, Rondi Rondi Pepino, Pata Pata, Ko Ko Ko
396 401 Emana Karassoli, Loucra Loucra Ponponto, Pata Pata, Ko Ko Ko.
402 0 unread bytes
397 403 abort: missing support for 'test:unknown'
398 404 [255]
General Comments 0
You need to be logged in to leave comments. Login now