[PATCH] Add verify-all script to run repeated conversions and verify each one
Greg Ward <[email protected]>
| Newsgroups | gmane.comp.version-control.subversion.cvs2svn.devel |
|---|---|
| Message-ID | <5f2cf6a14fcce3789fa0.1250820045@davros> |
# HG changeset patch # User Greg Ward <[email protected]> # Date 1250819779 14400 # Node ID 5f2cf6a14fcce3789fa0b1c5713707a1262c18fc # Parent cf5ad7ec18d51573cfc9347a60fdded88a810c10 Add verify-all script to run repeated conversions and verify each one. Takes a list of CVS repositories to convert+verify on the command line, defaulting to most of test-data/*-cvsrepos. diff --git a/contrib/verify-all b/contrib/verify-all new file mode 100755 --- /dev/null +++ b/contrib/verify-all @@ -0,0 +1,111 @@ +#!/usr/bin/python + +"""Run repeated conversions from CVS, verifying each one in turn. If +you don't supply a list of input CVS repositories, converts and verifies +test-data/*-cvsrepos (with some exceptions). +""" + +# XXX currently only supports conversion to Mercurial + +import sys +import os +import signal +import optparse +import glob +import tempfile +import subprocess +import shutil + +class ConversionFailed(Exception): + def __init__(self, inrepo, cmd, output): + self.inrepo = inrepo + self.cmd = cmd + self.output = output + + def __str__(self): + return ("conversion failure: %s\n" + "command: %s\n" + "output:\n%s" + % (self.inrepo, " ".join(self.cmd), self.output)) + +class VerificationFailed(Exception): + def __init__(self, inrepo): + self.inrepo = inrepo + + def __str__(self): + return "verification failure: %s" % self.inrepo + +def convert(base_cmd, tmpdir, inrepo): + print "Converting", inrepo + outrepo = os.path.join( + tmpdir, os.path.basename(inrepo).replace("-cvsrepos", "") + ".hg") + cmd = base_cmd + ["--hgrepos", outrepo, inrepo] + child = subprocess.Popen(cmd, + stdout=subprocess.PIPE, + stderr=subprocess.STDOUT) + output = child.stdout.read() + status = child.wait() + if status: + raise ConversionFailed(inrepo, cmd, output) + return outrepo + +def verify(tmpdir, inrepo, verifyrepo): + cmd = ["./contrib/verify-cvs2svn.py", + "--tempdir", tmpdir, + "--hg", inrepo, verifyrepo] + child = subprocess.Popen(cmd) + status = child.wait() + if status: + raise VerificationFailed(inrepo) + +# Some of the CVS repositories in test-data cannot be converted or +# verified -- skip them. +EXCLUDE_REPOS = set([ + "attic-directory-conflict-cvsrepos", # file/dir name conflict + "bogus-tag-cvsrepos", # bad tag name + + ]) + +def main(): + parser = optparse.OptionParser(usage="%prog [options] [cvs-repo ...]", + description=__doc__) + + (options, args) = parser.parse_args() + if not args: + args = [os.path.join("test-data", name) + for name in set(os.listdir("test-data")) - EXCLUDE_REPOS + if name.endswith("-cvsrepos")] + args.sort() + + tmpdir = tempfile.mkdtemp(prefix="verify.", dir=".") + base_cmd = ["./cvs2hg"] + convert_failed = [] + verify_failed = [] + try: + for inrepo in args: + if inrepo is not args[0]: + print + try: + verifyrepo = convert(base_cmd, tmpdir, inrepo) + verify(tmpdir, inrepo, verifyrepo) + except ConversionFailed, err: + convert_failed.append(inrepo) + sys.stderr.write("error: " + str(err)) + except VerificationFailed, err: + verify_failed.append((inrepo, verifyrepo)) + sys.stderr.write("error: " + str(err)) + finally: + print "cleaning", tmpdir + shutil.rmtree(tmpdir, ignore_errors=True) + + if convert_failed: + sys.stderr.write("error: %d conversion(s) failed:\n %s\n" + % (len(convert_failed), "\n ".join(convert_failed))) + if verify_failed: + failed = ["%s != %s" % pair for pair in verify_failed] + sys.stderr.write("error: %d verification(s) failed:\n %s\n" + % (len(verify_failed), "\n ".join(failed))) + + sys.exit((convert_failed or verify_failed) and 1 or 0) + +main() ------------------------------------------------------ http://cvs2svn.tigris.org/ds/viewMessage.do?dsForumId=1667&dsMessageId=2385870 To unsubscribe from this discussion, e-mail: [[email protected]].