LuaSVN - Using Subversion from Lua

lua svn lua subversion 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.

Some LuaSVN functions also have as an optional parameter a configuration table, named config. This table has several fields that receive boolean values. Each function indicates which fields of config are important for it.

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.3.0 of the LuaSVN API:

Getting LuaSVN

Click here to download LuaSVN from LuaForge.

Building LuaSVN

There are several ways to build LuaSVN. One easy way to install LuaSVN is by using LuaRocks. If you can not install LuaSVN using LuaRocks, it may be useful to take a look in this messageof the LuaRocks mailing list and the corresponding answer.

On Ubuntu, if you have the right permissions, you can do this:

  1. Install libsvn-dev:
    	sudo apt-get install libsvn-dev
    	
  2. Type make
  3. 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 use a tool like apt-get, then you need to install Subversion and APR. After this, you should edit the makefile and adjust the variables APR, APR_UTIL and SUBVERSION. You should also use the right definition of LDFLAGS, as explained in the makefile.

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.

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 Lua list or for me (smedeiros at inf dot puc-rio dot br).

License

Copyright © 2007-2009 LabLua.

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.