コード例 #1
0
def main(pool, repos_dir, path):
    # Construct a ChangeCollector to fetch our changes.
    fs_ptr = repos.svn_repos_fs(repos.svn_repos_open(repos_dir, pool))
    youngest_rev = fs.svn_fs_youngest_rev(fs_ptr, pool)
    root = fs.svn_fs_revision_root(fs_ptr, youngest_rev, pool)
    if not fs.svn_fs_node_prop(root, path, core.SVN_PROP_NEEDS_LOCK, pool):
        sys.stderr.write(
            """Locking of path '%s' prohibited by repository policy (must have
%s property set)
""" % (path, core.SVN_PROP_NEEDS_LOCK))
        return 1
    return 0
コード例 #2
0
def main(pool, repos_dir, path):
    # Construct a ChangeCollector to fetch our changes.
    fs_ptr = repos.svn_repos_fs(repos.svn_repos_open(repos_dir, pool))
    youngest_rev = fs.svn_fs_youngest_rev(fs_ptr, pool)
    root = fs.svn_fs_revision_root(fs_ptr, youngest_rev, pool)
    if not fs.svn_fs_node_prop(root, path, core.SVN_PROP_NEEDS_LOCK, pool):
        sys.stderr.write(
"""Locking of path '%s' prohibited by repository policy (must have
%s property set)
""" % (path, core.SVN_PROP_NEEDS_LOCK))
        return 1
    return 0
コード例 #3
0
def export_revision(rev, repo, fs, pool):
    sys.stderr.write("Exporting revision %s... " % rev)

    revpool = svn_pool_create(pool)
    svn_pool_clear(revpool)

    # Open a root object representing the youngest (HEAD) revision.
    root = svn_fs_revision_root(fs, rev, revpool)

    # And the list of what changed in this revision.
    changes = svn_fs_paths_changed(root, revpool)

    i = 1
    marks = {}
    file_changes = []

    for path, change_type in changes.iteritems():
        c_t = ct_short[change_type.change_kind]
        if svn_fs_is_dir(root, path, revpool):
            continue

        if not path.startswith(trunk_path):
            # We don't handle branches. Or tags. Yet.
            pass
        else:
            if c_t == 'D':
                file_changes.append("D %s" % path.replace(trunk_path, ''))
            else:
                marks[i] = path.replace(trunk_path, '')
                file_changes.append("M 644 :%s %s" % (i, marks[i]))
                sys.stdout.write("blob\nmark :%s\n" % i)
                dump_file_blob(root, path, revpool)
                i += 1

    # Get the commit author and message
    props = svn_fs_revision_proplist(fs, rev, revpool)

    # Do the recursive crawl.
    if props.has_key('svn:author'):
        author = "%s <%s@localhost>" % (props['svn:author'],
                                        props['svn:author'])
    else:
        author = 'nobody <nobody@localhost>'

    if len(file_changes) == 0:
        svn_pool_destroy(revpool)
        sys.stderr.write("skipping.\n")
        return

    svndate = props['svn:date'][0:-8]
    commit_time = mktime(strptime(svndate, '%Y-%m-%dT%H:%M:%S'))
    sys.stdout.write("commit refs/heads/master\n")
    sys.stdout.write("committer %s %s -0000\n" % (author, int(commit_time)))
    sys.stdout.write("data %s\n" % len(props['svn:log']))
    sys.stdout.write(props['svn:log'])
    sys.stdout.write("\n")
    sys.stdout.write('\n'.join(file_changes))
    sys.stdout.write("\n\n")

    svn_pool_destroy(revpool)

    sys.stderr.write("done!\n")
コード例 #4
0
def export_revision(rev, repo, fs, pool):
    sys.stderr.write("Exporting revision %s... " % rev)

    revpool = svn_pool_create(pool)
    svn_pool_clear(revpool)

    # Open a root object representing the youngest (HEAD) revision.
    root = svn_fs_revision_root(fs, rev, revpool)

    # And the list of what changed in this revision.
    changes = svn_fs_paths_changed(root, revpool)

    i = 1
    marks = {}
    file_changes = []

    for path, change_type in changes.iteritems():
        c_t = ct_short[change_type.change_kind]
        if svn_fs_is_dir(root, path, revpool):
            continue

        if not path.startswith(trunk_path):
            # We don't handle branches. Or tags. Yet.
            pass
        else:
            if c_t == "D":
                file_changes.append("D %s" % path.replace(trunk_path, ""))
            else:
                marks[i] = path.replace(trunk_path, "")
                file_changes.append("M 644 :%s %s" % (i, marks[i]))
                sys.stdout.write("blob\nmark :%s\n" % i)
                dump_file_blob(root, path, revpool)
                i += 1

    # Get the commit author and message
    props = svn_fs_revision_proplist(fs, rev, revpool)

    # Do the recursive crawl.
    if props.has_key("svn:author"):
        author = "%s <%s@localhost>" % (props["svn:author"], props["svn:author"])
    else:
        author = "nobody <nobody@localhost>"

    if len(file_changes) == 0:
        svn_pool_destroy(revpool)
        sys.stderr.write("skipping.\n")
        return

    svndate = props["svn:date"][0:-8]
    commit_time = mktime(strptime(svndate, "%Y-%m-%dT%H:%M:%S"))
    sys.stdout.write("commit refs/heads/master\n")
    sys.stdout.write("committer %s %s -0000\n" % (author, int(commit_time)))
    sys.stdout.write("data %s\n" % len(props["svn:log"]))
    sys.stdout.write(props["svn:log"])
    sys.stdout.write("\n")
    sys.stdout.write("\n".join(file_changes))
    sys.stdout.write("\n\n")

    svn_pool_destroy(revpool)

    sys.stderr.write("done!\n")