----- Original Message -----
From: cmpilato@collab.net
To: Chris Foote Chris.Foote@v21.me.uk
Cc: dev@subversion.tigris.org
Sent: Tuesday, January 28, 2003 1:01 AM
Subject: Re: flaw in python bindings diff?
Chris, would you mind taking another run at this patch to incorporate
my and Greg's feedback? Thanks!
Sure, here goes.
Log:
For windows, add a version of popen2 that takes the same type of args
as on Unix platforms.
* fs.py:
(FileDiff.get_pipe): Use _compat_popen2.
(_compat_popen2): New function to wrap the Unix form of popen2.popen2
on windows.
Index: subversion/bindings/swig/python/svn/fs.py
===================================================================
--- subversion/bindings/swig/python/svn/fs.py (revision 4642)
+++ subversion/bindings/swig/python/svn/fs.py (working copy)
@@ -19,6 +19,7 @@
### hide these names?
import tempfile
import os
+import sys
import popen2
import _fs
@@ -110,7 +111,7 @@
# open the pipe, forget the end for writing to the child (we won't),
# and then return the file object for reading from the child.
- fromchild, tochild = popen2.popen2(cmd)
+ fromchild, tochild = _compat_popen2(cmd)
tochild.close()
return fromchild
@@ -127,3 +128,26 @@
os.remove(self.tempfile2)
except OSError:
pass
+
+# For windows, add a version of popen2 that takes the same type of args
+# as on Unix platforms.
+if sys.platform[:3] == 'win':
+ import types
+
+ def _compat_popen2(cmd, bufsize=-1, mode='t'):
+ Execute the shell command 'cmd' in a sub-process. If 'bufsize' is
+ specified, it sets the buffer size for the I/O pipes. The file objects
+ (child_stdout, child_stdin) are returned.
+ cmdstr = ''
+ if isinstance(cmd, types.StringTypes):
+ cmdstr = cmd
+ else:
+ cmdstr = cmd[0]
+ for arg in cmd[1:]: # build the command string
+ cmdstr = cmdstr + ' ' + str(arg) + ''
+
+ return popen2.popen2(cmdstr, bufsize, mode)
+
+else:
+ _compat_popen2 = popen2.popen2
+
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org
Received on Sat Oct 14 02:23:18 2006