[svn.haxx.se] · SVN Dev · SVN Users · SVN Org · TSVN Dev · TSVN Users · Subclipse Dev · Subclipse Users · this month's index

Re: Walking the repository starting from a path

From: C. Michael Pilato <cmpilato_at_collab.net>
Date: 2004-08-19 22:41:37 CEST

"Edward Diener" <ediener@loyaltyworks.com> writes:

> > The documentation for the swig bindings is largely found in the
> > subversion/include directory -- we're just exposing the C API,
> > generally speaking.
> To say that there is documentation in the subversion/include
> directory is a misnomer. I do see the subversion API documentation,
> but this does not tell me the equivalent Python constructs to their
> C++ counterparts. I am a C++ programmer also but trying to figure
> out what Python expects as opposed to C++ is a major headache. SWIG
> is very clever but impossible to understand.

In most cases, there are no equivalents. The funky types that
Subversion uses (like svn_fs_root_t, svn_repos_t, svn_fs_t, etc.) are
generally only meant for consumption by Subversion itself. SWIG turns
the C objects into Python objects, and you hand those (basically
opaque) object back to the API.

So, writing to the SWIG bindings is very much like writing to the
Subversion C API:

    from svn import core, repos, fs
    def handle_dir(fs_root, path, id, pool):
        print "%s/ [%s]" % (path, id)
        dirents = fs.dir_entries(fs_root, path, pool)
        subpool = core.svn_pool_create(pool)
        for name in dirents.keys():
            fullpath = path + '/' + name
            id = fs.unparse_id(dirents[name].id, subpool)
            is_dir = fs.is_dir(fs_root, fullpath, subpool)
            if is_dir:
                handle_dir(fs_root, fullpath, id, subpool)
                print "%s [%s]" % (fullpath, id)
    pool = core.svn_pool_create(None)
    repos_ptr = repos.svn_repos_open('/usr/local/svn/subversion', pool)
    fs_ptr = repos.svn_repos_fs(repos_ptr)
    fs_root = fs.revision_root(fs_ptr, 1000, pool)
    id = fs.unparse_id(fs.node_id(fs_root, 'trunk', pool), pool)
    handle_dir(fs_root, 'trunk', id, pool)

And there are plenty of other examples of the bindings usage in the
Subversion tree and ViewCVS projects.

To unsubscribe, e-mail: users-unsubscribe@subversion.tigris.org
For additional commands, e-mail: users-help@subversion.tigris.org
Received on Thu Aug 19 22:43:47 2004

This is an archived mail posted to the Subversion Users mailing list.

This site is subject to the Apache Privacy Policy and the Apache Public Forum Archive Policy.