[PATCH 1 of 1] subrepo: make stdin for svn a pipe for non-interactive use (issue2759)

Augie Fackler durin42 at gmail.com
Tue May 31 19:57:01 CDT 2011


# HG changeset patch
# User Augie Fackler <durin42 at gmail.com>
# Date 1306889357 18000
# Node ID f0f965098810259757c8254c375b24a540941712
# Parent  a086b91ce7fb91b5ab9bac3e482e40838f1f298c
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.

diff --git a/mercurial/subrepo.py b/mercurial/subrepo.py
--- a/mercurial/subrepo.py
+++ b/mercurial/subrepo.py
@@ -528,13 +528,17 @@
 
     def _svncommand(self, commands, filename=''):
         cmd = ['svn']
-        # Starting in svn 1.5 --non-interactive is a global flag
-        # instead of being per-command, but we need to support 1.4 so
-        # we have to be intelligent about what commands take
-        # --non-interactive.
-        if (not self._ui.interactive() and
-            commands[0] in ('update', 'checkout', 'commit')):
-            cmd.append('--non-interactive')
+        extrakw = {}
+        if not self._ui.interactive():
+            # Making stdin be a pipe should prevent svn from behaving
+            # interactively even if we can't pass --non-interactive.
+            extrakw['stdin'] = subprocess.PIPE
+            # Starting in svn 1.5 --non-interactive is a global flag
+            # instead of being per-command, but we need to support 1.4 so
+            # we have to be intelligent about what commands take
+            # --non-interactive.
+            if commands[0] in ('update', 'checkout', 'commit'):
+                cmd.append('--non-interactive')
         cmd.extend(commands)
         if filename is not None:
             path = os.path.join(self._ctx._repo.origroot, self._path, filename)
@@ -544,7 +548,7 @@
         env['LC_MESSAGES'] = 'C'
         p = subprocess.Popen(cmd, bufsize=-1, close_fds=util.closefds,
                              stdout=subprocess.PIPE, stderr=subprocess.PIPE,
-                              universal_newlines=True, env=env)
+                              universal_newlines=True, env=env, **extrakw)
         stdout, stderr = p.communicate()
         stderr = stderr.strip()
         if p.returncode:


More information about the Mercurial-devel mailing list