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

[PATCH] Need to bump repos format number for 1.4.0

From: Malcolm Rowe <malcolm-svn-dev_at_farside.org.uk>
Date: 2006-08-21 18:17:16 CEST

On Tue, Aug 15, 2006 at 03:35:28PM +0100, Max Bowsher wrote:
> We need to bump the repos format number for 1.4.
>
> This is because of the svndiff1 stuff. The svndiff1 change is signalled
> by an increase of the *fs* format number from 1 to 2.
>
> However, fs format numbers were not introduced until Subversion 1.2,
> thus the possibility that 1.0 or 1.1 could naively act on a svndiff1
> repository.
>
> I brought the issue up with DannyB on IRC, and he was pretty confident
> that operations would fail (somewhat) cleanly because of the specifics
> of the svndiff0 to svndiff1 change, but I feel queasy on relying on
> particulars of the change to guard against problems.
>
> Therefore, I think we need to:
> * have 1.4 libsvn_repos create new repositories at format 4, except if
> --no-svndiff1 is specified, in which case format 3 is used.
>
> * have 1.4 libsvn_repos accept both format 3 and format 4 repositories.
>
>

How about something like the attached? (Warning: untested).

[[[
Conditionally bump the format number of newly-created repositories to 4,
depending on whether the created filesystem format number is greater than 1.

This prevents problems that might occur if a client that does not check
filesystem format numbers (a pre-1.2 client, for example) attempts to use
a repository containing a filesystem with format number > 1.

* subversion/libsvn_repos/repos.c
  (svn_repos_create): Read the filesystem format file back after creation
    and create a format 4 repository if the filesystem format is greater
    than 1, or a format 3 repository otherwise.
  (check_repos_format): Accept both format 3 and format 4 repositories.

* subversion/libsvn_repos/repos.h
  (SVN_REPOS__FORMAT_NUMBER): Bump default repository format number to 4,
    and explain the difference between formats 3 and 4.
]]]

I'm not overly-happy with the re-reading back the filesystem format
number because it hard-codes knowledge of the 'format' file's existence
and name in the filesystem, but I can't see a less-intrusive way (short
of adding a call to ask the filesystem what format it is, which seems
over the top).

Regards,
Malcolm

Index: subversion/libsvn_repos/repos.c
===================================================================
--- subversion/libsvn_repos/repos.c (revision 21106)
+++ subversion/libsvn_repos/repos.c (working copy)
@@ -1656,12 +1656,13 @@ svn_repos_create(svn_repos_t **repos_p,
                  apr_hash_t *config,
                  apr_hash_t *fs_config,
                  apr_pool_t *pool)
 {
   svn_repos_t *repos;
   svn_error_t *err;
+ int fs_format;
 
   /* Allocate a repository object, filling in the format we will create. */
   repos = create_svn_repos_t(path, pool);
   repos->format = SVN_REPOS__FORMAT_NUMBER;
 
   /* Discover the type of the filesystem we are about to create. */
@@ -1686,16 +1687,25 @@ svn_repos_create(svn_repos_t **repos_p,
        * create_repos_structure will fail if the path existed before we started
        * so we can't accidentally remove a directory that previously existed. */
       svn_error_clear(svn_io_remove_dir(path, pool));
       return err;
     }
 
+ /* If the filesystem format number is "1", we can safely downgrade the
+ * repository to a format 3 repository, since we do not require that users
+ * of this repository check the filesystem format number. */
+ SVN_ERR(svn_io_read_version_file(&fs_format,
+ svn_path_join(repos->db_path, "format", pool), pool));
+
+ if (fs_format <= 1)
+ repos->format = 3;
+
   /* This repository is ready. Stamp it with a format number. */
   SVN_ERR(svn_io_write_version_file
           (svn_path_join(path, SVN_REPOS__FORMAT, pool),
- SVN_REPOS__FORMAT_NUMBER, pool));
+ repos->format, pool));
 
   *repos_p = repos;
   return SVN_NO_ERROR;
 }
 
 
@@ -1746,13 +1756,16 @@ check_repos_format(svn_repos_t *repos,
   int format;
   const char *format_path;
 
   format_path = svn_path_join(repos->path, SVN_REPOS__FORMAT, pool);
   SVN_ERR(svn_io_read_version_file(&format, format_path, pool));
 
- if (format != SVN_REPOS__FORMAT_NUMBER)
+ /* We support both format 3 and format 4 repositories equally.
+ (The only difference is whether the caller is required to check the
+ filesystem format file, and we always do). */
+ if (format != 3 && format != SVN_REPOS__FORMAT_NUMBER)
     {
       return svn_error_createf
         (SVN_ERR_REPOS_UNSUPPORTED_VERSION, NULL,
          _("Expected format '%d' of repository; found format '%d'"),
          SVN_REPOS__FORMAT_NUMBER, format);
     }
Index: subversion/libsvn_repos/repos.h
===================================================================
--- subversion/libsvn_repos/repos.h (revision 21106)
+++ subversion/libsvn_repos/repos.h (working copy)
@@ -26,13 +26,23 @@
 #ifdef __cplusplus
 extern "C" {
 #endif /* __cplusplus */
 
 
 /*** Repository format number. */
-#define SVN_REPOS__FORMAT_NUMBER 3
+
+/* The difference between a format 3 and format 4 repository is that the
+ user of a format 4 repository must check that whether the filesystem
+ format number is supported, whereas a format 3 repository is not required
+ to contain a filesystem format number.
+
+ Since a user of a format 3 repository is not required to check the
+ filesystem format number, a repository format bump is needed for
+ repositories that contain filesystems with a format number greater
+ than 1. */
+#define SVN_REPOS__FORMAT_NUMBER 4
 
 
 /*** Repository layout. ***/
 
 /* The top-level repository dir contains a README and various
    subdirectories. */

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org
Received on Mon Aug 21 18:42:30 2006

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.