SWiM/Subversion client

You can associate a Subversion repository with each wiki namespace. Wiki pages will be imported from that repository for viewing and editing, and exported there when they are edited in the wiki. In fact, the SWiM database acts as a working copy. But SWiM is not yet a complete Subversion client; Subversion does not fully replace the database backend. So far, the commands update, commit, lock, and unlock are supported, i.e. there is no conflict resolution yet.

The client is implemented using the repository package of svnkit.

Database tables
The Subversion client has to be configured manually in the database; see The following tables are used for the SWiM Subversion client: CREATE TABLE subversion ( id           INT NOT NULL PRIMARY KEY DEFAULT nextval('subversion_ids'),  user_id      INT NOT NULL REFERENCES users(id) ON DELETE CASCADE,  namespace_id INT NOT NULL REFERENCES namespaces(id) ON DELETE CASCADE,  login        CHAR(80) NOT NULL,  password     CHAR(80) NOT NULL,  UNIQUE(user_id,namespace_id) );

CREATE TABLE subversion_urlmap ( namespace_id       INT NOT NULL REFERENCES namespaces(id) ON DELETE CASCADE,  svn_repos_url      CHAR(255),  page_title_pattern CHAR(255) NOT NULL,  svn_path_url       CHAR(255) NOT NULL );

Detailed explanation

 * subversion
 * maps user×namespace to a Subversion account. Unless subversion_urlmap has an entry for the namespace, the namespace URI is assumed to be the Subversion repository URL.
 * user_id:the internal ID of a wiki user
 * namespace_id:the internal ID of a wiki namespace
 * login:the Subversion login (as it can be different from the wiki login)
 * password:the Subversion password, currently stored as plain text, as I don't know how to use svnkit with encrypted/hashed password


 * subversion_urlmap
 * optional: map wiki page URIs (the internal ones, not the once that you see in the browser) to different Subversion resource URLs
 * namespace:a wiki namespace ID
 * svn_repos_url:the actual URL of the repository, or the directory within the repository. If NULL, the namespace URI is used
 * page_title_pattern:a regular expression (as defined for java.util.regex.Pattern) that is matched against the wiki page title, i.e. the local name of the full internal URI of a wiki page
 * svn_path_url:a string that is replaced for page_title_pattern, may contain backreferences to bracketed groups in the pattern

Example
To do

Snippets
Grant a few users access to the Subversion repository with a shared account: insert into subversion(user_id,namespace_id,login,password) select users.id,NAMESPACE_ID,'SVN_LOGIN','SVN_PASSWD' from users where users.login ~ E'^(username1|username2|...)\\s+$';