Author: philip
Date: Thu Apr 22 18:59:01 2010
New Revision: 937010

URL: http://svn.apache.org/viewvc?rev=937010&view=rev
Log:
Move some code.

* subversion/libsvn_wc/copy.c
  (determine_copyfrom_info): Delete.
  (copy_file_administratively, copy_dir_administratively): Use
   svn_wc__node_get_copyfrom_info instead.

* subversion/include/private/svn_wc_private.h
  (svn_wc__node_get_copyfrom_info): Tweak docstring.

* subversion/libsvn_wc/node.c
  (svn_wc__node_get_copyfrom_info): Extend to handle all the cases
   covered by determine_copyfrom_info.

* subversion/libsvn_client/diff.c
  (convert_to_url): Return an error if no URL available.

Modified:
    subversion/trunk/subversion/include/private/svn_wc_private.h
    subversion/trunk/subversion/libsvn_client/diff.c
    subversion/trunk/subversion/libsvn_wc/copy.c
    subversion/trunk/subversion/libsvn_wc/node.c

Modified: subversion/trunk/subversion/include/private/svn_wc_private.h
URL: 
http://svn.apache.org/viewvc/subversion/trunk/subversion/include/private/svn_wc_private.h?rev=937010&r1=937009&r2=937010&view=diff
==============================================================================
--- subversion/trunk/subversion/include/private/svn_wc_private.h (original)
+++ subversion/trunk/subversion/include/private/svn_wc_private.h Thu Apr 22 
18:59:01 2010
@@ -363,9 +363,9 @@ svn_wc__node_get_url(const char **url,
 /**
  * Set @a *copyfrom_url to the corresponding copy-from URL, and @a
  * copyfrom_rev to the corresponding copy-from revision, of @a
- * local_abspath, using @a wc_ctx.  If @a local_abspath does not
- * represent the root of a copied subtree, set @a *copyfrom_rev to
- * NULL and @a copyfrom_rev to @c SVN_INVALID_REVNUM.
+ * local_abspath, using @a wc_ctx.  If @a local_abspath is not copied,
+ * set @a *copyfrom_rev to NULL and @a *copyfrom_rev to @c
+ * SVN_INVALID_REVNUM.
  */
 svn_error_t *
 svn_wc__node_get_copyfrom_info(const char **copyfrom_url,

Modified: subversion/trunk/subversion/libsvn_client/diff.c
URL: 
http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_client/diff.c?rev=937010&r1=937009&r2=937010&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_client/diff.c (original)
+++ subversion/trunk/subversion/libsvn_client/diff.c Thu Apr 22 18:59:01 2010
@@ -894,6 +894,11 @@ convert_to_url(const char **url,
       SVN_ERR(svn_wc__node_get_copyfrom_info(url, &copyfrom_rev,
                                              wc_ctx, abspath_or_url,
                                              result_pool, scratch_pool));
+      if (! url)
+        return svn_error_createf(SVN_ERR_ENTRY_MISSING_URL, NULL,
+                                 _("Path '%s' has no URL"),
+                                 svn_dirent_local_style(abspath_or_url,
+                                                        scratch_pool));
     }
   return SVN_NO_ERROR;
 }

Modified: subversion/trunk/subversion/libsvn_wc/copy.c
URL: 
http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_wc/copy.c?rev=937010&r1=937009&r2=937010&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_wc/copy.c (original)
+++ subversion/trunk/subversion/libsvn_wc/copy.c Thu Apr 22 18:59:01 2010
@@ -258,78 +258,6 @@ copy_added_dir_administratively(svn_wc_c
   return SVN_NO_ERROR;
 }
 
-/* A helper for copy_file_administratively() which sets *COPYFROM_URL
-   and *COPYFROM_REV appropriately (possibly to NULL/SVN_INVALID_REVNUM).  */
-static svn_error_t *
-determine_copyfrom_info(const char **copyfrom_url,
-                        svn_revnum_t *copyfrom_rev,
-                        svn_wc__db_t *db,
-                        const char *src_abspath,
-                        apr_pool_t *result_pool,
-                        apr_pool_t *scratch_pool)
-{
-  const char *url;
-  const char *original_root_url;
-  const char *original_repos_relpath;
-  svn_revnum_t original_revision;
-  svn_wc__db_status_t status;
-
-  url = NULL;
-  original_revision = SVN_INVALID_REVNUM;
-
-  SVN_ERR(svn_wc__db_read_info(&status, NULL, NULL, NULL, NULL, NULL, NULL,
-                               NULL, NULL, NULL, NULL, NULL, NULL, NULL,
-                               NULL, &original_repos_relpath,
-                               &original_root_url, NULL, &original_revision,
-                               NULL, NULL, NULL, NULL, NULL, db, src_abspath,
-                               scratch_pool, scratch_pool));
-  if (original_root_url && original_repos_relpath)
-    {
-      /* When copying/moving a file that was already explicitly
-         copied/moved then we know the URL it was copied from... */
-      url = svn_path_url_add_component2(original_root_url,
-                                        original_repos_relpath, scratch_pool);
-    }
-  else if (status == svn_wc__db_status_added
-           || status == svn_wc__db_status_obstructed_add)
-    {
-      /* ...But if this file is merely the descendant of an explicitly
-         copied/moved directory, we need to do a bit more work to
-         determine copyfrom_url and copyfrom_rev. */
-      const char *op_root_abspath;
-
-      SVN_ERR(svn_wc__db_scan_addition(&status, &op_root_abspath, NULL, NULL,
-                                       NULL, &original_repos_relpath,
-                                       &original_root_url, NULL,
-                                       &original_revision, db, src_abspath,
-                                       scratch_pool, scratch_pool));
-      if (status == svn_wc__db_status_copied ||
-          status == svn_wc__db_status_moved_here)
-        {
-          const char *src_parent_url;
-          const char *src_relpath;
-
-          src_parent_url = svn_path_url_add_component2(original_root_url,
-                                                       original_repos_relpath,
-                                                       scratch_pool);
-          src_relpath = svn_dirent_is_child(op_root_abspath, src_abspath,
-                                            scratch_pool);
-          if (src_relpath)
-            url = svn_path_url_add_component2(src_parent_url, src_relpath,
-                                              scratch_pool);
-        }
-    }
-
-  if (url)
-    *copyfrom_url = apr_pstrdup(result_pool, url);
-  else
-    *copyfrom_url = NULL;
-  *copyfrom_rev = original_revision;
-
-  return SVN_NO_ERROR;
-}
-
-
 /* This function effectively creates and schedules a file for
    addition, but does extra administrative things to allow it to
    function as a 'copy'.
@@ -420,9 +348,9 @@ copy_file_administratively(svn_wc_contex
        but not committed? */
     if (src_entry->copied)
       {
-        SVN_ERR(determine_copyfrom_info(&copyfrom_url, &copyfrom_rev, db,
-                                        src_abspath,
-                                        scratch_pool, scratch_pool));
+        SVN_ERR(svn_wc__node_get_copyfrom_info(&copyfrom_url, &copyfrom_rev,
+                                               wc_ctx, src_abspath,
+                                               scratch_pool, scratch_pool));
 
         /* If the COPYFROM information is the SAME as the destination
            URL/REVISION, then omit the copyfrom info.  */
@@ -762,9 +690,9 @@ copy_dir_administratively(svn_wc_context
         SVN_ERR(svn_wc__get_entry(&dst_entry, db, dst_abspath, TRUE,
                                   svn_node_dir, TRUE,
                                   scratch_pool, scratch_pool));
-        SVN_ERR(determine_copyfrom_info(&copyfrom_url, &copyfrom_rev, db,
-                                        src_abspath,
-                                        scratch_pool, scratch_pool));
+        SVN_ERR(svn_wc__node_get_copyfrom_info(&copyfrom_url, &copyfrom_rev,
+                                               wc_ctx, src_abspath,
+                                               scratch_pool, scratch_pool));
 
         /* If the COPYFROM information is the SAME as the destination
            URL/REVISION, then omit the copyfrom info.  */

Modified: subversion/trunk/subversion/libsvn_wc/node.c
URL: 
http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_wc/node.c?rev=937010&r1=937009&r2=937010&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_wc/node.c (original)
+++ subversion/trunk/subversion/libsvn_wc/node.c Thu Apr 22 18:59:01 2010
@@ -350,11 +350,12 @@ svn_wc__node_get_copyfrom_info(const cha
   const char *original_root_url;
   const char *original_repos_relpath;
   svn_revnum_t original_revision;
+  svn_wc__db_status_t status;
 
   *copyfrom_url = NULL;
   *copyfrom_rev = SVN_INVALID_REVNUM;
 
-  SVN_ERR(svn_wc__db_read_info(NULL, NULL, NULL, NULL, NULL, NULL, NULL,
+  SVN_ERR(svn_wc__db_read_info(&status, NULL, NULL, NULL, NULL, NULL, NULL,
                                NULL, NULL, NULL, NULL, NULL, NULL, NULL,
                                NULL, &original_repos_relpath,
                                &original_root_url, NULL, &original_revision,
@@ -362,11 +363,46 @@ svn_wc__node_get_copyfrom_info(const cha
                                local_abspath, scratch_pool, scratch_pool));
   if (original_root_url && original_repos_relpath)
     {
+      /* If this was the root of the copy then the URL is immediately
+         available... */
       *copyfrom_url = svn_path_url_add_component2(original_root_url,
                                                   original_repos_relpath,
                                                   result_pool);
       *copyfrom_rev = original_revision;
     }
+  else if (status == svn_wc__db_status_added
+           || status == svn_wc__db_status_obstructed_add)
+    {
+      /* ...But if this is merely the descendant of an explicitly
+         copied/moved directory, we need to do a bit more work to
+         determine copyfrom_url and copyfrom_rev. */
+      const char *op_root_abspath;
+
+      SVN_ERR(svn_wc__db_scan_addition(&status, &op_root_abspath, NULL, NULL,
+                                       NULL, &original_repos_relpath,
+                                       &original_root_url, NULL,
+                                       &original_revision, db, local_abspath,
+                                       scratch_pool, scratch_pool));
+      if (status == svn_wc__db_status_copied ||
+          status == svn_wc__db_status_moved_here)
+        {
+          const char *src_parent_url;
+          const char *src_relpath;
+
+          src_parent_url = svn_path_url_add_component2(original_root_url,
+                                                       original_repos_relpath,
+                                                       scratch_pool);
+          src_relpath = svn_dirent_is_child(op_root_abspath, local_abspath,
+                                            scratch_pool);
+          if (src_relpath)
+            {
+              *copyfrom_url = svn_path_url_add_component2(src_parent_url,
+                                                          src_relpath,
+                                                          result_pool);
+              *copyfrom_rev = original_revision;
+            }
+        }
+    }
 
   return SVN_NO_ERROR;
 }


Reply via email to