Comments
Patch
@@ -549,8 +549,12 @@ class bundle20(object):
if param:
yield param
# starting compression
- for chunk in self._getcorechunk():
- yield self._compressor.compress(chunk)
+ g = self._getcorechunk()
+ try:
+ for chunk in g:
+ yield self._compressor.compress(chunk)
+ finally:
+ g.close()
yield self._compressor.flush()
def _paramchunk(self):
@@ -571,8 +575,12 @@ class bundle20(object):
outdebug(self.ui, 'start of parts')
for part in self._parts:
outdebug(self.ui, 'bundle part: "%s"' % part.type)
- for chunk in part.getchunks(ui=self.ui):
- yield chunk
+ g = part.getchunks(ui=self.ui)
+ try:
+ for chunk in g:
+ yield chunk
+ finally:
+ g.close()
outdebug(self.ui, 'end of bundle')
yield _pack(_fpartheadersize, 0)
@@ -150,7 +150,8 @@ Create an extension to test bundle2 API
>
> if opts['timeout']:
> bundler.newpart('test:song', data=ELEPHANTSSONG, mandatory=False)
- > for idx, junk in enumerate(bundler.getchunks()):
+ > g = bundler.getchunks()
+ > for idx, junk in enumerate(g):
> ui.write('%d chunk\n' % idx)
> if idx > 4:
> # This throws a GeneratorExit inside the generator, which
@@ -158,7 +159,7 @@ Create an extension to test bundle2 API
> # too zealous. It's important for this test that the break
> # occur while we're in the middle of a part.
> break
- > gc.collect()
+ > g.close()
> ui.write('fake timeout complete.\n')
> return
> try: