Hi!

Since I can't test it, and know too little of libsvn_wc, I ask if
any of you guys think it looks ok?

[[[
Implmenent converter function for converting svn_wc_status3_t to
svn_wc_status2_t.

* subversion/include/private/svn_wc_private.h
  (svn_wc__status2_from_3): Return svn_error_t * instead of
    svn_wc_status2_t *. Return the new status in an out parameter
    instead. I needed to be able to return errors from the entry
    fetching function. Add wc_ctx and local_abspath parameters to be
    used when fetching the entry.

* subversion/libsvn_wc/deprecated.c
  (status_4_wrapper_baton): Add wc_ctx field to be used when calling
    svn_wc__status2_from_3().
  (status4_wrapper_func): Track parameter and return value changes of
    svn_wc__status2_from_3().
  (svn_wc_get_status_editor4): Initialize wc_ctx field of the
    wrapper_baton.
  (svn_wc_status2): Track parameter and return value changes of
    svn_wc__status2_from_3().

* subversion/libsvn_wc/util.c
  (svn_wc__status2_from_3): Initialize the svn_wc_status2_t struct with
    values from svn_wc_status3_t.

* subversion/libsvn_client/deprecated.c
  (status4_wrapper_baton): Add ctx field.
  (status4_wrapper_func): Track parameter and return value changes of
    svn_wc__status2_from_3().
  (svn_client_status4): Initialize ctx field of wrapper_baton.
]]]
Index: subversion/include/private/svn_wc_private.h
===================================================================
--- subversion/include/private/svn_wc_private.h (revision 938200)
+++ subversion/include/private/svn_wc_private.h (working copy)
@@ -248,9 +248,13 @@
  * Convert from svn_wc_status3_t to svn_wc_status2_t.
  * Allocate the result in RESULT_POOL.
  */
-svn_wc_status2_t *
-svn_wc__status2_from_3(const svn_wc_status3_t *status, 
-                       apr_pool_t *result_pool);
+svn_error_t *
+svn_wc__status2_from_3(svn_wc_status2_t **status,
+                       const svn_wc_status3_t *old_status, 
+                       svn_wc_context_t *wc_ctx,
+                       const char *local_abspath,
+                       apr_pool_t *result_pool,
+                       apr_pool_t *scratch_pool);
 
 
 /**
Index: subversion/libsvn_wc/deprecated.c
===================================================================
--- subversion/libsvn_wc/deprecated.c   (revision 938200)
+++ subversion/libsvn_wc/deprecated.c   (working copy)
@@ -2230,6 +2230,7 @@
   void *old_baton;
   const char *anchor_abspath;
   const char *anchor_relpath;
+  svn_wc_context_t *wc_ctx;
 };
 
 /* */
@@ -2243,7 +2244,8 @@
   svn_wc_status2_t *dup;
   const char *path = local_abspath;
 
-  dup = svn_wc__status2_from_3(status, scratch_pool);
+  SVN_ERR(svn_wc__status2_from_3(&dup, status, swb->wc_ctx, local_abspath,
+                                 scratch_pool, scratch_pool));
 
   if (swb->anchor_abspath != NULL)
     {
@@ -2289,6 +2291,8 @@
   SVN_ERR(svn_wc__context_create_with_db(&wc_ctx, NULL /* config */,
                                          wc_db, pool));
 
+  swb->wc_ctx = wc_ctx;
+
   anchor_abspath = svn_wc__adm_access_abspath(anchor);
 
   if (!svn_dirent_is_absolute(svn_wc_adm_access_path(anchor)))
@@ -2562,7 +2566,8 @@
                                          pool));
 
   SVN_ERR(svn_wc_status3(&stat3, wc_ctx, local_abspath, pool, pool));
-  *status = svn_wc__status2_from_3(stat3, pool);
+  SVN_ERR(svn_wc__status2_from_3(status, stat3, wc_ctx, local_abspath,
+                                 pool, pool));
 
   return svn_error_return(svn_wc_context_destroy(wc_ctx));
 }
Index: subversion/libsvn_wc/util.c
===================================================================
--- subversion/libsvn_wc/util.c (revision 938200)
+++ subversion/libsvn_wc/util.c (working copy)
@@ -544,11 +544,43 @@
   return new_conflict;
 }
 
-svn_wc_status2_t *
-svn_wc__status2_from_3(const svn_wc_status3_t *status, 
-                       apr_pool_t *result_pool)
+svn_error_t *
+svn_wc__status2_from_3(svn_wc_status2_t **status,
+                       const svn_wc_status3_t *old_status, 
+                       svn_wc_context_t *wc_ctx,
+                       const char *local_abspath,
+                       apr_pool_t *result_pool,
+                       apr_pool_t *scratch_pool)
 {
-  /* ### As of r937468, status2_t and status3_t are no longer identical. We
-   * ### need to extend this function to properly do the conversion. */ 
-  return (svn_wc_status2_t *) svn_wc_dup_status3(status, result_pool);
+  const svn_wc_entry_t *entry;
+
+  if (old_status == NULL)
+    *status = NULL;
+
+  status = apr_pcalloc(result_pool, sizeof(*status));
+
+  SVN_ERR(svn_wc__get_entry(&entry, wc_ctx->db, local_abspath, TRUE,
+                            svn_node_unknown, FALSE, result_pool,
+                            scratch_pool));
+  (*status)->entry = entry;
+  (*status)->text_status = old_status->text_status;
+  (*status)->prop_status = old_status->prop_status;
+  (*status)->locked = old_status->locked;
+  (*status)->copied = old_status->copied;
+  (*status)->switched = old_status->switched;
+  (*status)->repos_text_status = old_status->repos_text_status;
+  (*status)->repos_prop_status = old_status->repos_prop_status;
+  (*status)->repos_lock = svn_lock_dup(old_status->repos_lock, result_pool);
+  (*status)->url = apr_pstrdup(result_pool, old_status->url);
+  (*status)->ood_last_cmt_rev = old_status->ood_last_cmt_rev;
+  (*status)->ood_last_cmt_date = old_status->ood_last_cmt_date;
+  (*status)->ood_kind = old_status->ood_kind;
+  (*status)->ood_last_cmt_author = old_status->ood_last_cmt_author;
+  (*status)->tree_conflict =
+    svn_wc__conflict_description_dup(old_status->tree_conflict, result_pool);
+  (*status)->file_external = old_status->file_external;
+  (*status)->pristine_text_status = old_status->pristine_text_status;
+  (*status)->pristine_prop_status = old_status->pristine_prop_status;
+
+  return SVN_NO_ERROR;
 }
Index: subversion/libsvn_client/deprecated.c
===================================================================
--- subversion/libsvn_client/deprecated.c       (revision 938200)
+++ subversion/libsvn_client/deprecated.c       (working copy)
@@ -1428,6 +1428,7 @@
 struct status4_wrapper_baton
 {
   svn_wc_status_func3_t old_func;
+  svn_client_ctx_t *ctx;
   void *old_baton;
 };
 
@@ -1439,8 +1440,12 @@
 {
   struct status4_wrapper_baton *swb = baton;
   svn_wc_status2_t *dup;
+  const char *local_abspath;
 
-  dup = svn_wc__status2_from_3(status, scratch_pool);
+  SVN_ERR(svn_dirent_get_absolute(&local_abspath, path, scratch_pool));
+  SVN_ERR(svn_wc__status2_from_3(&dup, status, swb->ctx->wc_ctx,
+                                 local_abspath, scratch_pool,
+                                 scratch_pool));
 
   return (*swb->old_func)(swb->old_baton, path, dup, scratch_pool);
 }
@@ -1460,7 +1465,7 @@
                    svn_client_ctx_t *ctx,
                    apr_pool_t *pool)
 {
-  struct status4_wrapper_baton swb = { status_func, status_baton };
+  struct status4_wrapper_baton swb = { status_func, ctx, status_baton };
 
   return svn_client_status5(result_rev, path, revision, status4_wrapper_func,
                             &swb, depth, get_all, update, no_ignore,

Reply via email to