def check_hotcopy_fsfs_fsx(src, dst):
    for (src_dirpath, src_dirs, src_files) in os.walk(src):
        dst_dirpath = src_dirpath.replace(src, dst)
        if (not os.path.isdir(dst_dirpath)):
            raise svntest.Failure(('%s does not exist in hotcopy destination' % dst_dirpath))
        for dst_dirent in os.listdir(dst_dirpath):
            if (dst_dirent == 'pack-lock'):
                continue
            if (dst_dirent == 'write-lock'):
                continue
            if (dst_dirent == 'rep-cache.db-journal'):
                continue
            src_dirent = os.path.join(src_dirpath, dst_dirent)
            if (not os.path.exists(src_dirent)):
                raise svntest.Failure(('%s does not exist in hotcopy source' % src_dirent))
        for src_file in src_files:
            if (src_file == 'pack-lock'):
                continue
            if (src_file == 'write-lock'):
                continue
            if (src_file == 'rep-cache.db-journal'):
                continue
            src_path = os.path.join(src_dirpath, src_file)
            dst_path = os.path.join(dst_dirpath, src_file)
            if (not os.path.isfile(dst_path)):
                raise svntest.Failure(('%s does not exist in hotcopy destination' % dst_path))
            if (src_path == os.path.join(src, 'db', 'uuid')):
                lines1 = open(src_path, 'rb').read().split(b'\n')
                lines2 = open(dst_path, 'rb').read().split(b'\n')
                if (len(lines1) != len(lines2)):
                    raise svntest.Failure(('%s differs in number of lines' % dst_path))
                if (lines1[0] != lines2[0]):
                    raise svntest.Failure(("%s contains different uuid: '%s' vs. '%s'" % (dst_path, lines1[0], lines2[0])))
                continue
            if (src_file == 'rep-cache.db'):
                db1 = svntest.sqlite3.connect(src_path)
                db2 = svntest.sqlite3.connect(dst_path)
                schema1 = db1.execute('pragma user_version').fetchone()[0]
                schema2 = db2.execute('pragma user_version').fetchone()[0]
                if (schema1 != schema2):
                    raise svntest.Failure(("rep-cache schema differs: '%s' vs. '%s'" % (schema1, schema2)))
                if ((schema1 >= 2) and (svntest.sqlite3.sqlite_version_info < (3, 8, 2))):
                    continue
                rows1 = []
                rows2 = []
                for row in db1.execute('select * from rep_cache order by hash'):
                    rows1.append(row)
                for row in db2.execute('select * from rep_cache order by hash'):
                    rows2.append(row)
                if (len(rows1) != len(rows2)):
                    raise svntest.Failure('number of rows in rep-cache differs')
                for i in range(len(rows1)):
                    if (rows1[i] != rows2[i]):
                        raise svntest.Failure(("rep-cache row %i differs: '%s' vs. '%s'" % (i, rows1[i], rows2[i])))
                continue
            if (src_file == 'revprop-generation'):
                f2 = open(dst_path, 'r')
                revprop_gen = int(f2.read().strip())
                if (revprop_gen != 0):
                    raise svntest.Failure(('Hotcopy destination has non-zero ' + 'revprop generation'))
                continue
            f1 = open(src_path, 'rb')
            f2 = open(dst_path, 'rb')
            while True:
                offset = 0
                BUFSIZE = 1024
                buf1 = f1.read(BUFSIZE)
                buf2 = f2.read(BUFSIZE)
                if ((not buf1) or (not buf2)):
                    if ((not buf1) and (not buf2)):
                        break
                    elif buf1:
                        raise svntest.Failure(('%s differs at offset %i' % (dst_path, offset)))
                    elif buf2:
                        raise svntest.Failure(('%s differs at offset %i' % (dst_path, offset)))
                if (len(buf1) != len(buf2)):
                    raise svntest.Failure(('%s differs in length' % dst_path))
                for i in range(len(buf1)):
                    if (buf1[i] != buf2[i]):
                        raise svntest.Failure(('%s differs at offset %i' % (dst_path, offset)))
                    offset += 1
            f1.close()
            f2.close()
def check_hotcopy_fsfs_fsx(src, dst):
    for (src_dirpath, src_dirs, src_files) in os.walk(src):
        dst_dirpath = src_dirpath.replace(src, dst)
        if (not os.path.isdir(dst_dirpath)):
            raise svntest.Failure(('%s does not exist in hotcopy destination' % dst_dirpath))
        for dst_dirent in os.listdir(dst_dirpath):
            if (dst_dirent == 'pack-lock'):
                continue
            if (dst_dirent == 'write-lock'):
                continue
            if (dst_dirent == 'rep-cache.db-journal'):
                continue
            src_dirent = os.path.join(src_dirpath, dst_dirent)
            if (not os.path.exists(src_dirent)):
                raise svntest.Failure(('%s does not exist in hotcopy source' % src_dirent))
        for src_file in src_files:
            if (src_file == 'pack-lock'):
                continue
            if (src_file == 'write-lock'):
                continue
            if (src_file == 'rep-cache.db-journal'):
                continue
            src_path = os.path.join(src_dirpath, src_file)
            dst_path = os.path.join(dst_dirpath, src_file)
            if (not os.path.isfile(dst_path)):
                raise svntest.Failure(('%s does not exist in hotcopy destination' % dst_path))
            if (src_path == os.path.join(src, 'db', 'uuid')):
                lines1 = open(src_path, 'rb').read().split(b'\n')
                lines2 = open(dst_path, 'rb').read().split(b'\n')
                if (len(lines1) != len(lines2)):
                    raise svntest.Failure(('%s differs in number of lines' % dst_path))
                if (lines1[0] != lines2[0]):
                    raise svntest.Failure(("%s contains different uuid: '%s' vs. '%s'" % (dst_path, lines1[0], lines2[0])))
                continue
            if (src_file == 'rep-cache.db'):
                db1 = svntest.sqlite3.connect(src_path)
                db2 = svntest.sqlite3.connect(dst_path)
                schema1 = db1.execute('pragma user_version').fetchone()[0]
                schema2 = db2.execute('pragma user_version').fetchone()[0]
                if (schema1 != schema2):
                    raise svntest.Failure(("rep-cache schema differs: '%s' vs. '%s'" % (schema1, schema2)))
                if ((schema1 >= 2) and (svntest.sqlite3.sqlite_version_info < (3, 8, 2))):
                    continue
                rows1 = []
                rows2 = []
                for row in db1.execute('select * from rep_cache order by hash'):
                    rows1.append(row)
                for row in db2.execute('select * from rep_cache order by hash'):
                    rows2.append(row)
                if (len(rows1) != len(rows2)):
                    raise svntest.Failure('number of rows in rep-cache differs')
                for i in range(len(rows1)):
                    if (rows1[i] != rows2[i]):
                        raise svntest.Failure(("rep-cache row %i differs: '%s' vs. '%s'" % (i, rows1[i], rows2[i])))
                continue
            if (src_file == 'revprop-generation'):
                f2 = open(dst_path, 'r')
                revprop_gen = int(f2.read().strip())
                if (revprop_gen != 0):
                    raise svntest.Failure(('Hotcopy destination has non-zero ' + 'revprop generation'))
                continue
            f1 = open(src_path, 'rb')
            f2 = open(dst_path, 'rb')
            while True:
                offset = 0
                BUFSIZE = 1024
                buf1 = f1.read(BUFSIZE)
                buf2 = f2.read(BUFSIZE)
                if ((not buf1) or (not buf2)):
                    if ((not buf1) and (not buf2)):
                        break
                    elif buf1:
                        raise svntest.Failure(('%s differs at offset %i' % (dst_path, offset)))
                    elif buf2:
                        raise svntest.Failure(('%s differs at offset %i' % (dst_path, offset)))
                if (len(buf1) != len(buf2)):
                    raise svntest.Failure(('%s differs in length' % dst_path))
                for i in range(len(buf1)):
                    if (buf1[i] != buf2[i]):
                        raise svntest.Failure(('%s differs at offset %i' % (dst_path, offset)))
                    offset += 1
            f1.close()
            f2.close()