convert: work around svn.ra.get_files() not releasing input buffer
authorPatrick Mezard <pmezard@gmail.com>
Sun, 30 Nov 2008 22:01:26 +0100
changeset 7446 2d2e0be762be
parent 7445 29c6e71b1c73
child 7447 4fd92687f331
convert: work around svn.ra.get_files() not releasing input buffer
hgext/convert/subversion.py
--- a/hgext/convert/subversion.py	Sun Nov 30 18:38:42 2008 +0100
+++ b/hgext/convert/subversion.py	Sun Nov 30 22:01:26 2008 +0100
@@ -851,7 +851,6 @@
             raise
 
     def _getfile(self, file, rev):
-        io = StringIO()
         # TODO: ra.get_file transmits the whole file instead of diffs.
         mode = ''
         try:
@@ -859,7 +858,12 @@
             if self.module != new_module:
                 self.module = new_module
                 self.reparent(self.module)
+            io = StringIO()
             info = svn.ra.get_file(self.ra, file, revnum, io)
+            data = io.getvalue()
+            # ra.get_files() seems to keep a reference on the input buffer
+            # preventing collection. Release it explicitely.
+            io.close()
             if isinstance(info, list):
                 info = info[-1]
             mode = ("svn:executable" in info) and 'x' or ''
@@ -870,7 +874,6 @@
             if e.apr_err in notfound: # File not found
                 raise IOError()
             raise
-        data = io.getvalue()
         if mode == 'l':
             link_prefix = "link "
             if data.startswith(link_prefix):