Author: stsp
Date: Mon Nov 13 22:52:27 2017
New Revision: 1815147

URL: http://svn.apache.org/viewvc?rev=1815147&view=rev
Log:
On the addremove branch, reduce the scope of move match-making.

The original 'hg addremove' does not match arbitrary paths, but only
matches up the missing and unversioned path which get added/removed.

I feel that matching up arbitrary deleted/added nodes in the working
copy which were not missing/unversioned when 'addremove' was started
is a bit risky for an initial implementation.

At the API level, merge the functionality of the new API function
svn_client_match_up_local_deletes_and_adds() back into the new API
function svn_client_addremove().

* subversion/include/svn_client.h
  (svn_client_match_up_local_deletes_and_adds): Remove declaration.

* subversion/libsvn_client/addremove.c
  (addremove_status_baton): Remove 'added' and 'deleted' node status lists.
  (addremove_status_func): Ignore added and deleted nodes.
  (suggest_file_moves): Align a comment with our reduced implementation goal.
  (match_up_new_deletes_and_adds): Move up in the file and rename from ...
  (match_up_local_deletes_and_adds): ... this.
  (addremove): Track removed status baton fields. After adding/deleting
   nodes, run match_up_new_deletes_and_adds on the same list of nodes
   as we just processed.
  (svn_client_match_up_local_deletes_and_adds): Remove. No longer needed.

* subversion/svn/addremove-cmd.c
  (svn_cl__addremove): Remove svn_client_match_up_local_deletes_and_adds() call.

Modified:
    subversion/branches/addremove/subversion/include/svn_client.h
    subversion/branches/addremove/subversion/libsvn_client/addremove.c
    subversion/branches/addremove/subversion/svn/addremove-cmd.c

Modified: subversion/branches/addremove/subversion/include/svn_client.h
URL: 
http://svn.apache.org/viewvc/subversion/branches/addremove/subversion/include/svn_client.h?rev=1815147&r1=1815146&r2=1815147&view=diff
==============================================================================
--- subversion/branches/addremove/subversion/include/svn_client.h (original)
+++ subversion/branches/addremove/subversion/include/svn_client.h Mon Nov 13 
22:52:27 2017
@@ -1679,6 +1679,9 @@ svn_client_add(const char *path,
  * nodes found into added status, and put any missing nodes found into deleted
  * status.
  *
+ * Also, attempt to match up missing nodes with unversioned nodes.
+ * Any matches will be recorded as a move in the working copy.
+ *
  * The level of recursion is specified by @a depth.
  *
  * @since New in 1.10.
@@ -1691,20 +1694,6 @@ svn_client_addremove(const char *local_p
                      svn_client_ctx_t *ctx,
                      apr_pool_t *scratch_pool);
 
-/**
- * Recurse into the versioned directory @a local_path, and attempt to match
- * up versioned deleted nodes with versioned added (or copied) nodes.
- * Any matches found will be transformed into a move.
- *
- * The level of recursion is specified by @a depth.
- *
- * @since New in 1.10.
- */
-svn_error_t *
-svn_client_match_up_local_deletes_and_adds(const char *local_path,
-                                           svn_depth_t depth,
-                                           svn_client_ctx_t *ctx,
-                                           apr_pool_t *scratch_pool);
 /** @} */
 
 /**

Modified: subversion/branches/addremove/subversion/libsvn_client/addremove.c
URL: 
http://svn.apache.org/viewvc/subversion/branches/addremove/subversion/libsvn_client/addremove.c?rev=1815147&r1=1815146&r2=1815147&view=diff
==============================================================================
--- subversion/branches/addremove/subversion/libsvn_client/addremove.c 
(original)
+++ subversion/branches/addremove/subversion/libsvn_client/addremove.c Mon Nov 
13 22:52:27 2017
@@ -53,12 +53,6 @@ struct addremove_status_baton {
 
   /* Status info for unversioned paths. */
   apr_hash_t *unversioned;
-
-  /* Status info for added paths. */
-  apr_hash_t *added;
-
-  /* Status info for deleted paths. */
-  apr_hash_t *deleted;
 };
 
 /* Implements svn_wc_status_func4_t. */
@@ -80,14 +74,6 @@ addremove_status_func(void *baton, const
         hash = b->missing;
         break;
 
-      case svn_wc_status_added:
-        hash = b->added;
-        break;
-
-      case svn_wc_status_deleted:
-        hash = b->deleted;
-        break;
-
       default:
         break;
     }
@@ -129,8 +115,9 @@ suggest_file_moves(apr_hash_t **moves,
 
       svn_pool_clear(iterpool);
 
+      /* Skip files which were already versioned before addremove. */
       if (svn_hash_gets(deleted, similar_abspath) == NULL)
-        continue; /* ### TODO treat as a copy? */
+        continue;
 
       move_targets = svn_hash_gets(*moves, similar_abspath);
       if (move_targets == NULL)
@@ -346,6 +333,49 @@ suggest_moves(apr_hash_t **moves,
 }
 
 static svn_error_t *
+match_up_new_deletes_and_adds(const char *local_abspath,
+                              apr_hash_t *deleted,
+                              apr_hash_t *added,
+                              svn_depth_t depth,
+                              svn_client_ctx_t *ctx,
+                              apr_pool_t *scratch_pool)
+{
+  apr_hash_t *moves;
+  apr_hash_index_t *hi;
+  apr_pool_t *iterpool;
+
+  SVN_ERR(suggest_moves(&moves, deleted, added,
+                        ctx, scratch_pool, scratch_pool));
+
+  iterpool = svn_pool_create(scratch_pool);
+  for (hi = apr_hash_first(scratch_pool, moves); hi;
+       hi = apr_hash_next(hi))
+    {
+      const char *src_abspath = apr_hash_this_key(hi);
+      apr_array_header_t *move_targets = apr_hash_this_val(hi);
+      svn_boolean_t is_ambiguous_move = (move_targets->nelts > 1);
+      int i;
+
+      svn_pool_clear(iterpool);
+
+      for (i = 0; i < move_targets->nelts; i++) 
+        {
+          const char *dst_abspath = APR_ARRAY_IDX(move_targets, i,
+                                                  const char *);
+          SVN_ERR(svn_wc__fixup_copyfrom(ctx->wc_ctx, src_abspath, dst_abspath,
+                                         !is_ambiguous_move, /* is_move */
+                                         ctx->cancel_func, ctx->cancel_baton,
+                                         ctx->notify_func2, ctx->notify_baton2,
+                                         iterpool));
+        }
+    }
+  svn_pool_destroy(iterpool);
+
+  return SVN_NO_ERROR;
+}
+
+
+static svn_error_t *
 addremove(const char *local_abspath, svn_depth_t depth,
           svn_boolean_t no_autoprops, svn_boolean_t no_ignore,
           svn_client_ctx_t *ctx, apr_pool_t *scratch_pool)
@@ -359,8 +389,6 @@ addremove(const char *local_abspath, svn
 
   b.missing = apr_hash_make(scratch_pool);
   b.unversioned = apr_hash_make(scratch_pool);
-  b.added = NULL;
-  b.deleted = NULL;
 
   SVN_ERR(svn_wc_walk_status(ctx->wc_ctx, local_abspath, depth,
                              TRUE, FALSE, FALSE, NULL,
@@ -423,6 +451,10 @@ addremove(const char *local_abspath, svn
     }
   svn_pool_destroy(iterpool);
 
+  SVN_ERR(match_up_new_deletes_and_adds(local_abspath,
+                                        b.missing, b.unversioned,
+                                        depth, ctx, scratch_pool));
+
   return SVN_NO_ERROR;
 }
 
@@ -444,73 +476,3 @@ svn_client_addremove(const char *local_p
 
   return SVN_NO_ERROR;
 }
-
-static svn_error_t *
-match_up_local_deletes_and_adds(const char *local_abspath,
-                                svn_depth_t depth,
-                                svn_client_ctx_t *ctx,
-                                apr_pool_t *scratch_pool)
-{
-  struct addremove_status_baton b;
-  apr_hash_t *moves;
-  apr_hash_index_t *hi;
-  apr_pool_t *iterpool;
-
-  b.missing = NULL;
-  b.unversioned = NULL;
-  b.added = apr_hash_make(scratch_pool);
-  b.deleted = apr_hash_make(scratch_pool);
-
-  SVN_ERR(svn_wc_walk_status(ctx->wc_ctx, local_abspath, depth,
-                             TRUE, FALSE, FALSE, NULL,
-                             addremove_status_func, &b,
-                             ctx->cancel_func, ctx->cancel_baton,
-                             scratch_pool));
-
-  SVN_ERR(suggest_moves(&moves, b.deleted, b.added,
-                        ctx, scratch_pool, scratch_pool));
-
-  iterpool = svn_pool_create(scratch_pool);
-  for (hi = apr_hash_first(scratch_pool, moves); hi;
-       hi = apr_hash_next(hi))
-    {
-      const char *src_abspath = apr_hash_this_key(hi);
-      apr_array_header_t *move_targets = apr_hash_this_val(hi);
-      svn_boolean_t is_ambiguous_move = (move_targets->nelts > 1);
-      int i;
-
-      svn_pool_clear(iterpool);
-
-      for (i = 0; i < move_targets->nelts; i++) 
-        {
-          const char *dst_abspath = APR_ARRAY_IDX(move_targets, i,
-                                                  const char *);
-          SVN_ERR(svn_wc__fixup_copyfrom(ctx->wc_ctx, src_abspath, dst_abspath,
-                                         !is_ambiguous_move, /* is_move */
-                                         ctx->cancel_func, ctx->cancel_baton,
-                                         ctx->notify_func2, ctx->notify_baton2,
-                                         iterpool));
-        }
-    }
-  svn_pool_destroy(iterpool);
-
-  return SVN_NO_ERROR;
-}
-
-svn_error_t *
-svn_client_match_up_local_deletes_and_adds(const char *local_path,
-                                           svn_depth_t depth,
-                                           svn_client_ctx_t *ctx,
-                                           apr_pool_t *scratch_pool)
-{
-  const char *local_abspath;
-
-  SVN_ERR(svn_dirent_get_absolute(&local_abspath, local_path, scratch_pool));
-
-  SVN_WC__CALL_WITH_WRITE_LOCK(
-    match_up_local_deletes_and_adds(local_abspath, depth, ctx, scratch_pool),
-    ctx->wc_ctx, local_abspath, TRUE, scratch_pool);
-
-  return SVN_NO_ERROR;
-}
-

Modified: subversion/branches/addremove/subversion/svn/addremove-cmd.c
URL: 
http://svn.apache.org/viewvc/subversion/branches/addremove/subversion/svn/addremove-cmd.c?rev=1815147&r1=1815146&r2=1815147&view=diff
==============================================================================
--- subversion/branches/addremove/subversion/svn/addremove-cmd.c (original)
+++ subversion/branches/addremove/subversion/svn/addremove-cmd.c Mon Nov 13 
22:52:27 2017
@@ -104,28 +104,6 @@ svn_cl__addremove(apr_getopt_t *os,
                SVN_ERR_WC_PATH_NOT_FOUND,
                0));
     }
-
-  if (errors->nelts > 0)
-    {
-      svn_error_t *err = wrap_illegal_target_error(errors);
-      svn_handle_warning2(stderr, err, "svn: ");
-    }
-
-  /* Now ask for magic to be performed which will detect moves. */
-  for (i = 0; i < targets->nelts; i++)
-    {
-      const char *target = APR_ARRAY_IDX(targets, i, const char *);
-
-      svn_pool_clear(iterpool);
-      SVN_ERR(svn_cl__check_cancel(ctx->cancel_baton));
-      SVN_ERR(svn_cl__try(svn_client_match_up_local_deletes_and_adds(
-                            target, opt_state->depth,
-                            ctx, iterpool),
-               errors, opt_state->quiet,
-               SVN_ERR_ENTRY_EXISTS,
-               SVN_ERR_WC_PATH_NOT_FOUND,
-               0));
-    }
   svn_pool_destroy(iterpool);
 
   if (errors->nelts > 0)


Reply via email to