Trying to remove more uses of svn_wc_entry_t, it seems there is no way at the moment to get the equivalent of entry->copied using node routines. Is this the sort of thing that is needed?

[[[
wc-ng: work towards eliminating svn_wc_entry_t

* libsvn_wc/node.c, include/private/svn_wc_private.h
    Add svn_wc__node_is_status_copied()

* subversion/libsvn_client/copy.c
    (calculate_target_mergeinfo): Remove unused 'no_repos_access'
      parameter, replace use of svn_wc__get_entry with node routines.

Patch by: Matthew Bentham <mjb67{_AT_}artvps.com>
]]]
Index: subversion/include/private/svn_wc_private.h
===================================================================
--- subversion/include/private/svn_wc_private.h (revision 916192)
+++ subversion/include/private/svn_wc_private.h (working copy)
@@ -492,6 +492,19 @@
                              apr_pool_t *scratch_pool);
 
 /**
+ * Set @a *is_added to whether @a local_abspath is copied, using
+ * @a wc_ctx.  If @a local_abspath is not in the working copy, return
+ * @c SVN_ERR_WC_PATH_NOT_FOUND.  Use @a scratch_pool for all temporary
+ * allocations.
+ */
+svn_error_t *
+svn_wc__node_is_status_copied(svn_boolean_t *is_copied,
+                             svn_wc_context_t *wc_ctx,
+                             const char *local_abspath,
+                             apr_pool_t *scratch_pool);
+
+
+/**
  * Get the base revision of @a local_abspath using @a wc_ctx.  If
  * @a local_abspath is not in the working copy, return
  * @c SVN_ERR_WC_PATH_NOT_FOUND.
Index: subversion/libsvn_client/copy.c
===================================================================
--- subversion/libsvn_client/copy.c     (revision 916192)
+++ subversion/libsvn_client/copy.c     (working copy)
@@ -71,20 +71,16 @@
 /* Obtain the implied mergeinfo and the existing mergeinfo of the
    source path, combine them and return the result in
    *TARGET_MERGEINFO.  ADM_ACCESS may be NULL, if SRC_PATH_OR_URL is an
-   URL.  If NO_REPOS_ACCESS is set, this function is disallowed from
-   consulting the repository about anything.  RA_SESSION may be NULL but
-   only if NO_REPOS_ACCESS is true.  */
+   URL.  RA_SESSION may be NULL. */
 static svn_error_t *
 calculate_target_mergeinfo(svn_ra_session_t *ra_session,
                            apr_hash_t **target_mergeinfo,
                            svn_wc_adm_access_t *adm_access,
                            const char *src_path_or_url,
                            svn_revnum_t src_revnum,
-                           svn_boolean_t no_repos_access,
                            svn_client_ctx_t *ctx,
                            apr_pool_t *pool)
 {
-  const svn_wc_entry_t *entry = NULL;
   svn_boolean_t locally_added = FALSE;
   const char *src_url;
   apr_hash_t *src_mergeinfo = NULL;
@@ -94,13 +90,15 @@
      bother checking. */
   if (adm_access)
     {
+      svn_boolean_t added, copied;
       const char *local_abspath;
 
       SVN_ERR(svn_dirent_get_absolute(&local_abspath, src_path_or_url, pool));
-      SVN_ERR(svn_wc__get_entry_versioned(&entry, ctx->wc_ctx, local_abspath,
-                                          svn_node_unknown, FALSE, FALSE,
-                                          pool, pool));
-      if (entry->schedule == svn_wc_schedule_add && (! entry->copied))
+      SVN_ERR(svn_wc__node_is_status_added(&added, ctx->wc_ctx,
+                                           local_abspath, pool));
+      SVN_ERR(svn_wc__node_is_status_copied(&copied, ctx->wc_ctx,
+                                           local_abspath, pool));
+      if (added && !copied)
         {
           locally_added = TRUE;
         }
@@ -119,38 +117,24 @@
 
   if (! locally_added)
     {
-      if (! no_repos_access)
-        {
-          /* Fetch any existing (explicit) mergeinfo.  We'll temporarily
-             reparent to the target URL here, just to keep the code simple.
-             We could, as an alternative, first see if the target URL was a
-             child of the session URL and use the relative "remainder", 
-             falling back to this reparenting as necessary.  */
-          const char *old_session_url = NULL;
-          SVN_ERR(svn_client__ensure_ra_session_url(&old_session_url,
-                                                    ra_session, src_url, 
pool));
-          SVN_ERR(svn_client__get_repos_mergeinfo(ra_session, &src_mergeinfo,
-                                                  "", src_revnum,
-                                                  svn_mergeinfo_inherited,
-                                                  TRUE, pool));
-          if (old_session_url)
-            SVN_ERR(svn_ra_reparent(ra_session, old_session_url, pool));
-        }
-      else
-        {
-          svn_boolean_t inherited;
-          const char *local_abspath;
-
-          SVN_ERR(svn_dirent_get_absolute(&local_abspath, src_path_or_url,
-                                          pool));
-          SVN_ERR(svn_client__get_wc_mergeinfo(&src_mergeinfo, &inherited,
-                                               svn_mergeinfo_inherited,
-                                               local_abspath, NULL,
-                                               NULL, ctx, pool, pool));
-        }
+      /* Fetch any existing (explicit) mergeinfo.  We'll temporarily
+         reparent to the target URL here, just to keep the code simple.
+         We could, as an alternative, first see if the target URL was a
+         child of the session URL and use the relative "remainder", 
+         falling back to this reparenting as necessary.  */
+      const char *old_session_url = NULL;
+      SVN_ERR(svn_client__ensure_ra_session_url(&old_session_url,
+                                                ra_session, src_url, pool));
+      SVN_ERR(svn_client__get_repos_mergeinfo(ra_session, &src_mergeinfo,
+                                              "", src_revnum,
+                                              svn_mergeinfo_inherited,
+                                              TRUE, pool));
+      if (old_session_url)
+        SVN_ERR(svn_ra_reparent(ra_session, old_session_url, pool));
     }
 
   *target_mergeinfo = src_mergeinfo;
+  
   return SVN_NO_ERROR;
 }
 
@@ -818,7 +802,7 @@
       SVN_ERR(svn_client__ensure_ra_session_url(&ignored_url, ra_session,
                                                 pair->src, pool));
       SVN_ERR(calculate_target_mergeinfo(ra_session, &mergeinfo, NULL, 
pair->src,
-                                         pair->src_revnum, FALSE, ctx, pool));
+                                         pair->src_revnum, ctx, pool));
       if (mergeinfo)
         SVN_ERR(svn_mergeinfo_to_string(&info->mergeinfo, mergeinfo, pool));
 
@@ -1369,7 +1353,7 @@
                                                    sizeof(svn_prop_t *));
       SVN_ERR(calculate_target_mergeinfo(ra_session, &mergeinfo, adm_access,
                                          pair->src, pair->src_revnum,
-                                         FALSE, ctx, iterpool));
+                                         ctx, iterpool));
       SVN_ERR(svn_wc__get_entry_versioned(&entry, ctx->wc_ctx, pair->src_abs,
                                           svn_node_unknown, FALSE, FALSE,
                                           pool, pool));
@@ -1506,7 +1490,7 @@
              ### source path. */
           SVN_ERR(calculate_target_mergeinfo(ra_session, &src_mergeinfo, NULL,
                                              pair->src, src_revnum,
-                                             FALSE, ctx, pool));
+                                             ctx, pool));
           SVN_ERR(extend_wc_mergeinfo(dst_abspath, src_mergeinfo, ctx, pool));
         }
       else  /* different repositories */
@@ -1564,7 +1548,7 @@
 
       SVN_ERR(calculate_target_mergeinfo(ra_session, &src_mergeinfo,
                                          NULL, pair->src, src_revnum,
-                                         FALSE, ctx, pool));
+                                         ctx, pool));
       SVN_ERR(extend_wc_mergeinfo(dst_abspath, src_mergeinfo, ctx, pool));
 
       /* Ideally, svn_wc_add_repos_file3() would take a notify function
Index: subversion/libsvn_wc/node.c
===================================================================
--- subversion/libsvn_wc/node.c (revision 916192)
+++ subversion/libsvn_wc/node.c (working copy)
@@ -590,6 +590,34 @@
 }
 
 svn_error_t *
+svn_wc__node_is_status_copied(svn_boolean_t *is_copied,
+                              svn_wc_context_t *wc_ctx,
+                              const char *local_abspath,
+                              apr_pool_t *scratch_pool)
+{
+  svn_wc__db_status_t status;
+  svn_boolean_t added;
+
+  SVN_ERR(svn_wc__node_is_status_added(&added, wc_ctx, local_abspath,
+                                scratch_pool));
+  if (!added)
+    {
+      *is_copied = FALSE;
+      return SVN_NO_ERROR;
+    }
+
+  SVN_ERR(svn_wc__db_scan_addition(&status, 
+                                NULL, NULL, NULL, NULL,
+                                NULL, NULL, NULL, NULL,
+                                wc_ctx->db, local_abspath,
+                                scratch_pool, scratch_pool));
+  *is_copied = (status == svn_wc__db_status_copied);
+
+  return SVN_NO_ERROR;
+}
+
+
+svn_error_t *
 svn_wc__node_get_base_rev(svn_revnum_t *base_revision,
                           svn_wc_context_t *wc_ctx,
                           const char *local_abspath,

Reply via email to