Rev 5978: Fix the test failure, streams should be closed. In the right order. in file:///home/vila/src/bzr/reviews/tarball-generator/

Vincent Ladeuil v.ladeuil+lp at free.fr
Tue Jun 7 13:33:41 UTC 2011


At file:///home/vila/src/bzr/reviews/tarball-generator/

------------------------------------------------------------
revno: 5978
revision-id: v.ladeuil+lp at free.fr-20110607133341-5vs6tj04kn1z9bvt
parent: geoffreyfishing at gmail.com-20110606170837-prj4v9au7cfevwfk
committer: Vincent Ladeuil <v.ladeuil+lp at free.fr>
branch nick: tarball-generator
timestamp: Tue 2011-06-07 15:33:41 +0200
message:
  Fix the test failure, streams should be closed. In the right order.
-------------- next part --------------
=== modified file 'bzrlib/export/tar_exporter.py'
--- a/bzrlib/export/tar_exporter.py	2011-06-06 09:31:59 +0000
+++ b/bzrlib/export/tar_exporter.py	2011-06-07 13:33:41 +0000
@@ -83,9 +83,8 @@
         item.linkname = tree.get_symlink_target(entry.file_id)
         fileobj = None
     else:
-        raise errors.BzrError("don't know how to export {%s} of kind %r" 
+        raise errors.BzrError("don't know how to export {%s} of kind %r"
                               % (entry.file_id, entry.kind))
-    
     return (item, fileobj)
 
 def export_tarball_generator(tree, ball, root, subdir=None, filtered=False,
@@ -164,9 +163,12 @@
                                       force_mtime):
 
         yield
-
+    # Closing ball may trigger writes to zipstream
+    ball.close()
+    # Closing zipstream may trigger writes to stream
     zipstream.close()
     if not is_stdout:
+        # Now we can safely close the stream
         stream.close()
 
 

=== modified file 'bzrlib/export/zip_exporter.py'
--- a/bzrlib/export/zip_exporter.py	2011-06-03 17:40:45 +0000
+++ b/bzrlib/export/zip_exporter.py	2011-06-07 13:33:41 +0000
@@ -103,7 +103,6 @@
                 zinfo.compress_type = compression
                 zinfo.external_attr = _FILE_ATTR
                 zipf.writestr(zinfo, tree.get_symlink_target(file_id))
-            
             yield
 
         zipf.close()
@@ -113,10 +112,10 @@
         os.remove(dest)
         from bzrlib.errors import BzrError
         raise BzrError("Can't export non-ascii filenames to zip")
-    
-def zip_exporter(tree, dest, root, subdir=None, filtered=False, 
+
+
+def zip_exporter(tree, dest, root, subdir=None, filtered=False,
                  force_mtime=None, fileobj=None):
-    
     for _ in zip_exporter_generator(tree, dest, root, subdir, filtered,
                                     force_mtime, fileobj):
         pass

=== modified file 'bzrlib/tests/blackbox/test_export.py'
--- a/bzrlib/tests/blackbox/test_export.py	2011-05-13 12:51:05 +0000
+++ b/bzrlib/tests/blackbox/test_export.py	2011-06-07 13:33:41 +0000
@@ -174,8 +174,8 @@
     def run_tar_export_disk_and_stdout(self, extension, tarfile_flags):
         tree = self.make_basic_tree()
         fname = 'test.%s' % (extension,)
+        self.run_bzr('export -d tree %s' % (fname,))
         mode = 'r|%s' % (tarfile_flags,)
-        self.run_bzr('export -d tree %s' % (fname,))
         ball = tarfile.open(fname, mode=mode)
         self.assertTarANameAndContent(ball, root='test/')
         content = self.run_bzr('export -d tree --format=%s -' % (extension,))[0]



More information about the bazaar-commits mailing list