Hi,

maybe you remember that patch of mine with a function gstein said looks like
a duplicate of svn_wc__internal_node_get_url().
http://subversion.tigris.org/ds/viewMessage.do?dsForumId=462&dsMessageId=2415782

It almost *is* a duplicate, but there's a difference...

svn_wc__internal_node_get_url() *combines* the repos_root_url and
repos_relpath to a URL. But I need them *separate*. If you want to see why,
look at get_node_uri(), which I want to eliminate, in the output of:

  svn diff -c-880555 ^/subversion/trunk | less

(This had been committed before and reverted in r880555, and now I'm giving
it some review to be able to commit it again. It "wc-ng"s the tree-conflict
detection during update.)


So, I split functionality off svn_wc__internal_node_get_url() to get a
function that does everything except combining the two URL parts into a
single string.

See attached patch that does the function split I'd like to do, so I can
then fix and commit -c-880555. -- if you like attached patch, feel free to
commit. I don't have an apache account yet.

Thanks,
~Neels
Split a function off svn_wc__internal_node_get_url() that returns the same
result, but still separated in REPOS_RELPATH and REPOS_ROOT_URL.
The new function is published in wc.h, because it is going to be used in
update_editor.c in a subsequent patch.

* subversion/libsvn_wc/node.c
   (svn_wc__internal_node_get_relpath_and_root_url): New function.
   (svn_wc__internal_node_get_url): Move some code into above function.
* subversion/libsvn_wc/wc.h:
   (svn_wc__internal_node_get_relpath_and_root_url): New function.
   (svn_wc__internal_node_get_url): Add comment.

--This line, and those below, will be ignored--
Index: subversion/libsvn_wc/node.c
===================================================================
--- subversion/libsvn_wc/node.c (revision 893783)
+++ subversion/libsvn_wc/node.c (working copy)
@@ -274,29 +274,28 @@ svn_wc__node_get_changelist(const char *
 }
 
 svn_error_t *
-svn_wc__internal_node_get_url(const char **url,
-                              svn_wc__db_t *db,
-                              const char *local_abspath,
-                              apr_pool_t *result_pool,
-                              apr_pool_t *scratch_pool)
+svn_wc__internal_node_get_relpath_and_root_url(const char **repos_relpath,
+                                               const char **repos_root_url,
+                                               svn_wc__db_t *db,
+                                               const char *local_abspath,
+                                               apr_pool_t *result_pool,
+                                               apr_pool_t *scratch_pool)
 {
   svn_wc__db_status_t status;
-  const char *repos_relpath;
-  const char *repos_root_url;
 
-  SVN_ERR(svn_wc__db_read_info(&status, NULL, NULL, &repos_relpath,
-                               &repos_root_url,
+  SVN_ERR(svn_wc__db_read_info(&status, NULL, NULL, repos_relpath,
+                               repos_root_url,
                                NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
                                NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
                                NULL, NULL, NULL,
                                db, local_abspath,
                                scratch_pool, scratch_pool));
-  if (repos_relpath == NULL)
+  if (*repos_relpath == NULL)
     {
       if (status == svn_wc__db_status_normal
           || status == svn_wc__db_status_incomplete)
         {
-          SVN_ERR(svn_wc__db_scan_base_repos(&repos_relpath, &repos_root_url,
+          SVN_ERR(svn_wc__db_scan_base_repos(repos_relpath, repos_root_url,
                                              NULL,
                                              db, local_abspath,
                                              scratch_pool, scratch_pool));
@@ -304,22 +303,46 @@ svn_wc__internal_node_get_url(const char
       else if (status == svn_wc__db_status_added
                || status == svn_wc__db_status_obstructed_add)
         {
-          SVN_ERR(svn_wc__db_scan_addition(NULL, NULL, &repos_relpath,
-                                           &repos_root_url, NULL, NULL, NULL,
+          SVN_ERR(svn_wc__db_scan_addition(NULL, NULL, repos_relpath,
+                                           repos_root_url, NULL, NULL, NULL,
                                            NULL, NULL,
                                            db, local_abspath,
                                            scratch_pool, scratch_pool));
         }
       else
         {
-          *url = NULL;
+          *repos_relpath = NULL;
+          *repos_root_url = NULL;
           return SVN_NO_ERROR;
         }
     }
 
-  SVN_ERR_ASSERT(repos_root_url != NULL && repos_relpath != NULL);
-  *url = svn_path_url_add_component2(repos_root_url, repos_relpath,
-                                     result_pool);
+  SVN_ERR_ASSERT(*repos_root_url != NULL && *repos_relpath != NULL);
+  return SVN_NO_ERROR;
+}
+
+svn_error_t *
+svn_wc__internal_node_get_url(const char **url,
+                              svn_wc__db_t *db,
+                              const char *local_abspath,
+                              apr_pool_t *result_pool,
+                              apr_pool_t *scratch_pool)
+{
+  const char *repos_relpath;
+  const char *repos_root_url;
+  
+  SVN_ERR(svn_wc__internal_node_get_relpath_and_root_url(&repos_relpath,
+                                                         &repos_root_url,
+                                                         db,
+                                                         local_abspath,
+                                                         scratch_pool,
+                                                         scratch_pool));
+
+  if (repos_relpath != NULL && repos_root_url != NULL)
+    *url = svn_path_url_add_component2(repos_root_url, repos_relpath,
+                                       result_pool);
+  else
+    *url = NULL;
 
   return SVN_NO_ERROR;
 }
Index: subversion/libsvn_wc/wc.h
===================================================================
--- subversion/libsvn_wc/wc.h   (revision 893783)
+++ subversion/libsvn_wc/wc.h   (working copy)
@@ -515,6 +515,28 @@ svn_wc__internal_is_replaced(svn_boolean
                              apr_pool_t *scratch_pool);
 
 
+/* Try to return LOCAL_ABSPATH's corresponding Subversion URL,
+ * split in *REPOS_RELPATH and *REPOS_ROOT_URL, considering the status of
+ * the node looked up in DB. Allocate *REPOS_RELPATH and *REPOS_ROOT_URL in
+ * RESULT_POOL, do all other allocations in SCRATCH_POOL.
+ * If nothing can be found about LOCAL_ABSPATH, return *REPOS_RELPATH and
+ * *REPOS_ROOT_URL as NULL.
+ * See also: svn_wc__internal_node_get_url().
+ */
+svn_error_t *
+svn_wc__internal_node_get_relpath_and_root_url(const char **repos_relpath,
+                                               const char **repos_root_url,
+                                               svn_wc__db_t *db,
+                                               const char *local_abspath,
+                                               apr_pool_t *result_pool,
+                                               apr_pool_t *scratch_pool);
+
+/* Try to return LOCAL_ABSPATH's corresponding Subversion URL in *URL,
+ * considering the status of the node looked up in DB. Allocate *URL in
+ * RESULT_POOL, do all other allocations in SCRATCH_POOL. 
+ * If nothing can be found about LOCAL_ABSPATH, return *URL as NULL.
+ * See also: svn_wc__internal_node_get_relpath_and_root_url().
+ */
 svn_error_t *
 svn_wc__internal_node_get_url(const char **url,
                               svn_wc__db_t *db,

Attachment: signature.asc
Description: OpenPGP digital signature

Reply via email to