示例#1
0
文件: test_api.py 项目: epu/rsvndump
def mktemp(id):
    return test.mktemp(id)
示例#2
0
文件: test_api.py 项目: epu/rsvndump
def mktemp(id):
	return test.mktemp(id)
示例#3
0
文件: test_api.py 项目: epu/rsvndump
def diff_repos(id, repo1, sub1, repo2, sub2):
    log(
        id, "\n*** compare_repos (" + str(id) + "): " + repo1 + "/" + sub1 +
        " and " + repo2 + "/" + sub2 + "\n")

    # Retrieve log messages
    log1 = test.mktemp(id)
    log2 = test.mktemp(id)
    run("svnlook", "history", repo1, sub1, output=log1, error=test.log(id))
    run("svnlook", "history", repo2, sub2, output=log2, error=test.log(id))

    f1 = open(log1, "r")
    rev1 = f1.readlines()
    rev1.reverse()
    f2 = open(log2, "r")
    rev2 = f2.readlines()
    f2.close()
    f1.close()
    rev2.reverse()

    # Filter logs
    regex = re.compile(" *[0-9]*   \/" + sub1 + "$", re.IGNORECASE)
    rev1 = [rev for rev in rev1 if regex.search(rev)]
    regex = re.compile(" *[0-9]*   \/" + sub2 + "$", re.IGNORECASE)
    rev2 = [rev for rev in rev2 if regex.search(rev)]

    if len(rev1) != len(rev2):
        log(id, "\n" + str(rev1))
        log(id, "\n" + str(rev2))
        return False

    # Compare trees & file contents
    out1 = mktemp(id)
    out2 = mktemp(id)
    fout1 = mktemp(id)
    fout2 = mktemp(id)
    diff = test.log(id) + ".diff"
    rx1 = re.compile(" *([0-9]*)", re.IGNORECASE)
    for rev in zip(rev1, rev2):
        r1 = int(rx1.match(rev[0]).group())
        r2 = int(rx1.match(rev[1]).group())
        run_noa("svnlook",
                "tree",
                "--full-paths",
                "-r",
                str(r1),
                repo1,
                sub1,
                output=out1,
                error=test.log(id))
        run_noa("svnlook",
                "tree",
                "--full-paths",
                "-r",
                str(r2),
                repo2,
                sub2,
                output=out2,
                error=test.log(id))
        log(id, "comparing trees at revision " + str(r1) + " and " + str(r2))
        try:
            run("diff", "-Naur", out1, out2, output=diff)
        except:
            return False

        # Compare files
        f = open(out1, "r")
        for line in f.readlines():
            file = line.lstrip()[:-1]
            if file.endswith("/"):  # Skip directories
                continue

            run_noa("svnlook",
                    "cat",
                    "-r",
                    str(r1),
                    repo1,
                    file,
                    output=fout1,
                    error=test.log(id))
            run_noa("svnlook",
                    "cat",
                    "-r",
                    str(r2),
                    repo2,
                    file,
                    output=fout2,
                    error=test.log(id))
            try:
                run("diff", "-Naur", fout1, fout2, output=diff)
            except:
                log(id, "  failed, file " + file + " differs!")
                return False

        f.close()

    return True
示例#4
0
文件: test_api.py 项目: epu/rsvndump
def diff_repos(id, repo1, sub1, repo2, sub2):
	log(id, "\n*** compare_repos ("+str(id)+"): "+repo1+"/"+sub1+" and "+repo2+"/"+sub2+"\n")

	# Retrieve log messages
	log1 = test.mktemp(id)
	log2 = test.mktemp(id)
	run("svnlook", "history", repo1, sub1, output = log1, error = test.log(id))
	run("svnlook", "history", repo2, sub2, output = log2, error = test.log(id))

	f1 = open(log1, "r")
	rev1 = f1.readlines()
	rev1.reverse()
	f2 = open(log2, "r")
	rev2 = f2.readlines()
	f2.close()
	f1.close()
	rev2.reverse()

	# Filter logs
	regex = re.compile(" *[0-9]*   \/"+sub1+"$", re.IGNORECASE)
	rev1 = [rev for rev in rev1 if regex.search(rev)]
	regex = re.compile(" *[0-9]*   \/"+sub2+"$", re.IGNORECASE)
	rev2 = [rev for rev in rev2 if regex.search(rev)]

	if len(rev1) != len(rev2):
		log(id, "\n"+str(rev1))
		log(id, "\n"+str(rev2))
		return False

	# Compare trees & file contents
	out1 = mktemp(id)
	out2 = mktemp(id)
	fout1 = mktemp(id)
	fout2 = mktemp(id)
	diff = test.log(id)+".diff"
	rx1 = re.compile(" *([0-9]*)", re.IGNORECASE)
	for rev in zip(rev1, rev2):
		r1 = int(rx1.match(rev[0]).group())
		r2 = int(rx1.match(rev[1]).group())
		run_noa("svnlook", "tree", "--full-paths", "-r", str(r1), repo1, sub1, output = out1, error = test.log(id))
		run_noa("svnlook", "tree", "--full-paths", "-r", str(r2), repo2, sub2, output = out2, error = test.log(id))
		log(id, "comparing trees at revision "+str(r1)+" and "+str(r2))
		try:
			run("diff", "-Naur", out1, out2, output = diff)
		except:
			return False

		# Compare files
		f = open(out1, "r")
		for line in f.readlines():
			file = line.lstrip()[:-1]
			if file.endswith("/"): # Skip directories
				continue

			run_noa("svnlook", "cat", "-r", str(r1), repo1, file, output = fout1, error = test.log(id))
			run_noa("svnlook", "cat", "-r", str(r2), repo2, file, output = fout2, error = test.log(id))
			try:
				run("diff", "-Naur", fout1, fout2, output = diff)
			except:
				log(id, "  failed, file "+file+" differs!")
				return False

		f.close()

	return True