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

[PATCH] Accept --force for switch --relocate was Re: Possible SVN Relocate bug

From: Justin Erenkrantz <justin_at_erenkrantz.com>
Date: 2007-03-14 08:49:47 CET

On 3/13/07, Scott Hendrickson <sahendrickson@gmail.com> wrote:
> I don't see a --force option for switch, and it won't accept the
> command. Maybe that would be a good feature, though :-)

It does accept it in trunk though, but it doesn't do anything for relocate.

The patch below should do the trick here. The only subjective point
is whether we think it's kosher to accept a NULL baton in
svn_wc_relocate2 - or whether we should still call the function and
have validator_func always return TRUE for the check if we were asked
to --force it. I think it tends to be a bikeshed - so I went behind
Door #1. *shrug*

If no one has any objections/comments in a reasonable amount of time,
I'll commit it.

BTW, the current help message for 'svn switch' is way way too verbose
for --force, but I'm not going to editorialize that now. No human
being could ever make sense of the current help message, IMHO.

Thanks! -- justin

--
Allow switch --relocate to accept --force to allow unreadable roots/UUIDs to
be switched.
* subversion/include/svn_client.h
  (svn_client_relocate2): Rev API to accept a skip UUID check parameter.
  (svn_client_relocate): Deprecated wrapper.
* subversion/libsvn_wc/relocate.c
  (relocate_entry): Allow the validator function to be NULL.
* subversion/libsvn_client/relocate.c
  (svn_client_relocate2): Rev API to accept a skip UUID check parameter.
  (svn_client_relocate): Deprecated wrapper.
* subversion/svn/switch-cmd.c
  (rewrite_urls): Take a bool argument for skipping the UUID check; call
  rev'd API.
  (svn_cl__switch): Pass the state of ->force to rewrite_urls.
* subversion/svn/main.c
  (svn_cl__cmd_table): Hint at what --force does for --relocate.
Index: subversion/include/svn_client.h
===================================================================
--- subversion/include/svn_client.h	(revision 23808)
+++ subversion/include/svn_client.h	(working copy)
@@ -2179,10 +2179,26 @@
  * @param from Original URL
  * @param to New URL
  * @param recurse Whether to recurse
+ * @param skip_uuid_check Whether to skip the UUID comparison check.
  * @param ctx svn_client_ctx_t
  * @param pool The pool from which to perform memory allocations
  */
 svn_error_t *
+svn_client_relocate2(const char *dir,
+                     const char *from,
+                     const char *to,
+                     svn_boolean_t recurse,
+                     svn_boolean_t skip_uuid_check,
+                     svn_client_ctx_t *ctx,
+                     apr_pool_t *pool);
+
+/**
+ * Similar to svn_client_relocate2() but with @a skip_uuid_check
+ * always set to false.
+ *
+ * @deprecated Provided for backward compatibility with the 1.4 API.
+ */
+svn_error_t *
 svn_client_relocate(const char *dir,
                     const char *from,
                     const char *to,
Index: subversion/libsvn_wc/relocate.c
===================================================================
--- subversion/libsvn_wc/relocate.c	(revision 23808)
+++ subversion/libsvn_wc/relocate.c	(working copy)
@@ -79,15 +79,16 @@
           entry2.repos = apr_pstrcat(pool, to, entry->repos + from_len, NULL);
           flags |= SVN_WC__ENTRY_MODIFY_REPOS;
           /* Make sure to is really the repository root. */
-          SVN_ERR(validator(validator_baton, entry->uuid, entry2.repos,
-                            TRUE, pool));
+          if (validator)
+            SVN_ERR(validator(validator_baton, entry->uuid, entry2.repos,
+                              TRUE, pool));
         }
     }
   if (entry->url && ! strncmp(entry->url, from, from_len))
     {
       entry2.url = apr_pstrcat(pool, to, entry->url + from_len, NULL);
-      if (entry->uuid)
+      if (entry->uuid && validator)
         SVN_ERR(validator(validator_baton, entry->uuid, entry2.url, FALSE,
                           pool));
       flags |= SVN_WC__ENTRY_MODIFY_URL;
@@ -97,7 +98,7 @@
     {
       entry2.copyfrom_url = apr_pstrcat(pool, to,
                                         entry->copyfrom_url + from_len, NULL);
-      if (entry->uuid)
+      if (entry->uuid && validator)
         SVN_ERR(validator(validator_baton, entry->uuid,
                           entry2.copyfrom_url, FALSE, pool));
       flags |= SVN_WC__ENTRY_MODIFY_COPYFROM_URL;
Index: subversion/libsvn_client/relocate.c
===================================================================
--- subversion/libsvn_client/relocate.c	(revision 23808)
+++ subversion/libsvn_client/relocate.c	(working copy)
@@ -112,15 +112,17 @@
 }
 svn_error_t *
-svn_client_relocate(const char *path,
-                    const char *from,
-                    const char *to,
-                    svn_boolean_t recurse,
-                    svn_client_ctx_t *ctx,
-                    apr_pool_t *pool)
+svn_client_relocate2(const char *path,
+                     const char *from,
+                     const char *to,
+                     svn_boolean_t recurse,
+                     svn_boolean_t skip_uuid_check,
+                     svn_client_ctx_t *ctx,
+                     apr_pool_t *pool)
 {
   svn_wc_adm_access_t *adm_access;
   struct validator_baton_t vb;
+  svn_wc_relocation_validator2_t vf;
   /* Get an access baton for PATH. */
   SVN_ERR(svn_wc_adm_probe_open3(&adm_access, NULL, path,
@@ -129,14 +131,35 @@
                                  pool));
   /* Now, populate our validator callback baton, and call the relocate code. */
-  vb.ctx = ctx;
-  vb.path = path;
-  vb.url_uuids = apr_array_make(pool, 1, sizeof(struct url_uuid_t));
-  vb.pool = pool;
+  if (skip_uuid_check == FALSE)
+    {
+      vb.ctx = ctx;
+      vb.path = path;
+      vb.url_uuids = apr_array_make(pool, 1, sizeof(struct url_uuid_t));
+      vb.pool = pool;
+
+      vf = validator_func;
+    }
+  else
+    {
+      vf = NULL;
+    }
+
   SVN_ERR(svn_wc_relocate2(path, adm_access, from, to,
-                           recurse, validator_func, &vb, pool));
+                           recurse, vf, &vb, pool));
   /* All done.  Clean up, and move on out. */
   SVN_ERR(svn_wc_adm_close(adm_access));
   return SVN_NO_ERROR;
 }
+
+svn_error_t *
+svn_client_relocate(const char *path,
+                    const char *from,
+                    const char *to,
+                    svn_boolean_t recurse,
+                    svn_client_ctx_t *ctx,
+                    apr_pool_t *pool)
+{
+  return svn_client_relocate2(path, from, to, recurse, FALSE, ctx, pool);
+}
Index: subversion/svn/switch-cmd.c
===================================================================
--- subversion/svn/switch-cmd.c	(revision 23808)
+++ subversion/svn/switch-cmd.c	(working copy)
@@ -36,6 +36,7 @@
 static svn_error_t *
 rewrite_urls(apr_array_header_t *targets,
              svn_boolean_t recurse,
+             svn_boolean_t force,
              svn_client_ctx_t *ctx,
              apr_pool_t *pool)
 {
@@ -61,7 +62,7 @@
   if (targets->nelts == 2)
     {
-      SVN_ERR(svn_client_relocate("", from, to, recurse, ctx, pool));
+      SVN_ERR(svn_client_relocate2("", from, to, recurse, force, ctx, pool));
     }
   else
     {
@@ -69,8 +70,8 @@
         {
           const char *target = APR_ARRAY_IDX(targets, i, const char *);
           svn_pool_clear(subpool);
-          SVN_ERR(svn_client_relocate(target, from, to, recurse,
-                                      ctx, subpool));
+          SVN_ERR(svn_client_relocate2(target, from, to, recurse, force,
+                                       ctx, subpool));
         }
     }
@@ -101,7 +102,8 @@
   /* handle only-rewrite case specially */
   if (opt_state->relocate)
-    return rewrite_urls(targets, !opt_state->nonrecursive, ctx, pool);
+    return rewrite_urls(targets, !opt_state->nonrecursive, opt_state->force,
+                        ctx, pool);
   if (targets->nelts < 1)
     return svn_error_create(SVN_ERR_CL_INSUFFICIENT_ARGS, 0, NULL);
Index: subversion/svn/main.c
===================================================================
--- subversion/svn/main.c	(revision 23808)
+++ subversion/svn/main.c	(working copy)
@@ -769,16 +769,20 @@
      "     or hostname change) but your working copy still reflects the same\n"
      "     directory within the same repository.\n"
      "\n"
-     "  If --force is used, unversioned obstructing paths in the working\n"
-     "  copy do not automatically cause a failure if the switch attempts to\n"
-     "  add the same path.  If the obstructing path is the same type (file\n"
-     "  or directory) as the corresponding path in the repository it becomes\n"
-     "  versioned but its contents are left 'as-is' in the working copy.\n"
-     "  This means that an obstructing directory's unversioned children may\n"
-     "  also obstruct and become versioned.  For files, any content
differences\n"
-     "  between the obstruction and the repository are treated like a local\n"
-     "  modification to the working copy.  All properties from the
repository\n"
-     "  are applied to the obstructing path.\n"),
+     "  If --force is used:\n"
+     "\n"
+     "  1. Unversioned obstructing paths in the working copy do not\n"
+     "     automatically cause a failure if the switch attempts to add\n"
+     "     the same path.  If the obstructing path is the same type (file or\n"
+     "     directory) as the corresponding path in the repository it becomes\n"
+     "     versioned but its contents are left 'as-is' in the working copy.\n"
+     "     This means that an obstructing directory's unversioned children\n"
+     "     may also obstruct and become versioned.  For files, any content\n"
+     "     differences between the obstruction and the repository are
treated\n"
+     "     like a local modification to the working copy.  All properties\n"
+     "     from the repository are applied to the obstructing path.\n"
+     "\n"
+     "  2. No checks for UUID validity will be made.\n"),
     { 'r', 'N', 'q', svn_cl__merge_cmd_opt, svn_cl__relocate_opt,
       SVN_CL__AUTH_OPTIONS, svn_cl__config_dir_opt, svn_cl__force_opt} },
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org
Received on Wed Mar 14 08:50:01 2007

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