def patch_format(repo_dir, shard_size):
    'Rewrite the format of the FSFS or FSX repository REPO_DIR so\n  that it would use sharding with SHARDS revisions per shard.'
    format_path = os.path.join(repo_dir, 'db', 'format')
    contents = open(format_path, 'rb').read()
    processed_lines = []
    for line in contents.split(b'\n'):
        if line.startswith(b'layout '):
            processed_lines.append(('layout sharded %d' % shard_size).encode())
        else:
            processed_lines.append(line)
    new_contents = b'\n'.join(processed_lines)
    os.chmod(format_path, svntest.main.S_ALL_RW)
    with open(format_path, 'wb') as f:
        f.write(new_contents)
Rewrite the format of the FSFS or FSX repository REPO_DIR so
that it would use sharding with SHARDS revisions per shard.
def patch_format(repo_dir, shard_size):
    'Rewrite the format of the FSFS or FSX repository REPO_DIR so\n  that it would use sharding with SHARDS revisions per shard.'
    format_path = os.path.join(repo_dir, 'db', 'format')
    contents = open(format_path, 'rb').read()
    processed_lines = []
    for line in contents.split(b'\n'):
        if line.startswith(b'layout '):
            processed_lines.append(('layout sharded %d' % shard_size).encode())
        else:
            processed_lines.append(line)
    new_contents = b'\n'.join(processed_lines)
    os.chmod(format_path, svntest.main.S_ALL_RW)
    with open(format_path, 'wb') as f:
        f.write(new_contents)