1 / 139

Automating Subversion with Bindings

Automating Subversion with Bindings. @ BenReser http:// svn.ms / autosvnslides. About Ben. Subversion Committer working at WANdisco since 2012.

brian
Download Presentation

Automating Subversion with Bindings

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Automating Subversion with Bindings @BenReser http://svn.ms/autosvnslides

  2. About Ben Automating Subversion with Bindings Subversion Committer working at WANdisco since 2012. Started working on Perl Bindings in 2003 to automate Subversion as a replacement for CVS. Never finished the project that inspired the work and ended up working on Subversion itself. My work isn’t limited to bindings anymore and has expanded across the different parts of Subversion including acting as the Release Manager.

  3. What are Bindings?

  4. What is Subversion… Automating Subversion with Bindings An implementation of a Version Control System?

  5. What is Subversion… Automating Subversion with Bindings An implementation of a Version Control System? Libraries that implement a Version Control System.

  6. What is Subversion… Automating Subversion with Bindings • An implementation of a Version Control System? • Libraries that implement a Version Control System. • Written in C

  7. Layered Library Design Automating Subversion with Bindings

  8. Layered Library Design - Client Automating Subversion with Bindings • Client • Implements the basic functions of a client. Knows about working copies and uses the…

  9. Layered Library Design - Client Automating Subversion with Bindings • Client • Implements the basic functions of a client. Knows about working copies and uses the… • WC (Working Copy) • Implements the working copy

  10. Layered Library Design - Client Automating Subversion with Bindings • Client • Implements the basic functions of a client. Knows about working copies and uses the… • WC (Working Copy) • Implements the working copy • RA (Repository Access) • Implements protocol to talk to (possibly remote) repository • Local (file://) • Neon (http(s):// 1.7.x and older was called DAV in 1.4.x and older, gone in 1.8.x) • Serf (http(s):// 1.5.x and newer) • SVN (svn://)

  11. Layered Library Design - Server Automating Subversion with Bindings • Repos • Repository interface which implements high level repository functionality and uses…

  12. Layered Library Design - Server Automating Subversion with Bindings • Repos • Repository interface which implements high level repository functionality and uses… • FS • File system implementation to store a repository • FS_Base (Berkeley DB) • FS_FS (non database implementation)

  13. Layered Library Design – Misc. Automating Subversion with Bindings • Subr • Miscellaneous subroutines

  14. Layered Library Design – Misc. Automating Subversion with Bindings • Subr • Miscellaneous subroutines • Delta • Tree and byte-stream differencing routines

  15. Layered Library Design – Misc. Automating Subversion with Bindings • Subr • Miscellaneous subroutines • Delta • Tree and byte-stream differencing routines • Diff • Contextual differencing and merge routines

  16. What are Bindings? Automating Subversion with Bindings • Access Subversion C APIs from other Higher Level Programming Languages

  17. What are Bindings? Automating Subversion with Bindings • Access Subversion C APIs from other Higher Level Programming Languages • Somewhat easier to use than C

  18. What are Bindings? Automating Subversion with Bindings • Access Subversion C APIs from other Higher Level Programming Languages • Somewhat easier to use than C • Provide an interface that somewhat matches the Higher Level Language’s idioms

  19. What are Bindings? Automating Subversion with Bindings • Access Subversion C APIs from other Higher Level Programming Languages • Somewhat easier to use than C • Provide an interface that somewhat matches the Higher Level Language’s idioms • May even hide some annoying details from using the libraries

  20. Why use Bindings?

  21. Can’t I Just Script The Client? Automating Subversion with Bindings • The client tries to have machine readable formats

  22. Can’t I Just Script The Client? Automating Subversion with Bindings • The client tries to have machine readable formats • I recently used something like this to try and find a bug in diff –summarize: (svn log $URL | grep -Eo '^r[0-9]+ \| ' | sed 's/[^0-9]//g') | while read rev; do svn diff --summarize $URL -c $rev; done

  23. Can’t I Just Script The Client? Automating Subversion with Bindings • It worked great until it ran into this output: svn log –c 933481 https://svn.apache.org/repos/asf/subversion/trunk ------------------------------------------------------------------------ r933481 | gstein | 2010-04-12 21:20:50 -0700 (Mon, 12 Apr 2010) | 27 lines Add some new methods to the Sandbox class for performing simple, unverified operations. Also introduce deep magic with svntest.main.make_log_msg() to produce log messages that show the source of the command invocation. These automated log messages look like: ---- r2 | jrandom | 2010-04-12 23:57:10 -0400 (Mon, 12 Apr 2010) | 1 line File './schedule_tests.py', line 543, in status_add_deleted_directory ----

  24. What about XML? Automating Subversion with Bindings • The client supports XML output with --xml on most commands.

  25. What about XML? Automating Subversion with Bindings • The client supports XML output with --xml on most commands. • XML is hard to parse correctly • Regexps aren’t reliable • XSLT is a pain to write • XML parsers are far from easy to drive

  26. Command behavior changes Automating Subversion with Bindings • We try to avoid changing the output and behavior of commands.

  27. Command behavior changes Automating Subversion with Bindings • We try to avoid changing the output and behavior of commands.

  28. Command behavior changes Automating Subversion with Bindings • We try to avoid changing the output and behavior of commands. • svnmergeinfo prior to 1.8.0 behaved as though --show-revs=merged was passed if no --show-revs option was passed. In 1.8.x this shows a graph.

  29. Greater capabilities Automating Subversion with Bindings • We can implement functionality that the command line client doesn’t have. • Examples: • ViewVC • Subclipse • control-chars.py hook-script

  30. Why not use Bindings? Automating Subversion with Bindings • Poor documentation

  31. Why not use Bindings? Automating Subversion with Bindings • Poor documentation • Need to install them

  32. Why not use Bindings? Automating Subversion with Bindings • Poor documentation • Need to install them • Expose internal details that may be hard to understand

  33. Why not use Bindings? Automating Subversion with Bindings • Poor documentation • Need to install them • Expose internal details that may be hard to understand • Not always updated for the latest features

  34. Getting Started

  35. What Bindings Are Available Automating Subversion with Bindings • SWIG • Python • Perl • Ruby • JavaHL • ctypes-python • SVNKit • pySVN

  36. What is SWIG? Automating Subversion with Bindings • Simplified Wrapper and Interface Generator

  37. What is SWIG? Automating Subversion with Bindings • Simplified Wrapper and Interface Generator • Partly automated generator

  38. What is SWIG? Automating Subversion with Bindings • Simplified Wrapper and Interface Generator • Partly automated generator • Acts like a specialized C compiler

  39. What is SWIG? Automating Subversion with Bindings • Simplified Wrapper and Interface Generator • Partly automated generator • Acts like a specialized C compiler • Only needed at interface generation time

  40. How To Install Bindings Automating Subversion with Bindings Windows Mac RedHat based Linux Debian based Linux Other

  41. Windows Automating Subversion with Bindings • WANdisco installer • Provides swig-python (for Python 2.7.2) and JavaHL • Alagazam.net • Provides swig-python, swig-perl, swig-ruby, and JavaHL

  42. RedHat based Linux Automating Subversion with Bindings • WANdisco packages • subversion-python (SWIG) • subversion-ruby (subversion 1.8.x only) • subversion-perl • subversion-javahl • OS Packages • Older but usually available and named same as above.

  43. Debian based Linux Automating Subversion with Bindings • WANdisco packages • python-subversion (SWIG) • libsvn-ruby (and libsvn-ruby1.8 for Ruby 1.8) • libsvn-perl • libsvn-java (JavaHL) • OS Packages • Older but usually available and named same as above.

  44. Mac Automating Subversion with Bindings • WANdisco installer • Provides swig-python, swig-perl, swig-ruby and JavaHL • MacPorts • subversion-javahlbindings • subversion-perlbindings-5.16 (number is perl version) • subversion-python27bindings (number is python version) • subversion-rubybindings • Homebrew • can provide JavaHL, swig-perl, swig-python, and swig-ruby • Xcode • Command line tools • old but includes swig-python, swig-perl and swig-ruby

  45. Other Automating Subversion with Bindings • WANdisco packages should have Bindings for most OSes • *NIX platforms build it yourself by: • [usual Subversion build instructions] • make $binding • make check-$binding • make install-$binding where $binding can be: javahl swig-pl swig-py swig-rb Don’t use do parallel builds of bindings (-j option to make)

  46. Build It Yourself - SWIG Automating Subversion with Bindings • On the Mac you need to do this before the normal Subversion instructions due to a bug in our API that makes the bindings fail to compile (requires SWIG, libtool and autoconf): • make extraclean • ./autogen.sh

  47. Build It Yourself - SWIG Automating Subversion with Bindings • On the Mac you need to do this before the normal Subversion instructions due to a bug in our API that makes the bindings fail to compile (requires SWIG, libtool and autoconf): • make extraclean • ./autogen.sh • May need the same instructions on other platforms if you get an error about an undeclared symbol starting with SVN_AUTH

  48. Build It Yourself - SWIG Automating Subversion with Bindings • On the Mac you need to do this before the normal Subversion instructions due to a bug in our API that makes the bindings fail to compile (requires SWIG, libtool and autoconf): • make extraclean • ./autogen.sh • May need the same instructions on other platforms if you get an error about an undeclared symbol starting with SVN_AUTH • To use Ruby 1.9 need Subversion 1.8.x

  49. Build It Yourself - SWIG Automating Subversion with Bindings • On the Mac you need to do this before the normal Subversion instructions due to a bug in our API that makes the bindings fail to compile (requires SWIG, libtool and autoconf): • make extraclean • ./autogen.sh • May need the same instructions on other platforms if you get an error about an undeclared symbol starting with SVN_AUTH • To use Ruby 1.9 need Subversion 1.8.x • Python 3 doesn’t work

  50. Build It Yourself - JavaHL Automating Subversion with Bindings • Need --enable-javahl passed to configure

More Related