Show More
@@ -5,8 +5,7 b'' | |||||
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 base64, errno |
|
8 | import base64, errno, subprocess, os | |
9 | import os |
|
|||
10 | import cPickle as pickle |
|
9 | import cPickle as pickle | |
11 | from mercurial import util |
|
10 | from mercurial import util | |
12 | from mercurial.i18n import _ |
|
11 | from mercurial.i18n import _ | |
@@ -260,7 +259,7 b' class commandline(object):' | |||||
260 | def postrun(self): |
|
259 | def postrun(self): | |
261 | pass |
|
260 | pass | |
262 |
|
261 | |||
263 |
def _cmdline(self, cmd, |
|
262 | def _cmdline(self, cmd, *args, **kwargs): | |
264 | cmdline = [self.command, cmd] + list(args) |
|
263 | cmdline = [self.command, cmd] + list(args) | |
265 | for k, v in kwargs.iteritems(): |
|
264 | for k, v in kwargs.iteritems(): | |
266 | if len(k) == 1: |
|
265 | if len(k) == 1: | |
@@ -277,19 +276,22 b' class commandline(object):' | |||||
277 | cmdline = [util.shellquote(arg) for arg in cmdline] |
|
276 | cmdline = [util.shellquote(arg) for arg in cmdline] | |
278 | if not self.ui.debugflag: |
|
277 | if not self.ui.debugflag: | |
279 | cmdline += ['2>', os.devnull] |
|
278 | cmdline += ['2>', os.devnull] | |
280 | if closestdin: |
|
|||
281 | cmdline += ['<', os.devnull] |
|
|||
282 | cmdline = ' '.join(cmdline) |
|
279 | cmdline = ' '.join(cmdline) | |
283 | return cmdline |
|
280 | return cmdline | |
284 |
|
281 | |||
285 | def _run(self, cmd, *args, **kwargs): |
|
282 | def _run(self, cmd, *args, **kwargs): | |
286 | return self._dorun(util.popen, cmd, True, *args, **kwargs) |
|
283 | def popen(cmdline): | |
|
284 | p = subprocess.Popen(cmdline, shell=True, bufsize=-1, | |||
|
285 | close_fds=util.closefds, | |||
|
286 | stdout=subprocess.PIPE) | |||
|
287 | return p | |||
|
288 | return self._dorun(popen, cmd, *args, **kwargs) | |||
287 |
|
289 | |||
288 | def _run2(self, cmd, *args, **kwargs): |
|
290 | def _run2(self, cmd, *args, **kwargs): | |
289 |
return self._dorun(util.popen2, cmd, |
|
291 | return self._dorun(util.popen2, cmd, *args, **kwargs) | |
290 |
|
292 | |||
291 |
def _dorun(self, openfunc, cmd, |
|
293 | def _dorun(self, openfunc, cmd, *args, **kwargs): | |
292 |
cmdline = self._cmdline(cmd, |
|
294 | cmdline = self._cmdline(cmd, *args, **kwargs) | |
293 | self.ui.debug('running: %s\n' % (cmdline,)) |
|
295 | self.ui.debug('running: %s\n' % (cmdline,)) | |
294 | self.prerun() |
|
296 | self.prerun() | |
295 | try: |
|
297 | try: | |
@@ -298,16 +300,17 b' class commandline(object):' | |||||
298 | self.postrun() |
|
300 | self.postrun() | |
299 |
|
301 | |||
300 | def run(self, cmd, *args, **kwargs): |
|
302 | def run(self, cmd, *args, **kwargs): | |
301 |
|
|
303 | p = self._run(cmd, *args, **kwargs) | |
302 |
output = |
|
304 | output = p.communicate()[0] | |
303 | self.ui.debug(output) |
|
305 | self.ui.debug(output) | |
304 |
return output, |
|
306 | return output, p.returncode | |
305 |
|
307 | |||
306 | def runlines(self, cmd, *args, **kwargs): |
|
308 | def runlines(self, cmd, *args, **kwargs): | |
307 |
|
|
309 | p = self._run(cmd, *args, **kwargs) | |
308 |
output = |
|
310 | output = p.stdout.readlines() | |
|
311 | p.wait() | |||
309 | self.ui.debug(''.join(output)) |
|
312 | self.ui.debug(''.join(output)) | |
310 |
return output, |
|
313 | return output, p.returncode | |
311 |
|
314 | |||
312 | def checkexit(self, status, output=''): |
|
315 | def checkexit(self, status, output=''): | |
313 | if status: |
|
316 | if status: |
@@ -104,9 +104,10 b' class darcs_source(converter_source, com' | |||||
104 | # possible, etree will still raise an exception if any |
|
104 | # possible, etree will still raise an exception if any | |
105 | # non-printable characters are in the XML changelog. |
|
105 | # non-printable characters are in the XML changelog. | |
106 | parser = XMLParser(encoding='latin-1') |
|
106 | parser = XMLParser(encoding='latin-1') | |
107 |
|
|
107 | p = self._run(cmd, **kwargs) | |
108 |
etree.parse( |
|
108 | etree.parse(p.stdout, parser=parser) | |
109 | self.checkexit(fp.close()) |
|
109 | p.wait() | |
|
110 | self.checkexit(p.returncode) | |||
110 | return etree.getroot() |
|
111 | return etree.getroot() | |
111 |
|
112 | |||
112 | def format(self): |
|
113 | def format(self): |
General Comments 0
You need to be logged in to leave comments.
Login now