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

[PATCH 2389] Remove Berkeley DB specific wording from FSFS repositories.

From: Max Bowsher <maxb_at_ukf.net>
Date: 2005-09-27 16:23:35 CEST

I'm posting this here before committing it, in case anyone has suggestions
for different wording.

[[[
Remove all Berkeley DB specific wording from FSFS repositories.
Two components:
 (a) 'README.txt' - show the advice about 'db/DB_CONFIG' only for BDB.
 (b) 'locks/db.lock' and 'locks/db-logs.lock' - Use content stating that
these
     files are unused and exist only for pre-1.3 compatibility, for FSFS
     repositories.

* subversion/libsvn_repos/repos.c
  (bdb_lock_file_contents, bdb_logs_lock_file_contents): Text for files in
    repository 'locks/' directory moved to these variables, and line endings
    fixed from "\n" to APR_EOL_STR.
  (pre12_compat_unneeded_file_contents): New text placed in 'locks/db.lock'
    and 'locks/db-logs.lock' for FSFS repositories.
  (create_db_logs_lock, create_db_lock): Refer to previously mentioned
    variables.
  (create_repos_structure): Place BDB-specific information into 'README.txt'
    only if the contained filesystem really is BDB.
  (svn_repos_create): Initialize repos->fs_type earlier so that it is
    available to create_repos_structure().
]]]

Index: subversion/libsvn_repos/repos.c
===================================================================
--- subversion/libsvn_repos/repos.c (revision 16303)
+++ subversion/libsvn_repos/repos.c (working copy)
@@ -180,6 +180,48 @@
   return err;
 }

+static const char * bdb_lock_file_contents =
+ "DB lock file, representing locks on the versioned filesystem."
+ APR_EOL_STR
+ APR_EOL_STR
+ "All accessors -- both readers and writers -- of the repository's"
+ APR_EOL_STR
+ "Berkeley DB environment take out shared locks on this file, and"
+ APR_EOL_STR
+ "each accessor removes its lock when done. If and when the DB"
+ APR_EOL_STR
+ "recovery procedure is run, the recovery code takes out an"
+ APR_EOL_STR
+ "exclusive lock on this file, so we can be sure no one else is"
+ APR_EOL_STR
+ "using the DB during the recovery."
+ APR_EOL_STR
+ APR_EOL_STR
+ "You should never have to edit or remove this file."
+ APR_EOL_STR;
+
+static const char * bdb_logs_lock_file_contents =
+ "DB logs lock file, representing locks on the versioned filesystem logs."
+ APR_EOL_STR
+ APR_EOL_STR
+ "All log manipulators of the repository's"
+ APR_EOL_STR
+ "Berkeley DB environment take out exclusive locks on this file"
+ APR_EOL_STR
+ "to ensure that only one accessor manupulates the logs at the time."
+ APR_EOL_STR
+ APR_EOL_STR
+ "You should never have to edit or remove this file."
+ APR_EOL_STR;
+
+static const char * pre12_compat_unneeded_file_contents =
+ "This file is not used by Subversion 1.3.x or later."
+ APR_EOL_STR
+ "However, its existence is required for compatibility with"
+ APR_EOL_STR
+ "Subversion 1.2.x or earlier."
+ APR_EOL_STR;
+
 /* Create the DB logs lockfile. */
 static svn_error_t *
 create_db_logs_lock (svn_repos_t *repos, apr_pool_t *pool) {
@@ -187,14 +229,10 @@
   const char *lockfile_path;

   lockfile_path = svn_repos_db_logs_lockfile (repos, pool);
- contents =
- "DB logs lock file, representing locks on the versioned filesystem
logs.\n"
- "\n"
- "All log manipulators of the repository's\n"
- "Berkeley DB environment take out exclusive locks on this file\n"
- "to ensure that only one accessor manupulates the logs at the time.\n"
- "\n"
- "You should never have to edit or remove this file.\n";
+ if (strcmp (repos->fs_type, SVN_FS_TYPE_BDB) == 0)
+ contents = bdb_logs_lock_file_contents;
+ else
+ contents = pre12_compat_unneeded_file_contents;

   SVN_ERR_W (svn_io_file_create (lockfile_path, contents, pool),
              _("Creating db logs lock file"));
@@ -205,21 +243,14 @@
 /* Create the DB lockfile. */
 static svn_error_t *
 create_db_lock (svn_repos_t *repos, apr_pool_t *pool) {
- const char *contents;
- const char *lockfile_path;
+ const char *contents;
+ const char *lockfile_path;

- lockfile_path = svn_repos_db_lockfile (repos, pool);
- contents =
- "DB lock file, representing locks on the versioned filesystem.\n"
- "\n"
- "All accessors -- both readers and writers -- of the repository's\n"
- "Berkeley DB environment take out shared locks on this file, and\n"
- "each accessor removes its lock when done. If and when the DB\n"
- "recovery procedure is run, the recovery code takes out an\n"
- "exclusive lock on this file, so we can be sure no one else is\n"
- "using the DB during the recovery.\n"
- "\n"
- "You should never have to edit or remove this file.\n";
+ lockfile_path = svn_repos_db_lockfile (repos, pool);
+ if (strcmp (repos->fs_type, SVN_FS_TYPE_BDB) == 0)
+ contents = bdb_lock_file_contents;
+ else
+ contents = pre12_compat_unneeded_file_contents;

   SVN_ERR_W (svn_io_file_create (lockfile_path, contents, pool),
              _("Creating db lock file"));
@@ -1543,22 +1574,16 @@

   /* Write the top-level README file. */
   {
- const char *readme_file_name
- = svn_path_join (path, SVN_REPOS__README, pool);
- static const char * const readme_contents =
+ const char * const readme_header =
       "This is a Subversion repository; use the 'svnadmin' tool to examine"
       APR_EOL_STR
       "it. Do not add, delete, or modify files here unless you know how"
       APR_EOL_STR
       "to avoid corrupting the repository."
       APR_EOL_STR
- /* ### It would be preferable to conditionalize the mention of
- DB_CONFIG below, since it's pointless if this is an FSFS
- repository, but we don't currently have an clear API for
- determining the fs type. Hence, the conditional is in the
- English, not the code :-). */
- APR_EOL_STR
- "If the directory \""
+ APR_EOL_STR;
+ const char * const readme_bdb_insert =
+ "The directory \""
       SVN_REPOS__DB_DIR
       "\" contains a Berkeley DB environment,"
       APR_EOL_STR
@@ -1568,12 +1593,28 @@
       APR_EOL_STR
       "requirements of your site."
       APR_EOL_STR
- APR_EOL_STR
+ APR_EOL_STR;
+ const char * const readme_footer =
       "Visit http://subversion.tigris.org/ for more information."
       APR_EOL_STR;
+ apr_file_t *f;
+ apr_size_t written;

- SVN_ERR_W (svn_io_file_create (readme_file_name, readme_contents,
pool),
- _("Creating readme file"));
+ SVN_ERR (svn_io_file_open (&f,
+ svn_path_join (path, SVN_REPOS__README,
pool),
+ (APR_WRITE | APR_CREATE | APR_EXCL),
+ APR_OS_DEFAULT, pool));
+
+ SVN_ERR (svn_io_file_write_full (f, readme_header, strlen
(readme_header),
+ &written, pool));
+ if (strcmp (repos->fs_type, SVN_FS_TYPE_BDB) == 0)
+ SVN_ERR (svn_io_file_write_full (f, readme_bdb_insert,
+ strlen (readme_bdb_insert),
+ &written, pool));
+ SVN_ERR (svn_io_file_write_full (f, readme_footer, strlen
(readme_footer),
+ &written, pool));
+
+ SVN_ERR (svn_io_file_close (f, pool));
   }

   return SVN_NO_ERROR;
@@ -1623,16 +1664,16 @@
   repos = create_svn_repos_t (path, pool);
   repos->format = SVN_REPOS__FORMAT_NUMBER;

- /* Create the various files and subdirectories for the repository. */
- SVN_ERR_W (create_repos_structure (repos, path, pool),
- _("Repository creation failed"));
-
   /* Discover the type of the filesystem we are about to create. */
   repos->fs_type = apr_hash_get (fs_config, SVN_FS_CONFIG_FS_TYPE,
                                  APR_HASH_KEY_STRING);
   if (! repos->fs_type)
     repos->fs_type = DEFAULT_FS_TYPE;

+ /* Create the various files and subdirectories for the repository. */
+ SVN_ERR_W (create_repos_structure (repos, path, pool),
+ _("Repository creation failed"));
+
   /* Lock if needed. */
   SVN_ERR (lock_repos (repos, FALSE, FALSE, pool));

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org
Received on Tue Sep 27 16:24:41 2005

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.