changeset 7446:2d2e0be762be

convert: work around svn.ra.get_files() not releasing input buffer
author Patrick Mezard <pmezard@gmail.com>
date Sun, 30 Nov 2008 22:01:26 +0100
parents 29c6e71b1c73
children 4fd92687f331
files hgext/convert/subversion.py
diffstat 1 files changed, 5 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- 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):