comparison mercurial/subrepo.py @ 14492:f0f965098810

subrepo: make stdin for svn a pipe for non-interactive use (issue2759) This certainly can't hurt, so go ahead and do it, potentially along with --non-interactive if that flag is safe for the given subcommand.
author Augie Fackler <durin42@gmail.com>
date Tue, 31 May 2011 19:49:17 -0500
parents 278a4e0fdfed
children 4f695345979c
comparison
equal deleted inserted replaced
14491:a086b91ce7fb 14492:f0f965098810
526 self._ctx = ctx 526 self._ctx = ctx
527 self._ui = ctx._repo.ui 527 self._ui = ctx._repo.ui
528 528
529 def _svncommand(self, commands, filename=''): 529 def _svncommand(self, commands, filename=''):
530 cmd = ['svn'] 530 cmd = ['svn']
531 # Starting in svn 1.5 --non-interactive is a global flag 531 extrakw = {}
532 # instead of being per-command, but we need to support 1.4 so 532 if not self._ui.interactive():
533 # we have to be intelligent about what commands take 533 # Making stdin be a pipe should prevent svn from behaving
534 # --non-interactive. 534 # interactively even if we can't pass --non-interactive.
535 if (not self._ui.interactive() and 535 extrakw['stdin'] = subprocess.PIPE
536 commands[0] in ('update', 'checkout', 'commit')): 536 # Starting in svn 1.5 --non-interactive is a global flag
537 cmd.append('--non-interactive') 537 # instead of being per-command, but we need to support 1.4 so
538 # we have to be intelligent about what commands take
539 # --non-interactive.
540 if commands[0] in ('update', 'checkout', 'commit'):
541 cmd.append('--non-interactive')
538 cmd.extend(commands) 542 cmd.extend(commands)
539 if filename is not None: 543 if filename is not None:
540 path = os.path.join(self._ctx._repo.origroot, self._path, filename) 544 path = os.path.join(self._ctx._repo.origroot, self._path, filename)
541 cmd.append(path) 545 cmd.append(path)
542 env = dict(os.environ) 546 env = dict(os.environ)
543 # Avoid localized output, preserve current locale for everything else. 547 # Avoid localized output, preserve current locale for everything else.
544 env['LC_MESSAGES'] = 'C' 548 env['LC_MESSAGES'] = 'C'
545 p = subprocess.Popen(cmd, bufsize=-1, close_fds=util.closefds, 549 p = subprocess.Popen(cmd, bufsize=-1, close_fds=util.closefds,
546 stdout=subprocess.PIPE, stderr=subprocess.PIPE, 550 stdout=subprocess.PIPE, stderr=subprocess.PIPE,
547 universal_newlines=True, env=env) 551 universal_newlines=True, env=env, **extrakw)
548 stdout, stderr = p.communicate() 552 stdout, stderr = p.communicate()
549 stderr = stderr.strip() 553 stderr = stderr.strip()
550 if p.returncode: 554 if p.returncode:
551 raise util.Abort(stderr or 'exited with code %d' % p.returncode) 555 raise util.Abort(stderr or 'exited with code %d' % p.returncode)
552 if stderr: 556 if stderr: