[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: Edward Diener <ediener_at_loyaltyworks.com>
Date: 2004-08-20 14:38:52 CEST

"C. Michael Pilato" <cmpilato@collab.net> wrote in message
news:m3hdqyj1xa.fsf@localhost.localdomain...
> "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:
>
> #!/usr/bin/python
>
> 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():
> core.svn_pool_clear(subpool)
> 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)
> else:
> print "%s [%s]" % (fullpath, id)
> core.svn_pool_destroy(subpool)
>
> core.apr_initialize()
> 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)
> core.apr_destroy()
>
> And there are plenty of other examples of the bindings usage in the
> Subversion tree and ViewCVS projects.

Thanks for you example. I still think there should be documentation on these
Python objects, else using them as you have done above is nearly impossible,
even more so since the interfaces to them are given in distributed shared
libraries and not in Python source code. As far as examples, where do these
exist ? They are not in the subversion distributed Python bindings unless I
have downloaded the wrong files. Are they in a subversion repository
somewhere ?

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@subversion.tigris.org
For additional commands, e-mail: users-help@subversion.tigris.org
Received on Fri Aug 20 14:39:23 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.