LuaSVN - Using Subversion from Lua


Introduction
Basic Operation
Change Log
API
Getting LuaSVN
Building LuaSVN
Contact and Further Information
License


Introduction

LuaSVN is a library that allows to use some Subversion (SVN) facilities inside Lua programs.

Subversion is an open source version control system that has becoming very popular, currently it is the version control system used in more than half of the open source projects according Cia.vc.

Subversion is used not only in source code versioning, but also in web pages versioning, in fact, this was the original motivation to develop LuaSVN.

LuaSVN was developed using the C API offered by Subversion and implements a basic set of functions which can be used in a Lua program. The functions available in LuaSVN are similar to the functions offered by the svn tool, but not all svn functions were implemented.

Basic Operation

Subversion uses some functionalities from Apache Portable Runtime (APR) project, because APR offers a standard interface to underlying platform-specific implementations, so Subversion does not need to worry about some lower level questions. Because of this, the memory handling is done by a pool from APR library, which by turn is passed as an argument to functions of the Subversion's C API.

The function init_function does the job to set up the initial configuration. The code related to the specific behavior of a function then comes after.

Change Log

This is a brief history of LuaSVN:

API

This version of LuaSVN works with URLs (e.g., "file:///", "http://", etc) and with paths (e.g., "wc/", "/home/name/workingcopy", etc). It also handles correctly the extra slash in the end of an URL or a path.

Often a LuaSVN function also has an integer optional parameter revision indicating the number of the version which should be considered. If this value is not specified, or if it is nil, then a default value will be supplied. Most of the time this value will be the youngest version of the repository, in case of an URL, and the base working copy, in case of a path. In general, if a function has an optional parameter, a default value will be used if an argument was not supplied or if nil was supplied.

The standard behavior of a LuaSVN function when an error occurs is to call lua_error.

The first thing you should do, so you can use LuaSVN, is to import the library. This can be done including require ("svn") in your Lua program. The functions below are in the version 0.2.6 of the LuaSVN API:

Getting LuaSVN

Click here to download LuaSVN from LuaForge.

Building LuaSVN

LuaSVN needs development versions of Subversion and APR. On Ubuntu, if you have the right permissions, you can install them in the following way:

sudo apt-get install libsvn-dev

Now you need to edit the makefile to reflect the places where Subversion and APR are installed. After this, you can type make and copy svn.so to a place where your Lua installation can find it, a typical one is: /usr/local/lib/lua/5.1/.

If you can not install LuaSVN this way, please take a look at http://www.freewisdom.org/projects/sputnik/Building_LuaSVN or feel free to ask.

To be able to use the URLs with http protocol, you will also need libneon, this can be a little bit complicated, but, in resume, you do not need to worry if you are building LuaSVN using apt-get and you should get libneon-0.25.X if you are building LuaSVN by yourself. I will try to put a more step-by-step guide if needed.

Contact and Further Information

LuaSVN was developed by Sérgio Medeiros and is free software. If you have any comments or doubts, please send an e-mail to the LuaSVN list or for me (smedeiros at inf dot puc-rio dot br).

License

Copyright © 2007 Sérgio Medeiros.

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.