You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@subversion.apache.org by Bob Aman <va...@gmail.com> on 2005/04/07 16:00:05 UTC

Accessing SVN through Ruby

I want to code up a CMS of sorts in Ruby that uses Subversion as the
backend.  However, the only simple interface to Subversion I seem to
have available to me is to call out to the Subversion command line
client, which is rather less than optimal.  I saw the Subversion SWIG
bindings in the Subversion repository at
http://svn.collab.net/repos/svn/trunk/subversion/bindings/swig/ruby/
but when I tried to work with them, I couldn't figure out how to set
them up properly.

I kept getting "No such file to load -- svn/ext/core (LoadError)" when
trying to run run-test.rb

Has anyone out there had better luck with the ruby svn bindings or
does anyone know of a nicer ruby interface to SVN, preferably one
that's more "ruby-like"?  There also seems to be disclaimers about the
functionality of the ruby bindings in the Subversion documentation,
but not a lot of information about what doesn't quite work.  Just that
there might be some stuff.  Anyone know what's missing or not working?
-- 
Bob Aman

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@subversion.tigris.org
For additional commands, e-mail: users-help@subversion.tigris.org

Re: Accessing SVN through Ruby

Posted by Bob Aman <va...@gmail.com>.
> Ok, so I gave up trying to figure out what to do with the .in file in
> Windows.  I ran ./configure for the apr on FreeBSD, everything,
> *poof*, went as expected, and it eventually spat out apr.h as well as
> a bunch of other stuff.  I borrowed that apr.h and stuck it on my
> Windows machine, hoping there wasn't anything FreeBSD specific in
> there as a result.  I no longer get a syntax error, but it's still
> telling me:
> *** No module name specified using %module or -module.
> 
> I have no idea what that means, but I guess I don't get a *_wrap.c
> file?  Or.... was I supposed to?

I hate answering my own questions, especially 30 seconds after I
posted them, but, judging from this list in the INSTALL file from
1.1.4 on the SWIG bindings for Java:

        subversion\bindings\swig\java\build\svn-api.jar
        Release\subversion\bindings\swig\java\_client.dll
        Release\subversion\bindings\swig\java\_core.dll
        Release\subversion\bindings\swig\java\_delta.dll
        Release\subversion\bindings\swig\java\_fs.dll
        Release\subversion\bindings\swig\java\_ra.dll
        Release\subversion\bindings\swig\java\_repos.dll
        Release\subversion\bindings\swig\java\_wc.dll

I'm going to guess that I'm getting exactly what I should.  But what
about the huge numbers of warnings from SWIG I'm getting?  Is that
normal?  e.g.:
 
svn_types.i(293): Warning(453): Can't apply (enum SWIGTYPE *OUTENUM).
No typemaps are defined.
svn_types.i(311): Warning(453): Can't apply (SWIGTYPE **OUTPARAM). No
typemaps are defined.
svn_types.h(46): Warning(801): Wrong class name (corrected to `Svn_error_t')
svn_types.h(190): Warning(801): Wrong class name (corrected to `Svn_dirent_t')
svn_types.h(290): Warning(801): Wrong class name (corrected to
`Svn_log_changed_path_t')
svn_string.i(111): Warning(453): Can't apply (RET_STRING). No typemaps
are defined.
svn_string.i(163): Warning(453): Can't apply (RET_STRING). No typemaps
are defined.
svn_delta.i(40): Warning(453): Can't apply (SWIGTYPE **OUTPARAM). No
typemaps are defined.
svn_delta.i(40): Warning(453): Can't apply (SWIGTYPE **OUTPARAM). No
typemaps are defined.
svn_delta.i(40): Warning(453): Can't apply (SWIGTYPE **OUTPARAM). No
typemaps are defined.
svn_delta.i(40): Warning(453): Can't apply (SWIGTYPE **OUTPARAM). No
typemaps are defined.
[snip... etc, etc...]

> And uhm, could someone tell me what I was actually supposed to do with
> the apr.h.* files?  Please?

And this question still stands.  I still have no idea how to generate
that apr.h file natively on Windows.
-- 
Bob Aman

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org

Re: Accessing SVN through Ruby

Posted by Bob Aman <va...@gmail.com>.
> You need to run SWIG on the .i files inside subversion/bindings/swig.
> Thus, you need to run SWIG on core.i, svn_client.i, svn_delta.i, svn_fs.i,
> svn_ra.i, svn_repos.i, and svn_wc.i.  If you look, you can see that core.i
> includes apr.i, which includes apr.h.  Incidentally, core.i also includes
> the %module, which is what SWIG is looking for.

I replied to my own post on that, I did figure out that I wasn't
supposed to do swig -ruby apr.i, only just swigging the .i files you
mentioned.

Garrett Rooney said that I should've used apr.hw to build for Windows,
and I'm going to try that next.  But I guess I'm not sure what exactly
I should do with the *_wrap.c files I've got as the result. 
Obviously, compile them, but is there anything special I need to do
with Visual Studio here?  There's of course, no project file for these
things, so it's not quite as obvious what to do as if I were compiling
with gcc.
-- 
Bob Aman

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org


Re: Accessing SVN through Ruby

Posted by John Lenz <le...@cs.wisc.edu>.
On 04/12/05 16:22:19, Bob Aman wrote:

> > Well, I managed to get a little bit more progress by moving around a
> > bunch of the .h files.  But apr.h seems to be missing.  I saw apr.h.in
> > and that seems to be what I'm looking for.  It says apr.h is a
> > generated file?  How do I generate it?  On a whim, I tried just
> > renaming apr.h.in to apr.h and got back an error from SWIG:
> > E:\svn-source\subversion-1.1.4\subversion\bindings\swig>swig -ruby apr.i
> > apr.h(257): Error: Syntax error in input.
> > *** No module name specified using %module or -module.
> >
> > So I assume that was the wrong thing to do :-P
> 
> Ok, so I gave up trying to figure out what to do with the .in file in
> Windows.  I ran ./configure for the apr on FreeBSD, everything,
> *poof*, went as expected, and it eventually spat out apr.h as well as
> a bunch of other stuff.  I borrowed that apr.h and stuck it on my
> Windows machine, hoping there wasn't anything FreeBSD specific in
> there as a result.  I no longer get a syntax error, but it's still
> telling me:
> *** No module name specified using %module or -module.
> 
> I have no idea what that means, but I guess I don't get a *_wrap.c
> file?  Or.... was I supposed to?
> 
> And uhm, could someone tell me what I was actually supposed to do with
> the apr.h.* files?  Please?

You need to run SWIG on the .i files inside subversion/bindings/swig.   
Thus, you need to run SWIG on core.i, svn_client.i, svn_delta.i, svn_fs.i,  
svn_ra.i, svn_repos.i, and svn_wc.i.  If you look, you can see that core.i  
includes apr.i, which includes apr.h.  Incidentally, core.i also includes  
the %module, which is what SWIG is looking for.

John


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org

Re: Accessing SVN through Ruby

Posted by Garrett Rooney <ro...@electricjellyfish.net>.
Bob Aman wrote:

>>Well, I managed to get a little bit more progress by moving around a
>>bunch of the .h files.  But apr.h seems to be missing.  I saw apr.h.in
>>and that seems to be what I'm looking for.  It says apr.h is a
>>generated file?  How do I generate it?  On a whim, I tried just
>>renaming apr.h.in to apr.h and got back an error from SWIG:
>>E:\svn-source\subversion-1.1.4\subversion\bindings\swig>swig -ruby apr.i
>>apr.h(257): Error: Syntax error in input.
>>*** No module name specified using %module or -module.
>>
>>So I assume that was the wrong thing to do :-P
> 
> 
> Ok, so I gave up trying to figure out what to do with the .in file in
> Windows.  I ran ./configure for the apr on FreeBSD, everything,
> *poof*, went as expected, and it eventually spat out apr.h as well as
> a bunch of other stuff.  I borrowed that apr.h and stuck it on my
> Windows machine, hoping there wasn't anything FreeBSD specific in
> there as a result.  I no longer get a syntax error, but it's still
> telling me:
> *** No module name specified using %module or -module.
> 
> I have no idea what that means, but I guess I don't get a *_wrap.c
> file?  Or.... was I supposed to?
> 
> And uhm, could someone tell me what I was actually supposed to do with
> the apr.h.* files?  Please?

The correct apr.h for a windows system is apr.hw, which is copied into 
the correct location by some part of the windows build process for APR, 
IIRC.  Sorry I can't be more help, perhaps figuring out how the SWIG 
build process for the Ruby bindings works on unix will give you more 
hints about what needs to be done to make it work on win32.

-garrett

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org

Re: Accessing SVN through Ruby

Posted by Bob Aman <va...@gmail.com>.
On Apr 12, 2005 2:11 PM, Bob Aman <va...@gmail.com> wrote:
> On Apr 12, 2005 1:33 PM, John Lenz <le...@cs.wisc.edu> wrote:
> > On 04/12/05 11:49:17, Bob Aman wrote:
> > > Ok, so I'm still trying to get SWIG to do its thing on Windows.  And
> > > I'm starting to get the impression that perhaps it's not necessary to
> > > go through a full build.  (At least, I certainly hope so.)  Am I
> > > correct in this assumption, and if so, what is the bare minimum
> > > necessary to get SWIG to do its magic in Windows?  I'm currently
> > > working with the source for 1.1.4, not the latest code from the
> > > repository.
> >
> > http://www.swig.org/Doc1.3/Windows.html
> >
> > I should also note here that as I have said before, the output files from
> > SWIG are portable to almost any architecture and only need to be generated
> > once.  Thus, if you have SWIG installed say on linux, you can run it to
> > generate the _wrap files and those exact wrap files can be used on Sun,
> > Windows, Linux, MacOS, whatever.  So you could even get someone to email
> > you the files that SWIG creates, and you wouldn't even need SWIG installed
> > to compile the bindings on windows.
> >
> > The right way to take care of this problem is to have the SWIG generated
> > files present directly inside the released subversion tarballs, then SWIG
> > does not need to be installed to build a tarball.  Sadly, this feature will
> > not even be in the 1.2 release, but hopefully future releases will have it.
> >
> > Note that all I've said is only true for SWIG since version 1.3.23... but
> > subversion is using 1.3.24 so shouldn't matter.
> >
> > John
> 
> Well, I managed to get a little bit more progress by moving around a
> bunch of the .h files.  But apr.h seems to be missing.  I saw apr.h.in
> and that seems to be what I'm looking for.  It says apr.h is a
> generated file?  How do I generate it?  On a whim, I tried just
> renaming apr.h.in to apr.h and got back an error from SWIG:
> E:\svn-source\subversion-1.1.4\subversion\bindings\swig>swig -ruby apr.i
> apr.h(257): Error: Syntax error in input.
> *** No module name specified using %module or -module.
> 
> So I assume that was the wrong thing to do :-P

Ok, so I gave up trying to figure out what to do with the .in file in
Windows.  I ran ./configure for the apr on FreeBSD, everything,
*poof*, went as expected, and it eventually spat out apr.h as well as
a bunch of other stuff.  I borrowed that apr.h and stuck it on my
Windows machine, hoping there wasn't anything FreeBSD specific in
there as a result.  I no longer get a syntax error, but it's still
telling me:
*** No module name specified using %module or -module.

I have no idea what that means, but I guess I don't get a *_wrap.c
file?  Or.... was I supposed to?

And uhm, could someone tell me what I was actually supposed to do with
the apr.h.* files?  Please?
-- 
Bob Aman

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org

Re: Accessing SVN through Ruby

Posted by Bob Aman <va...@gmail.com>.
On Apr 12, 2005 1:33 PM, John Lenz <le...@cs.wisc.edu> wrote:
> On 04/12/05 11:49:17, Bob Aman wrote:
> > Ok, so I'm still trying to get SWIG to do its thing on Windows.  And
> > I'm starting to get the impression that perhaps it's not necessary to
> > go through a full build.  (At least, I certainly hope so.)  Am I
> > correct in this assumption, and if so, what is the bare minimum
> > necessary to get SWIG to do its magic in Windows?  I'm currently
> > working with the source for 1.1.4, not the latest code from the
> > repository.
> 
> http://www.swig.org/Doc1.3/Windows.html
> 
> I should also note here that as I have said before, the output files from
> SWIG are portable to almost any architecture and only need to be generated
> once.  Thus, if you have SWIG installed say on linux, you can run it to
> generate the _wrap files and those exact wrap files can be used on Sun,
> Windows, Linux, MacOS, whatever.  So you could even get someone to email
> you the files that SWIG creates, and you wouldn't even need SWIG installed
> to compile the bindings on windows.
> 
> The right way to take care of this problem is to have the SWIG generated
> files present directly inside the released subversion tarballs, then SWIG
> does not need to be installed to build a tarball.  Sadly, this feature will
> not even be in the 1.2 release, but hopefully future releases will have it.
> 
> Note that all I've said is only true for SWIG since version 1.3.23... but
> subversion is using 1.3.24 so shouldn't matter.
> 
> John

Well, I managed to get a little bit more progress by moving around a
bunch of the .h files.  But apr.h seems to be missing.  I saw apr.h.in
and that seems to be what I'm looking for.  It says apr.h is a
generated file?  How do I generate it?  On a whim, I tried just
renaming apr.h.in to apr.h and got back an error from SWIG:
E:\svn-source\subversion-1.1.4\subversion\bindings\swig>swig -ruby apr.i
apr.h(257): Error: Syntax error in input.
*** No module name specified using %module or -module.

So I assume that was the wrong thing to do :-P
-- 
Bob Aman

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org

Re: Accessing SVN through Ruby

Posted by John Lenz <le...@cs.wisc.edu>.
On 04/12/05 11:49:17, Bob Aman wrote:
> Ok, so I'm still trying to get SWIG to do its thing on Windows.  And
> I'm starting to get the impression that perhaps it's not necessary to
> go through a full build.  (At least, I certainly hope so.)  Am I
> correct in this assumption, and if so, what is the bare minimum
> necessary to get SWIG to do its magic in Windows?  I'm currently
> working with the source for 1.1.4, not the latest code from the
> repository.

http://www.swig.org/Doc1.3/Windows.html

I should also note here that as I have said before, the output files from  
SWIG are portable to almost any architecture and only need to be generated  
once.  Thus, if you have SWIG installed say on linux, you can run it to  
generate the _wrap files and those exact wrap files can be used on Sun,  
Windows, Linux, MacOS, whatever.  So you could even get someone to email  
you the files that SWIG creates, and you wouldn't even need SWIG installed  
to compile the bindings on windows.

The right way to take care of this problem is to have the SWIG generated  
files present directly inside the released subversion tarballs, then SWIG  
does not need to be installed to build a tarball.  Sadly, this feature will  
not even be in the 1.2 release, but hopefully future releases will have it.

Note that all I've said is only true for SWIG since version 1.3.23... but  
subversion is using 1.3.24 so shouldn't matter.

John


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org

Re: Accessing SVN through Ruby

Posted by Bob Aman <va...@gmail.com>.
Ok, so I'm still trying to get SWIG to do its thing on Windows.  And
I'm starting to get the impression that perhaps it's not necessary to
go through a full build.  (At least, I certainly hope so.)  Am I
correct in this assumption, and if so, what is the bare minimum
necessary to get SWIG to do its magic in Windows?  I'm currently
working with the source for 1.1.4, not the latest code from the
repository.
--
Bob Aman

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org

Re: Accessing SVN through Ruby

Posted by Marcus Rueckert <da...@web.de>.
hi

SVN - Python script which allows multiple repository-side operations in
a single, atomic transaction.
https://opensvn.csie.org/traccgi/rsvn/trac.cgi/wiki

and maybe look at the upcoming ruby bindings to do something similar.

darix

-- 
irssi - the client of the smart and beautiful people

              http://www.irssi.de/


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org

Re: Accessing SVN through Ruby

Posted by Bob Aman <va...@gmail.com>.
Nice, an answer that might get me somewhere.  Thank you!

>DL is a generic dynamically-linked library wrapper that requires none
>of this C compiler business.  You load a so/dll and tell Ruby what the
>parameters are for the C calls, and it takes care of all the argument
>passing for you.
>
>DL ships with ruby 1.8, but there doesn't seem to be an exact home page
>for it.
>
>http://www.google.com/search?q=ruby+dl
>
>Will give you several tutorial/documents on it.
>
>>> svn lists easily parseable output as one of its features...
>>
>> I don't think calling out to the command line client is a truely
>> viable option.
>
> Why?

The requirement of having to be able to modify the metadata.  I assume
there's no way to modify the metadata in place through the client.  If
there is, then that very nearly settles it, I think.  (Only thing left
to deal with is my irrational apprehention every time I shell out for
something.  Plus my reservations about needing to have Subversion
installed.)
 
> If you build it to be reliable, it will be reliable.  Unit tests come
> in really handy for this.

Agreed, though you always have to consider the weakest link.  It's bad
if the weakest link is something you can't control.  That's kinda what
I meant.
 
> There's nothing that prevents an svn wrapper from presenting a
> ruby-like API.  DL and SWIG only give different tradeoffs in how this
> is implemented.

What potential trade-offs are there between DL and SWIG?
 
> While many of the svn commands can work directly with the repository
> without local storage, I don't know of any way to avoid writing to disk
> for those commands that require a local checkout.

Oh yeah, that reminds me...  Let's say you try to run the svn client
from a random directory that isn't a svn working directory.  Since
we're trying to avoid writing to disk, this will probably effectively
be the case.  Are there any parameters to the command line client to
tell it which repository it should be looking at?  It looks like you
can specify the target but not the url?

So how does TortoiseSVN do it with the repo-browser?  What
capabilities do the client libraries expose that the command line
client does not?
 
> This is easiest if you just shell out, since it will be easier to
> maintain a svn wrapper than maintaining libraries for the platforms
> that don't typically ship with a compiler (windows).

Agreed, and it's really the only real attraction to me for wrapping
the command line client.
 
> > It needs to be somewhat easy, because I am not a C
> > hacker by any stretch of the imagination.  And it's got to be
> > reasonably simple to set up on Windows, since, for the moment, that's
> > the dev environment I'm stuck with.
> 
> Sounds like you'd rather to an svn wrapper or DL (in that order).

Yeah, I would agree, assuming that all of the functionality I need can
be had through the command line client.
 
> > I've been trying to get the Ruby SWIG bindings to work, but I have
> > absolutely no idea how to get SWIG to do its thing.  It just sits
> > there and complains about missing files.
> 
> DL or an svn wrapper will probably get you farther faster than SWIG,
> since both have a lower barrier to entry.  For an svn wrapper you just
> need svn installed.  For DL you need to be able to find an svn .dll or
> .so, which may be as simple as installing svn.

But judging from the contents of my svn directory, maybe not:

 Volume in drive D is PRIMARY
 Volume Serial Number is 1CEC-3A16

 Directory of D:\Program Files\Subversion\bin

01/26/2005  11:07 PM    <DIR>          .
01/26/2005  11:07 PM    <DIR>          ..
01/20/2005  06:25 AM           794,722 svn.exe
01/20/2005  06:25 AM           311,392 svnadmin.exe
01/20/2005  06:25 AM           286,814 svnlook.exe
01/20/2005  06:25 AM           315,488 svnserve.exe
01/20/2005  06:25 AM           663,652 svnversion.exe
01/20/2005  06:25 AM           254,058 svndumpfilter.exe
01/20/2005  06:25 AM           647,168 libdb42.dll
01/20/2005  06:25 AM           127,057 libapr.dll
01/20/2005  06:25 AM           168,026 libaprutil.dll
01/20/2005  06:25 AM            36,956 libapriconv.dll
05/04/2004  08:52 AM            61,519 intl.dll
01/20/2005  06:25 AM           843,776 libeay32.dll
01/20/2005  06:25 AM           159,744 ssleay32.dll
03/31/2004  06:13 PM            61,440 SVNService.exe
              14 File(s)      4,731,812 bytes

Maybe I'm missing something, but I'm not really seeing that supposed
svn library that I can stick into a DL here.

> For SWIG you need
> headers and a compiler, which can be no fun if there's no default
> compiler and you have 2 or 3 different compilers to choose from.
 
> > Of course, it doesn't help that building svn on Windows seems to
> > require superhuman effort, though it's quite possible that I'm just
> > missing some build step somewhere.
> 
> If you're having these difficulties, do you expect other people to find
> it easier?  Do you feel you can maintain what you've done when you've
> completed your wrapper?  These are important things to think about
> before you put your hands on the keyboard.  I have failed before when
> trying to do something Too Big™ because I didn't think about how hard
> it would be to complete.

True, though if I can do it once, I can do it again.  The question is
whether it's worth the effort if it's going to take 4 hours every time
there's a new release of Subversion.  Beyond that, once I get the
thing started, if it seems to be going reasonably well, I won't be the
only person working on it.

But yeah, the possibility of Too Big™ thing is why I haven't started
writing any code quite yet.  I like to know what I'm getting into.
 
> > And I want that magic to ensue regardless of what platform I'm running
> > on.  If the user doesn't have subversion installed, I don't want that
> > to be a problem.
> 
> I think that you'll be better off making this a requirement, I would
> hate to be stuck duplicating the three different svn access protocols
> (http/DAV, file, svn) or even one of them.
> 
> The subversion people seem to have done a good job of getting
> no-brainer svn packages for all the major platforms.

This is true.  Ok, so maybe having svn as a prereq isn't too much of a problem.
 
> > It looked like the fxruby library did some stuff with SWIG and managed
> > to pull it off fairly well,
> 
> I believe that Lyle has a good deal of C mojo in his back pocket, which
> would make SWIG much easier for him.

Where's the C mojo when you need it?  I think long ago I used to have
it... but thus far I've been happier not even thinking about C.

> Ruby SWIG wrappers for svn once existed, but bitrotted due to lack of
> maintenance...

Well, if you take a look in the subversion subversion repository,
you'll see that they do exist and there's some nice unit tests and
everything for them.  Kou has been working on them fairly recently I
think.  But building for Windows isn't any easier, which, for the
moment, seems to be my main problem.
 
> It sounds like you need to step back and re-evaluate all of the options
> available.
> 
> SWIG seems to be more like a belt-fed, automatic, pneumatic nail gun,
> and less like a box of nails and a hammer.  Just about anybody can use
> a hammer, but a belt-fed, automatic, pneumatic nail gun is going to
> take lots of practice to use correctly.  Once you have it down though,
> you'll be able to pound out houses with ease.  If you can invest the
> time and energy to build SWIG bindings for subversion, then you'll get
> a great tool.
> 
> If you can't invest that time, I would instead go for DL, or a wrapper
> for svn.
> 
> Really, I think you should check out DL, you'll quickly cut your
> problems down to those of actually wrapping the svn dll/so rather than
> trying to figure out why SWIG can't find your apr or svn headers.

I like the sound of DL, but... since there doesn't seem to be any .so
or .dll for the client, maybe it's not even possible?  I don't mind
learning SWIG _too_ much, I still have some C knowledge buried in the
attic, and I can dig it out if I don't have any choice.

So I guess my question now is, can the svn client modify the metadata
in place without writing to disk, or is a checkout necessary?  Same
question for the stuff I'm able to do via the SWIG bindings or the
mythical DL?  This is really the most important part to me I think.

Since it appears that there's actually no svn client libraries
packaged with svn, (presumably because the functionality is entirely
within svn.exe?) then perhaps to use DL magic, I have to compile the
SWIG stuff and then stick _that_ in the DL?  Can I get all of the
resultant DL's (since SWIG seems to generate multiple libraries?) to
package up nicely into one gem without much hassle?

And is there any way to use the svn client to work directly with the
repository in the way I want?  If not, how would you manage a
reasonably large multi-user system with lots of different things being
worked on, probably in some kind of temp directory?  Because right now
I'm envisioning that kind of thing getting out of control really fast.

And if it's not currently possible to edit metadata in place, would it
be unreasonable to make that a feature request for subversion?
-- 
Bob Aman

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org


Re: Accessing SVN through Ruby

Posted by Eric Hodel <dr...@segment7.net>.
On 11 Apr 2005, at 18:43, Bob Aman wrote:

> (Cross-posting to dev@subversion.tigris.org since at least part of
> this message is probably better answered by them.  Apologies to the
> respective mailing lists for the parts that are off topic.)
>
>> Is DL unsuitable for this?  That would require only a compiled SVN
>> library.
>
> DL?

DL is a generic dynamically-linked library wrapper that requires none 
of this C compiler business.  You load a so/dll and tell Ruby what the 
parameters are for the C calls, and it takes care of all the argument 
passing for you.

DL ships with ruby 1.8, but there doesn't seem to be an exact home page 
for it.

http://www.google.com/search?q=ruby+dl

Will give you several tutorial/documents on it.

>> svn lists easily parseable output as one of its features...
>
> I don't think calling out to the command line client is a truely 
> viable option.

Why?

> Ideally, I need a reliable interface to Subversion for Ruby.

If you build it to be reliable, it will be reliable.  Unit tests come 
in really handy for this.

> I want
> to be able to easily wrap it with something more "ruby-like" than the
> raw API.

There's nothing that prevents an svn wrapper from presenting a 
ruby-like API.  DL and SWIG only give different tradeoffs in how this 
is implemented.

> Ideally, I need to be able to "checkout" to memory - I
> probably don't have the luxury of checking stuff out to disk.

While many of the svn commands can work directly with the repository 
without local storage, I don't know of any way to avoid writing to disk 
for those commands that require a local checkout.

> The
> ultimate purpose is something almost like ViewSVN or WebSVN, except
> that I need to, at the very least, be able to modify the metadata from
> within the web app.  And we're probably talking about around 50-100
> concurrent users, not just one person at a time.

FreeBSD's CVSweb shells out for all of its commands, and likely handles 
50-100 concurrent users just fine (probably more, in fact).

> It needs to be cross-platform.

This is easiest if you just shell out, since it will be easier to 
maintain a svn wrapper than maintaining libraries for the platforms 
that don't typically ship with a compiler (windows).

> It needs to be somewhat easy, because I am not a C
> hacker by any stretch of the imagination.  And it's got to be
> reasonably simple to set up on Windows, since, for the moment, that's
> the dev environment I'm stuck with.

Sounds like you'd rather to an svn wrapper or DL (in that order).

> I've been trying to get the Ruby SWIG bindings to work, but I have
> absolutely no idea how to get SWIG to do its thing.  It just sits
> there and complains about missing files.

DL or an svn wrapper will probably get you farther faster than SWIG, 
since both have a lower barrier to entry.  For an svn wrapper you just 
need svn installed.  For DL you need to be able to find an svn .dll or 
.so, which may be as simple as installing svn.  For SWIG you need 
headers and a compiler, which can be no fun if there's no default 
compiler and you have 2 or 3 different compilers to choose from.

> --
> E:\Ruby Projects\Libraries\ruby-svn\swig>swig svn_client.i
> apr.i(47): Error: Unable to find 'apr.h'
> svn_types.i(527): Error: Unable to find 'svn_types.h'
> svn_delta.i(91): Error: Unable to find 'svn_delta.h'
> svn_wc.i(116): Error: Unable to find 'svn_wc.h'
> svn_client.i(434): Error: Unable to find 'svn_client.h'
> --
>
> Of course, it doesn't help that building svn on Windows seems to
> require superhuman effort, though it's quite possible that I'm just
> missing some build step somewhere.

If you're having these difficulties, do you expect other people to find 
it easier?  Do you feel you can maintain what you've done when you've 
completed your wrapper?  These are important things to think about 
before you put your hands on the keyboard.  I have failed before when 
trying to do something Too Big™ because I didn't think about how hard 
it would be to complete.

> But for me to actually do what I want, this thing needs to all get
> packaged up in a gem.  (http://docs.rubygems.org/read/book/1)  Thus
> far, I've gotten the impression that even if I were to get this whole
> SWIG thing to work, the steps required to get there might be too
> difficult for rubygems to handle compiling from source.  Which seems
> to leave me with precompiled gems?  I don't know, I'm kinda fuzzy on
> this.

I believe gems work can ship both precompiled libraries or build their 
own.  I seem to recall that gems have setup.rb on the inside (or 
something like it).

> I want this as the end result:
> gem install ruby-svn
> *poof, magic ensues*

An svn wrapper or DL are going to get you something that works fastest 
and require the fewest incantations before the magic ensues.

> And I want that magic to ensue regardless of what platform I'm running
> on.  If the user doesn't have subversion installed, I don't want that
> to be a problem.

I think that you'll be better off making this a requirement, I would 
hate to be stuck duplicating the three different svn access protocols 
(http/DAV, file, svn) or even one of them.

The subversion people seem to have done a good job of getting 
no-brainer svn packages for all the major platforms.

> I want the only prerequisite to be ruby and
> rubygems.  That includes build tools.  If the user lacks SWIG or vc++
> or whatever, I don't want that to prevent the library from working.  I
> think that leaves me with binaries, but...

Remember that you'll have to do the work of making this cross-platform, 
which means keeping all the necessary packages up to date.  That sounds 
like a lot of work.

> It looked like the fxruby library did some stuff with SWIG and managed
> to pull it off fairly well,

I believe that Lyle has a good deal of C mojo in his back pocket, which 
would make SWIG much easier for him.

> but I'm not sure I want users of the
> library to be presented with a list of 10 possible versions for
> different platforms when they type gem install ruby-svn like what
> happens with fxruby.  Especially when one of those platforms is
> "ruby".  Sooooo.... what happens with fxruby if I'm on Windows and I
> select "ruby" as my platform instead of "win32"?  "ruby" doesn't make
> sense as an option, so ideally, I'd rather just have the end result
> work everywhere instead of confusing the user with nonsensical choices
> that I don't have much control over.

> Also, I don't want to be dealing with bleeding edge stuff from
> Subversion's svn repository.  I have to make the corporate overlords
> happy, and you all know how that goes.
>
> So... is there any way for me to access the subversion client library
> without doing any SWIG magic, or at the very least, doing the SWIG
> magic ahead of time and then including any necessary binaries for the
> various platforms within a single gem?  And if I'm absolutely stuck
> doing SWIG magic, can someone hold my hand and walk me through getting
> that to work in Windows?  I've been trying to do this for almost a
> week now, and I'm really no further than when I first started.

Ruby SWIG wrappers for svn once existed, but bitrotted due to lack of 
maintenance...



It sounds like you need to step back and re-evaluate all of the options 
available.



SWIG seems to be more like a belt-fed, automatic, pneumatic nail gun, 
and less like a box of nails and a hammer.  Just about anybody can use 
a hammer, but a belt-fed, automatic, pneumatic nail gun is going to 
take lots of practice to use correctly.  Once you have it down though, 
you'll be able to pound out houses with ease.  If you can invest the 
time and energy to build SWIG bindings for subversion, then you'll get 
a great tool.

If you can't invest that time, I would instead go for DL, or a wrapper 
for svn.



Really, I think you should check out DL, you'll quickly cut your 
problems down to those of actually wrapping the svn dll/so rather than 
trying to figure out why SWIG can't find your apr or svn headers.

-- 
Eric Hodel - drbrain@segment7.net - http://segment7.net
FEC2 57F1 D465 EB15 5D6E  7C11 332A 551C 796C 9F04

Re: Accessing SVN through Ruby

Posted by Bob Aman <va...@gmail.com>.
(Cross-posting to dev@subversion.tigris.org since at least part of
this message is probably better answered by them.  Apologies to the
respective mailing lists for the parts that are off topic.)

> Is DL unsuitable for this?  That would require only a compiled SVN
> library.

DL?

> svn lists easily parseable output as one of its features...

I don't think calling out to the command line client is a truely viable option.

Ideally, I need a reliable interface to Subversion for Ruby.  I want
to be able to easily wrap it with something more "ruby-like" than the
raw API.  Ideally, I need to be able to "checkout" to memory - I
probably don't have the luxury of checking stuff out to disk.  The
ultimate purpose is something almost like ViewSVN or WebSVN, except
that I need to, at the very least, be able to modify the metadata from
within the web app.  And we're probably talking about around 50-100
concurrent users, not just one person at a time.  It needs to be
cross-platform.  It needs to be somewhat easy, because I am not a C
hacker by any stretch of the imagination.  And it's got to be
reasonably simple to set up on Windows, since, for the moment, that's
the dev environment I'm stuck with.

I've been trying to get the Ruby SWIG bindings to work, but I have
absolutely no idea how to get SWIG to do its thing.  It just sits
there and complains about missing files.

--
E:\Ruby Projects\Libraries\ruby-svn\swig>swig svn_client.i
apr.i(47): Error: Unable to find 'apr.h'
svn_types.i(527): Error: Unable to find 'svn_types.h'
svn_delta.i(91): Error: Unable to find 'svn_delta.h'
svn_wc.i(116): Error: Unable to find 'svn_wc.h'
svn_client.i(434): Error: Unable to find 'svn_client.h'
--

Of course, it doesn't help that building svn on Windows seems to
require superhuman effort, though it's quite possible that I'm just
missing some build step somewhere.

But for me to actually do what I want, this thing needs to all get
packaged up in a gem.  (http://docs.rubygems.org/read/book/1)  Thus
far, I've gotten the impression that even if I were to get this whole
SWIG thing to work, the steps required to get there might be too
difficult for rubygems to handle compiling from source.  Which seems
to leave me with precompiled gems?  I don't know, I'm kinda fuzzy on
this.

I want this as the end result:
gem install ruby-svn
*poof, magic ensues*

And I want that magic to ensue regardless of what platform I'm running
on.  If the user doesn't have subversion installed, I don't want that
to be a problem.  I want the only prerequisite to be ruby and
rubygems.  That includes build tools.  If the user lacks SWIG or vc++
or whatever, I don't want that to prevent the library from working.  I
think that leaves me with binaries, but...

It looked like the fxruby library did some stuff with SWIG and managed
to pull it off fairly well, but I'm not sure I want users of the
library to be presented with a list of 10 possible versions for
different platforms when they type gem install ruby-svn like what
happens with fxruby.  Especially when one of those platforms is
"ruby".  Sooooo.... what happens with fxruby if I'm on Windows and I
select "ruby" as my platform instead of "win32"?  "ruby" doesn't make
sense as an option, so ideally, I'd rather just have the end result
work everywhere instead of confusing the user with nonsensical choices
that I don't have much control over.

Also, I don't want to be dealing with bleeding edge stuff from
Subversion's svn repository.  I have to make the corporate overlords
happy, and you all know how that goes.

So... is there any way for me to access the subversion client library
without doing any SWIG magic, or at the very least, doing the SWIG
magic ahead of time and then including any necessary binaries for the
various platforms within a single gem?  And if I'm absolutely stuck
doing SWIG magic, can someone hold my hand and walk me through getting
that to work in Windows?  I've been trying to do this for almost a
week now, and I'm really no further than when I first started.
-- 
Bob Aman

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org