Mercurial > public > mercurial-scm > hg
comparison mercurial/subrepo.py @ 13014:d1c52354b0a9 stable
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.
author | Patrick Mezard <pmezard@gmail.com> |
---|---|
date | Wed, 17 Nov 2010 21:24:36 +0100 |
parents | 92b0d669637f |
children | 82ca0c43bc44 |
comparison
equal
deleted
inserted
replaced
13013:92b0d669637f | 13014:d1c52354b0a9 |
---|---|
4 # | 4 # |
5 # This software may be used and distributed according to the terms of the | 5 # This software may be used and distributed according to the terms of the |
6 # GNU General Public License version 2 or any later version. | 6 # GNU General Public License version 2 or any later version. |
7 | 7 |
8 import errno, os, re, xml.dom.minidom, shutil, urlparse, posixpath | 8 import errno, os, re, xml.dom.minidom, shutil, urlparse, posixpath |
9 import stat | 9 import stat, subprocess |
10 from i18n import _ | 10 from i18n import _ |
11 import config, util, node, error, cmdutil | 11 import config, util, node, error, cmdutil |
12 hg = None | 12 hg = None |
13 | 13 |
14 nullstate = ('', '', 'empty') | 14 nullstate = ('', '', 'empty') |
479 cmd = [util.shellquote(arg) for arg in cmd] | 479 cmd = [util.shellquote(arg) for arg in cmd] |
480 cmd = util.quotecommand(' '.join(cmd)) | 480 cmd = util.quotecommand(' '.join(cmd)) |
481 env = dict(os.environ) | 481 env = dict(os.environ) |
482 # Avoid localized output, preserve current locale for everything else. | 482 # Avoid localized output, preserve current locale for everything else. |
483 env['LC_MESSAGES'] = 'C' | 483 env['LC_MESSAGES'] = 'C' |
484 write, read, err = util.popen3(cmd, env=env, newlines=True) | 484 p = subprocess.Popen(cmd, shell=True, bufsize=-1, |
485 retdata = read.read() | 485 close_fds=util.closefds, |
486 err = err.read().strip() | 486 stdout=subprocess.PIPE, stderr=subprocess.PIPE, |
487 if err: | 487 universal_newlines=True, env=env) |
488 raise util.Abort(err) | 488 stdout, stderr = p.communicate() |
489 return retdata | 489 stderr = stderr.strip() |
490 if stderr: | |
491 raise util.Abort(stderr) | |
492 return stdout | |
490 | 493 |
491 def _wcrev(self): | 494 def _wcrev(self): |
492 output = self._svncommand(['info', '--xml']) | 495 output = self._svncommand(['info', '--xml']) |
493 doc = xml.dom.minidom.parseString(output) | 496 doc = xml.dom.minidom.parseString(output) |
494 entries = doc.getElementsByTagName('entry') | 497 entries = doc.getElementsByTagName('entry') |