Mercurial > cvs2svn
changeset 77:0ba887e6e58e
verify-cvs2svn: use subprocess rather than popen2.
author | Greg Ward <greg@gerg.ca> |
---|---|
date | Fri, 31 Jul 2009 17:31:23 -0400 |
parents | e79fb91e68e6 |
children | 5991b868c571 |
files | contrib/verify-cvs2svn.py |
diffstat | 1 files changed, 10 insertions(+), 24 deletions(-) [+] |
line wrap: on
line diff
--- a/contrib/verify-cvs2svn.py +++ b/contrib/verify-cvs2svn.py @@ -33,7 +33,7 @@ import os import sys import optparse -import popen2 +import subprocess import shutil import re @@ -43,20 +43,6 @@ SVN_CMD = 'svn' -# Minimal, incomplete, version of popen2.Popen4 for those platforms -# for which popen2 does not provide it. -try: - Popen4 = popen2.Popen4 -except AttributeError: - class Popen4: - def __init__(self, cmd): - if type(cmd) != str: - cmd = " ".join(cmd) - self.fromchild, self.tochild = popen2.popen4(cmd) - def wait(self): - return self.fromchild.close() or self.tochild.close() - - class CvsRepos: def __init__(self, path): """Open the CVS repository at PATH.""" @@ -89,9 +75,9 @@ else: cmd.extend([ '-D', 'now' ]) cmd.extend([ '-d', dest_path, self.module ]) - pipe = Popen4(cmd) - output = pipe.fromchild.read() - status = pipe.wait() + child = subprocess.Popen(cmd, stdout=subprocess.PIPE) + output = child.stdout.read() + status = child.wait() if status or output: print 'CMD FAILED:', ' '.join(cmd) print 'Output:' @@ -119,9 +105,9 @@ """Export PATH to DEST_PATH.""" url = '/'.join([self.url, path]) cmd = [ SVN_CMD, 'export', '-q', url, dest_path ] - pipe = Popen4(cmd) - output = pipe.fromchild.read() - status = pipe.wait() + child = subprocess.Popen(cmd, stdout=subprocess.PIPE) + output = child.stdout.read() + status = child.wait() if status or output: print 'CMD FAILED:', ' '.join(cmd) print 'Output:' @@ -143,9 +129,9 @@ def list(self, path): """Return a list of all files and directories in PATH.""" cmd = [ SVN_CMD, 'ls', self.url + '/' + path ] - pipe = Popen4(cmd) - lines = pipe.fromchild.readlines() - status = pipe.wait() + child = subprocess.Popen(cmd, stdout=subprocess.PIPE) + lines = child.stdout.readlines() + status = child.wait() if status: print 'CMD FAILED:', ' '.join(cmd) print 'Output:'