[svn.haxx.se] · SVN Dev · SVN Users · SVN Org · TSVN Dev · TSVN Users · Subclipse Dev · Subclipse Users · this month's index

[PATCH] Make DAV activity db location configurable

From: Eric Gillespie <epg_at_pretzelnet.org>
Date: 2007-04-28 02:38:50 CEST

I originally posted a patch that both converted the database to a
directory map and made the location configurable. Now that the
first part is in, here's the second part. svn_repos now only
knows about the "dav" directory for compatibility; in 2.0 that
should go away.

[[[
Make the location of mod_dav_svn's activity database configurable with a
new SVNActivitiesDB configuration directive. If set, use it directly as
the activity db for SVNPath repositories. For SVNParentPath repositories,
use it to contain activity db directories named after the repository
basename. If this directive is not specified, use "dav/activities.d" at
the top of the repository.

* subversion/mod_dav_svn/mod_dav_svn.c
  (dir_conf_t): Add activities_db member.
  (merge_dir_config): Merge in activities_db field.
  (SVNActivitiesDB_cmd): Implement SVNActivitiesDB.
  (dav_svn__get_activities_db): Expose new field.
  (cmds): Declare SVNActivitiesDB directive.

* subversion/mod_dav_svn/dav_svn.h
  (dav_svn_repos): Add activities_db member.
  (dav_svn__get_activities_db): Declare.

* subversion/mod_dav_svn/repos.c
  (DEFAULT_ACTIVITY_DB): New macro.
  (get_resource): Set repos->activities_db based on activities_db
    config and maybe DEFAULT_ACTIVITY_DB.

* subversion/mod_dav_svn/activity.c
  (ACTIVITY_DB): No longer used.
  (activity_pathname): New function, constructs activity path from
    repos->activities_db.
  (dav_svn__get_txn, dav_svn__delete_activity): Use activity_pathname.
  (dav_svn__store_activity): Create repos->activities_db if it does
    not exist. Use activity_pathname.

* subversion/libsvn_repos/repos.c
  (create_svn_repos_t): Don't fill in dav_path.
  (create_repos_structure): Take fs_config argument and create the
    "dav" path (SVN_REPOS__DAV_DIR) only if it has the
    SVN_FS_CONFIG_PRE_1_5_COMPATIBLE setting.
  (svn_repos_create): Pass fs_config to create_repos_structure.

* subversion/libsvn_repos/repos.h
  (SVN_REPOS__DAV_DIR): Note this is only for pre-1.5 compatibility.
  (svn_repos_t): Drop dav_path member.
]]]

Index: subversion/mod_dav_svn/mod_dav_svn.c
===================================================================
--- subversion/mod_dav_svn/mod_dav_svn.c (revision 24819)
+++ subversion/mod_dav_svn/mod_dav_svn.c (working copy)
@@ -67,6 +67,7 @@
   enum conf_flag list_parentpath; /* whether to allow GET of parentpath */
   const char *root_dir; /* our top-level directory */
   const char *master_uri; /* URI to the master SVN repos */
+ const char *activities_db; /* path to activities database(s) */
 } dir_conf_t;
 
 
@@ -156,6 +157,7 @@
 
   newconf->fs_path = INHERIT_VALUE(parent, child, fs_path);
   newconf->master_uri = INHERIT_VALUE(parent, child, master_uri);
+ newconf->activities_db = INHERIT_VALUE(parent, child, activities_db);
   newconf->repo_name = INHERIT_VALUE(parent, child, repo_name);
   newconf->xslt_uri = INHERIT_VALUE(parent, child, xslt_uri);
   newconf->fs_parent_path = INHERIT_VALUE(parent, child, fs_parent_path);
@@ -192,6 +194,17 @@
 
 
 static const char *
+SVNActivitiesDB_cmd(cmd_parms *cmd, void *config, const char *arg1)
+{
+ dir_conf_t *conf = config;
+
+ conf->activities_db = apr_pstrdup(cmd->pool, arg1);
+
+ return NULL;
+}
+
+
+static const char *
 SVNIndexXSLT_cmd(cmd_parms *cmd, void *config, const char *arg1)
 {
   dir_conf_t *conf = config;
@@ -454,6 +467,16 @@
 }
 
 
+const char *
+dav_svn__get_activities_db(request_rec *r)
+{
+ dir_conf_t *conf;
+
+ conf = ap_get_module_config(r->per_dir_config, &dav_svn_module);
+ return conf->activities_db;
+}
+
+
 static void
 merge_xml_filter_insert(request_rec *r)
 {
@@ -619,6 +642,12 @@
   AP_INIT_TAKE1("SVNMasterURI", SVNMasterURI_cmd, NULL, ACCESS_CONF,
                 "specifies a URI to access a master Subversion repository"),
 
+ /* per directory/location */
+ AP_INIT_TAKE1("SVNActivitiesDB", SVNActivitiesDB_cmd, NULL, ACCESS_CONF,
+ "specifies the location in the filesystem in which the "
+ "activities database(s) should be stored"),
+
+
   { NULL }
 };
 
Index: subversion/mod_dav_svn/dav_svn.h
===================================================================
--- subversion/mod_dav_svn/dav_svn.h (revision 24819)
+++ subversion/mod_dav_svn/dav_svn.h (working copy)
@@ -109,6 +109,9 @@
   /* is the client a Subversion client? */
   svn_boolean_t is_svn_client;
 
+ /* The path to the activities db */
+ const char *activities_db;
+
 } dav_svn_repos;
 
 
@@ -296,6 +299,9 @@
 /* Return the master URI (for mirroring) */
 const char * dav_svn__get_master_uri(request_rec *r);
 
+/* Return the activities db */
+const char * dav_svn__get_activities_db(request_rec *r);
+
 /* Return the root directory */
 const char * dav_svn__get_root_dir(request_rec *r);
 
Index: subversion/mod_dav_svn/repos.c
===================================================================
--- subversion/mod_dav_svn/repos.c (revision 24819)
+++ subversion/mod_dav_svn/repos.c (working copy)
@@ -44,6 +44,9 @@
 #include "dav_svn.h"
 
 
+#define DEFAULT_ACTIVITY_DB "dav/activities.d"
+
+
 struct dav_stream {
   const dav_resource *res;
 
@@ -1572,6 +1575,21 @@
   /* Is autoversioning active in this repos? */
   repos->autoversioning = dav_svn__get_autoversioning_flag(r);
 
+ /* Path to activities database */
+ repos->activities_db = dav_svn__get_activities_db(r);
+ if (repos->activities_db == NULL)
+ /* If not specified, use default ($repos/dav/activities.d). */
+ repos->activities_db = svn_path_join(repos->fs_path,
+ DEFAULT_ACTIVITY_DB,
+ r->pool);
+ else if (fs_parent_path != NULL)
+ /* If this is a ParentPath-based repository, treat the specified
+ path as a similar parent directory. */
+ repos->activities_db = svn_path_join(repos->activities_db,
+ svn_path_basename(repos->fs_path,
+ r->pool),
+ r->pool);
+
   /* Remember various bits for later URL construction */
   repos->base_url = ap_construct_url(r->pool, "", r);
   repos->special_uri = dav_svn__get_special_uri(r);
Index: subversion/mod_dav_svn/activity.c
===================================================================
--- subversion/mod_dav_svn/activity.c (revision 24819)
+++ subversion/mod_dav_svn/activity.c (working copy)
@@ -33,9 +33,6 @@
 #include "dav_svn.h"
 
 
-#define ACTIVITY_DB "dav/activities.d"
-
-
 /* Escape ACTIVITY_ID to be safely usable as a filename. Simply
    returns the MD5 checksum of the id.
 */
@@ -47,7 +44,16 @@
   return svn_md5_digest_to_cstring_display(digest, pool);
 }
 
+/* Return filename for ACTIVITY_ID under the repository in REPOS. */
+static const char *
+activity_pathname(const dav_svn_repos *repos, const char *activity_id)
+{
+ return svn_path_join(repos->activities_db,
+ escape_activity(activity_id, repos->pool),
+ repos->pool);
+}
 
+
 /* FSFS transaction ids:
    19 bytes for svn_revnum_t (room for 32 or 64 bit values)
    + 1 byte for '-'
@@ -139,11 +145,7 @@
 const char *
 dav_svn__get_txn(const dav_svn_repos *repos, const char *activity_id)
 {
- const char *pathname;
- pathname = svn_path_join_many(repos->pool, repos->fs_path, ACTIVITY_DB,
- escape_activity(activity_id, repos->pool),
- NULL);
- return read_txn(pathname, repos->pool);
+ return read_txn(activity_pathname(repos, activity_id), repos->pool);
 }
 
 
@@ -160,9 +162,7 @@
      404. If the transaction is not present or is immutable, return a
      204. For all other failures, return a 500. */
 
- pathname = svn_path_join_many(repos->pool, repos->fs_path, ACTIVITY_DB,
- escape_activity(activity_id, repos->pool),
- NULL);
+ pathname = activity_pathname(repos, activity_id);
   txn_name = read_txn(pathname, repos->pool);
   if (txn_name == NULL)
     {
@@ -228,19 +228,13 @@
   apr_file_t *activity_file;
 
   /* Create activities directory if it does not yet exist. */
- err = svn_io_make_dir_recursively(svn_path_join_many(repos->pool,
- repos->fs_path,
- ACTIVITY_DB,
- NULL),
- repos->pool);
+ err = svn_io_make_dir_recursively(repos->activities_db, repos->pool);
   if (err != NULL)
     return dav_svn__convert_err(err, HTTP_INTERNAL_SERVER_ERROR,
                                 "could not initialize activity db.",
                                 repos->pool);
 
- final_path = svn_path_join_many(repos->pool, repos->fs_path, ACTIVITY_DB,
- escape_activity(activity_id, repos->pool),
- NULL);
+ final_path = activity_pathname(repos, activity_id);
   err = svn_io_open_unique_file2(&activity_file, &tmp_path, final_path,
                                  ".tmp", svn_io_file_del_none, repos->pool);
   if (err)
Index: subversion/libsvn_repos/repos.c
===================================================================
--- subversion/libsvn_repos/repos.c (revision 24819)
+++ subversion/libsvn_repos/repos.c (working copy)
@@ -1593,7 +1593,6 @@
 
   repos->path = apr_pstrdup(pool, path);
   repos->db_path = svn_path_join(path, SVN_REPOS__DB_DIR, pool);
- repos->dav_path = svn_path_join(path, SVN_REPOS__DAV_DIR, pool);
   repos->conf_path = svn_path_join(path, SVN_REPOS__CONF_DIR, pool);
   repos->hook_path = svn_path_join(path, SVN_REPOS__HOOK_DIR, pool);
   repos->lock_path = svn_path_join(path, SVN_REPOS__LOCK_DIR, pool);
@@ -1605,15 +1604,22 @@
 static svn_error_t *
 create_repos_structure(svn_repos_t *repos,
                        const char *path,
+ apr_hash_t *fs_config,
                        apr_pool_t *pool)
 {
   /* Create the top-level repository directory. */
   SVN_ERR_W(create_repos_dir(path, pool),
             _("Could not create top-level directory"));
 
- /* Create the DAV sandbox directory. */
- SVN_ERR_W(create_repos_dir(repos->dav_path, pool),
- _("Creating DAV sandbox dir"));
+ /* Create the DAV sandbox directory if pre-1.5-compatible. */
+ if (fs_config && apr_hash_get(fs_config, SVN_FS_CONFIG_PRE_1_5_COMPATIBLE,
+ APR_HASH_KEY_STRING))
+ {
+ const char *dav_path = svn_path_join(repos->path,
+ SVN_REPOS__DAV_DIR, pool);
+ SVN_ERR_W(create_repos_dir(dav_path, pool),
+ _("Creating DAV sandbox dir"));
+ }
 
   /* Create the lock directory. */
   SVN_ERR(create_locks(repos, pool));
@@ -1730,7 +1736,7 @@
     repos->fs_type = DEFAULT_FS_TYPE;
 
   /* Create the various files and subdirectories for the repository. */
- SVN_ERR_W(create_repos_structure(repos, path, pool),
+ SVN_ERR_W(create_repos_structure(repos, path, fs_config, pool),
             _("Repository creation failed"));
   
   /* Lock if needed. */
Index: subversion/libsvn_repos/repos.h
===================================================================
--- subversion/libsvn_repos/repos.h (revision 24819)
+++ subversion/libsvn_repos/repos.h (working copy)
@@ -54,7 +54,7 @@
 #define SVN_REPOS__FORMAT "format" /* Stores the current version
                                                of the repository. */
 #define SVN_REPOS__DB_DIR "db" /* Where Berkeley lives. */
-#define SVN_REPOS__DAV_DIR "dav" /* DAV sandbox. */
+#define SVN_REPOS__DAV_DIR "dav" /* DAV sandbox, for pre-1.5 */
 #define SVN_REPOS__LOCK_DIR "locks" /* Lock files live here. */
 #define SVN_REPOS__HOOK_DIR "hooks" /* Hook programs. */
 #define SVN_REPOS__CONF_DIR "conf" /* Configuration files. */
@@ -100,9 +100,6 @@
   /* The path to the repository's top-level directory. */
   char *path;
 
- /* The path to the repository's dav directory. */
- char *dav_path;
-
   /* The path to the repository's conf directory. */
   char *conf_path;
 

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org
Received on Sat Apr 28 02:40:00 2007

This is an archived mail posted to the Subversion Dev mailing list.

This site is subject to the Apache Privacy Policy and the Apache Public Forum Archive Policy.