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

[PATCH] Add repository UUIDs (fixes issue 1037)

From: mark benedetto king <bking_at_answerfriend.com>
Date: 2002-12-15 16:12:02 CET

This patch stores a UUID in the "svn:uuid" revprop on revision 0
Because the UUID should be immutable, an error is returned from
calls to svn_repos_fs_change_rev_prop for this property.

This enhancement was requested in issue 1037.

* subversion/include/svn_props.h
  Add a new #define, SVN_PROP_REVISION_UUID.

* subversion/libsvn_repos/hooks.c
  (svn_repos_fs_change_rev_prop): Return an error if the property
    is SVN_PROP_REVISION_UUID.

* subversion/libsvn_repo/repos.c
  #include apr_uuid.h for apr_uuid_*
  (set_repos_uuid): new static function
  (svn_repos_create): call set_repos_uuid

Index: subversion/include/svn_props.h
===================================================================
--- subversion/include/svn_props.h (revision 4130)
+++ subversion/include/svn_props.h (working copy)
@@ -200,6 +200,8 @@
 /* The fs revision property that stores a commit's date. */
 #define SVN_PROP_REVISION_DATE SVN_PROP_PREFIX "date"
 
+/* The fs revision property that stores a repository's unique id. */
+#define SVN_PROP_REVISION_UUID SVN_PROP_PREFIX "uuid"
 
 
 
Index: subversion/libsvn_repos/hooks.c
===================================================================
--- subversion/libsvn_repos/hooks.c (revision 4130)
+++ subversion/libsvn_repos/hooks.c (working copy)
@@ -314,6 +314,11 @@
 {
   svn_fs_t *fs = repos->fs;
 
+ if (! strcmp(name, SVN_PROP_REVISION_UUID))
+ return svn_error_create
+ (SVN_ERR_REPOS_DISABLED_FEATURE, 0, NULL,
+ "The repository UUID cannot be changed.\n");
+
   /* Run pre-revprop-change hook */
   SVN_ERR (run_pre_revprop_change_hook (repos, rev, author, name,
                                         value, pool));
Index: subversion/libsvn_repos/repos.c
===================================================================
--- subversion/libsvn_repos/repos.c (revision 4130)
+++ subversion/libsvn_repos/repos.c (working copy)
@@ -17,6 +17,7 @@
 
 #include <apr_pools.h>
 #include <apr_file_io.h>
+#include <apr_uuid.h>
 
 #include "svn_pools.h"
 #include "svn_error.h"
@@ -679,6 +680,27 @@
 }
 
 
+/* Generate a "universally unique id" (UUID) and associate
+ it with the SVN_PROP_REVISION_UUID property of revision 0
+ in REPOS, using POOL for all allocation */
+static svn_error_t *
+set_repos_uuid (svn_repos_t *repos, apr_pool_t *pool)
+{
+ apr_uuid_t uuid;
+ char buffer[APR_UUID_FORMATTED_LENGTH+1];
+ svn_string_t string;
+
+ apr_uuid_get (&uuid);
+ apr_uuid_format (buffer, &uuid);
+
+ string.len = APR_UUID_FORMATTED_LENGTH;
+ string.data = buffer;
+
+ return svn_fs_change_rev_prop (repos->fs, 0, SVN_PROP_REVISION_UUID,
+ &string, pool);
+}
+
+
 svn_error_t *
 svn_repos_create (svn_repos_t **repos_p, const char *path, apr_pool_t *pool)
 {
@@ -770,6 +792,8 @@
            (svn_path_join (path, SVN_REPOS__FORMAT, pool),
             SVN_REPOS__VERSION, pool));
 
+ set_repos_uuid (repos, pool);
+
   *repos_p = repos;
   return SVN_NO_ERROR;
 }

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org
Received on Sun Dec 15 16:21:30 2002

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.