[[What Is Subversion For|<<]] ... [[SVNKit Architecture|>>]]
== Subversion repository types ==
Up to now a [http://svnbook.red-bean.com/nightly/en/svn.reposadmin.html#svn.reposadmin.basics.backends Subversion repository storage]
can be represented by either a [http://svnbook.red-bean.com/nightly/en/svn.reposadmin.html#svn.reposadmin.basics.backends.bdb Berkley DB database]
(mostly reffered as ''Berkley DB'' type) or by an [http://svnbook.red-bean.com/nightly/en/svn.reposadmin.html#svn.reposadmin.basics.backends.fsfs ordinary filesystem]
(mostly reffered as ''FSFS'' type).
== Creating a Subversion repository manually ==
A Subversion distribution package (it can be downloaded from the [http://subversion.tigris.org Subversion home site])
includes a tool called '''svnadmin''' which is responsible for creating repositories. When you install Subversion you
can create a repository performing a command in the command prompt:
...>svnadmin create C:\path
This will create an FSFS repository at the path you specify. You may also explicitly provide the type of a repository
back-end:
...>svnadmin create --fs-type bdb C:\path
The layout of a repository root directory looks like this:
/
|_conf/
|_dav/
|_db/
|_hooks/
|_locks/
|_format
|_readme.txt
Read [http://svnbook.red-bean.com/nightly/en/svn.reposadmin.create.html official instructions] how to create and set up
a repository on your computer using official Subversion tools.
== Creating a Subversion repository with SVNKit ==
'''SVNKit''' provides an ability to create only FSFS-type repositories. The following is a code snippet which
demonstrates how you can create a blank repository using '''SVNKit''':
The second parameter of the ''createLocalRepository(...)'' method set to ''true'' enables modifications to [http://svnbook.red-bean.com/nightly/en/svn.reposadmin.html#svn.reposadmin.basics.revprops revision properties] of the created repository. As revision properties are unversioned, there's a risk to lose their values forever if changes to them are allowed. To allow revision properties changing you have to place an executable ''pre-revprop-change'' [http://svnbook.red-bean.com/nightly/en/svn.reposadmin.create.html#svn.reposadmin.create.hooks hook script] file into the ''hooks'' directory (see the repository root directory layout above). When someone is trying to change a revision property, a server (say, [http://svnbook.red-bean.com/nightly/en/svn.serverconfig.svnserve.html svnserve]) first invokes a ''pre-revprop-change'' hook. If this hook script is not found in the ''hooks'' directory, or the script returns a non-zero value, modifications to revision properties are rejected by the server.
When you create a new repository with the Subversion's '''svnadmin''' tool a new repository's ''hook'' directory contains no real hook files, but only hook templates. This means that you won't be able to change revision properties until you place a ''pre-revprop-change'' hook manually into the target ''hooks'' directory. With '''SVNKit''' enabling changes to revision properties is quite straightforward. When the second parameter of the ''createLocalRepository(...)'' methos is ''true'' '''SVNKit''' places an empty executable ''pre-revprop-change'' hook script into the ''hooks'' directory of a new repository. Such a hook does nothing, simply returns 0 letting the requested change operation perform. However when this parameter is ''false'' no hook scripts are added (but only templates), and revision properties changing is disabled.
The third parameter of the ''createLocalRepository(...)'' method controls whether a repository creation must be forced or not. That is, if this parameter is ''true'' and a repository already exists at the path you provide to ''createLocalRepository(...)'' '''SVNKit''' replaces it with a new repository. However if it's ''false'' an existing repository is not removed and a new repository creation fails with an [http://svnkit.com/kb/javadoc/org/tmatesoft/svn/core/SVNException.html SVNException].
If a repository is successfully created the ''createLocalRepository(...)'' method returns a ''file:///'' url of the repository root location.
Also you may create an FSFS-type repository with [http://svnkit.com/kb/javadoc/org/tmatesoft/svn/core/wc/SVNAdminClient.html SVNAdminClient] -
the class belonging to high-level API. Actually this admin client class uses [http://svnkit.com/kb/javadoc/org/tmatesoft/svn/core/io/SVNRepositoryFactory.html SVNRepositoryFactory]
to do the same job.
[[What Is Subversion For|<<]] ... [[SVNKit Architecture|>>]]