# HG changeset patch # User Patrick Mezard # Date 2010-11-17 20:24:36 # Node ID d1c52354b0a9535076bc9045d931cf41253ac24f # Parent 92b0d669637ffbce6d5c7abba4721a5fa0204d77 subrepo: use subprocess directly to avoid python 2.6 bug Using svn subrepos on MacOSX with native python 2.6.1 results in a lot of unexpected output caused by: http://bugs.python.org/issue5099 subprocess.Popen.__del__ causes AttributeError (os module == None) Avoiding dangling Popen instance solves the issue. diff --git a/mercurial/subrepo.py b/mercurial/subrepo.py --- a/mercurial/subrepo.py +++ b/mercurial/subrepo.py @@ -6,7 +6,7 @@ # GNU General Public License version 2 or any later version. import errno, os, re, xml.dom.minidom, shutil, urlparse, posixpath -import stat +import stat, subprocess from i18n import _ import config, util, node, error, cmdutil hg = None @@ -481,12 +481,15 @@ class svnsubrepo(abstractsubrepo): env = dict(os.environ) # Avoid localized output, preserve current locale for everything else. env['LC_MESSAGES'] = 'C' - write, read, err = util.popen3(cmd, env=env, newlines=True) - retdata = read.read() - err = err.read().strip() - if err: - raise util.Abort(err) - return retdata + p = subprocess.Popen(cmd, shell=True, bufsize=-1, + close_fds=util.closefds, + stdout=subprocess.PIPE, stderr=subprocess.PIPE, + universal_newlines=True, env=env) + stdout, stderr = p.communicate() + stderr = stderr.strip() + if stderr: + raise util.Abort(stderr) + return stdout def _wcrev(self): output = self._svncommand(['info', '--xml'])