Author: hwright
Date: Thu May 19 08:43:48 2011
New Revision: 1124599

URL: http://svn.apache.org/viewvc?rev=1124599&view=rev
Log:
Followup to r1103771 by rev'ing the propget API to maintain our pre-1.7
sematics of returning the appropriate hash keys.

Suggested by: rhuijben

* subversion/include/svn_client.h
  (svn_client_propget4): New.
  (svn_client_propget3): Deprecate.

* subversion/svn/propget-cmd.c
  (svn_cl__propget): Call the updated API.

* subversion/svn/propedit-cmd.c
  (svn_cl_propedit): Same.

* subversion/libsvn_client/deprecated.c
  (svn_client_propget3): New wrapper.

* subversion/libsvn_client/prop_commands.c
  (svn_client_propget4): New.
  (svn_client_propget3): Remove.

Modified:
    subversion/trunk/subversion/include/svn_client.h
    subversion/trunk/subversion/libsvn_client/deprecated.c
    subversion/trunk/subversion/libsvn_client/prop_commands.c
    subversion/trunk/subversion/svn/propedit-cmd.c
    subversion/trunk/subversion/svn/propget-cmd.c

Modified: subversion/trunk/subversion/include/svn_client.h
URL: 
http://svn.apache.org/viewvc/subversion/trunk/subversion/include/svn_client.h?rev=1124599&r1=1124598&r2=1124599&view=diff
==============================================================================
--- subversion/trunk/subversion/include/svn_client.h (original)
+++ subversion/trunk/subversion/include/svn_client.h Thu May 19 08:43:48 2011
@@ -4373,12 +4373,13 @@ svn_client_revprop_set(const char *propn
                        apr_pool_t *pool);
 
 /**
- * Set @a *props to a hash table whose keys are `<tt>char *</tt>' paths,
- * prefixed by @a target (a working copy path or a URL), of items on
- * which property @a propname is set, and whose values are `#svn_string_t
- * *' representing the property value for @a propname at that path.
+ * Set @a *props to a hash table whose keys are absolute paths or URLs
+ * of items on which property @a propname is set, and whose values are
+ * `#svn_string_t *' representing the property value for @a propname
+ * at that path.
  *
- * Allocate @a *props, its keys, and its values in @a pool.
+ * Allocate @a *props, its keys, and its values in @a pool, use
+ * @a scratch_pool for temporary allocations.
  *
  * Don't store any path, not even @a target, if it does not have a
  * property named @a propname.
@@ -4410,8 +4411,30 @@ svn_client_revprop_set(const char *propn
  * If error, don't touch @a *props, otherwise @a *props is a hash table
  * even if empty.
  *
+ * @since New in 1.7.
+ */
+svn_error_t *
+svn_client_propget4(apr_hash_t **props,
+                    const char *propname,
+                    const char *target,
+                    const svn_opt_revision_t *peg_revision,
+                    const svn_opt_revision_t *revision,
+                    svn_revnum_t *actual_revnum,
+                    svn_depth_t depth,
+                    const apr_array_header_t *changelists,
+                    svn_client_ctx_t *ctx,
+                    apr_pool_t *result_pool,
+                    apr_pool_t *scratch_pool);
+
+/** 
+ * Similar to svn_client_propget4(), but with the following change to the
+ * output hash keys:  keys are `<tt>char *</tt>' paths, prefixed by
+ * @a target, which is a working copy path or a URL.
+ *
  * @since New in 1.5.
+ * @deprecated Provided for backward compatibility with the 1.6 API.
  */
+SVN_DEPRECATED
 svn_error_t *
 svn_client_propget3(apr_hash_t **props,
                     const char *propname,

Modified: subversion/trunk/subversion/libsvn_client/deprecated.c
URL: 
http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_client/deprecated.c?rev=1124599&r1=1124598&r2=1124599&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_client/deprecated.c (original)
+++ subversion/trunk/subversion/libsvn_client/deprecated.c Thu May 19 08:43:48 
2011
@@ -1604,6 +1604,67 @@ svn_client_revprop_set(const char *propn
 }
 
 svn_error_t *
+svn_client_propget3(apr_hash_t **props,
+                    const char *propname,
+                    const char *path_or_url,
+                    const svn_opt_revision_t *peg_revision,
+                    const svn_opt_revision_t *revision,
+                    svn_revnum_t *actual_revnum,
+                    svn_depth_t depth,
+                    const apr_array_header_t *changelists,
+                    svn_client_ctx_t *ctx,
+                    apr_pool_t *pool)
+{
+  const char *target;
+  apr_hash_t *temp_props;
+
+  if (svn_path_is_url(path_or_url))
+    target = path_or_url;
+  else
+    SVN_ERR(svn_dirent_get_absolute(&target, path_or_url, pool));
+
+  SVN_ERR(svn_client_propget4(&temp_props, propname, target,
+                              peg_revision, revision, actual_revnum,
+                              depth, changelists, ctx, pool, pool));
+
+  if (actual_revnum
+        && !svn_path_is_url(path_or_url)
+        && !SVN_IS_VALID_REVNUM(*actual_revnum))
+    {
+      /* Get the actual_revnum; added nodes have no revision yet, and old
+       * callers expected the mock-up revision of 0. */
+      svn_boolean_t added;
+
+      SVN_ERR(svn_wc__node_is_added(&added, ctx->wc_ctx, target, pool));
+      if (added)
+        *actual_revnum = 0;
+    }
+
+  /* We may need to fix up our hash keys for legacy callers. */
+  if (!svn_path_is_url(path_or_url) && strcmp(target, path_or_url) != 0)
+    {
+      apr_hash_index_t *hi;
+
+      *props = apr_hash_make(pool);
+      for (hi = apr_hash_first(pool, temp_props); hi;
+            hi = apr_hash_next(hi))
+        {
+          const char *abspath = svn__apr_hash_index_key(hi);
+          svn_string_t *value = svn__apr_hash_index_val(hi);
+          const char *relpath = svn_dirent_join(path_or_url,
+                                     svn_dirent_skip_ancestor(target, abspath),
+                                     pool);
+
+          apr_hash_set(*props, relpath, APR_HASH_KEY_STRING, value);
+        }
+    }
+  else
+    *props = temp_props;
+
+  return SVN_NO_ERROR;
+}
+
+svn_error_t *
 svn_client_propget2(apr_hash_t **props,
                     const char *propname,
                     const char *target,

Modified: subversion/trunk/subversion/libsvn_client/prop_commands.c
URL: 
http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_client/prop_commands.c?rev=1124599&r1=1124598&r2=1124599&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_client/prop_commands.c (original)
+++ subversion/trunk/subversion/libsvn_client/prop_commands.c Thu May 19 
08:43:48 2011
@@ -864,44 +864,44 @@ get_prop_from_wc(apr_hash_t *props,
 
 /* Note: this implementation is very similar to svn_client_proplist. */
 svn_error_t *
-svn_client_propget3(apr_hash_t **props,
+svn_client_propget4(apr_hash_t **props,
                     const char *propname,
-                    const char *path_or_url,
+                    const char *target,
                     const svn_opt_revision_t *peg_revision,
                     const svn_opt_revision_t *revision,
                     svn_revnum_t *actual_revnum,
                     svn_depth_t depth,
                     const apr_array_header_t *changelists,
                     svn_client_ctx_t *ctx,
-                    apr_pool_t *pool)
+                    apr_pool_t *result_pool,
+                    apr_pool_t *scratch_pool)
 {
   svn_revnum_t revnum;
 
   SVN_ERR(error_if_wcprop_name(propname));
+  if (!svn_path_is_url(target))
+    SVN_ERR_ASSERT(svn_dirent_is_absolute(target));
 
   peg_revision = svn_cl__rev_default_to_head_or_working(peg_revision,
-                                                        path_or_url);
+                                                        target);
   revision = svn_cl__rev_default_to_peg(revision, peg_revision);
 
-  *props = apr_hash_make(pool);
+  *props = apr_hash_make(result_pool);
 
-  if (! svn_path_is_url(path_or_url)
+  if (! svn_path_is_url(target)
       && SVN_CLIENT__REVKIND_IS_LOCAL_TO_WC(peg_revision->kind)
       && SVN_CLIENT__REVKIND_IS_LOCAL_TO_WC(revision->kind))
     {
       svn_node_kind_t kind;
       svn_boolean_t pristine;
-      const char *local_abspath;
-      svn_boolean_t added;
-
-      SVN_ERR(svn_dirent_get_absolute(&local_abspath, path_or_url, pool));
+      svn_error_t *err;
 
       /* If FALSE, we want the working revision. */
       pristine = (revision->kind == svn_opt_revision_committed
                   || revision->kind == svn_opt_revision_base);
 
-      SVN_ERR(svn_wc_read_kind(&kind, ctx->wc_ctx, local_abspath, FALSE,
-                               pool));
+      SVN_ERR(svn_wc_read_kind(&kind, ctx->wc_ctx, target, FALSE,
+                               scratch_pool));
 
       if (kind == svn_node_unknown || kind == svn_node_none)
         {
@@ -909,24 +909,25 @@ svn_client_propget3(apr_hash_t **props,
              for this function. */
           return svn_error_createf(SVN_ERR_UNVERSIONED_RESOURCE, NULL,
                                    _("'%s' is not under version control"),
-                                   svn_dirent_local_style(local_abspath,
-                                                          pool));
+                                   svn_dirent_local_style(target,
+                                                          scratch_pool));
         }
 
-      /* Get the actual_revnum; added nodes have no revision yet, and we
-       * return the mock-up revision of 0.
-       * ### TODO: get rid of this 0. */
-      SVN_ERR(svn_wc__node_is_added(&added, ctx->wc_ctx, local_abspath, pool));
-      if (added)
-        revnum = 0;
-      else
-        SVN_ERR(svn_client__get_revision_number(&revnum, NULL, ctx->wc_ctx,
-                                                local_abspath, NULL, revision,
-                                                pool));
+      err = svn_client__get_revision_number(&revnum, NULL, ctx->wc_ctx,
+                                            target, NULL, revision,
+                                            scratch_pool);
+      if (err && err->apr_err == SVN_ERR_CLIENT_BAD_REVISION)
+        {
+          svn_error_clear(err);
+          revnum = SVN_INVALID_REVNUM;
+        }
+      else if (err)
+        return svn_error_return(err);
 
-      SVN_ERR(get_prop_from_wc(*props, propname, local_abspath,
+      SVN_ERR(get_prop_from_wc(*props, propname, target,
                                pristine, kind,
-                               depth, changelists, ctx, pool, pool));
+                               depth, changelists, ctx, scratch_pool,
+                               result_pool));
     }
   else
     {
@@ -936,15 +937,15 @@ svn_client_propget3(apr_hash_t **props,
 
       /* Get an RA plugin for this filesystem object. */
       SVN_ERR(svn_client__ra_session_from_path(&ra_session, &revnum,
-                                               &url, path_or_url, NULL,
+                                               &url, target, NULL,
                                                peg_revision,
-                                               revision, ctx, pool));
+                                               revision, ctx, scratch_pool));
 
-      SVN_ERR(svn_ra_check_path(ra_session, "", revnum, &kind, pool));
+      SVN_ERR(svn_ra_check_path(ra_session, "", revnum, &kind, scratch_pool));
 
       SVN_ERR(remote_propget(*props, propname, url, "",
                              kind, revnum, ra_session,
-                             depth, pool, pool));
+                             depth, result_pool, scratch_pool));
     }
 
   if (actual_revnum)

Modified: subversion/trunk/subversion/svn/propedit-cmd.c
URL: 
http://svn.apache.org/viewvc/subversion/trunk/subversion/svn/propedit-cmd.c?rev=1124599&r1=1124598&r2=1124599&view=diff
==============================================================================
--- subversion/trunk/subversion/svn/propedit-cmd.c (original)
+++ subversion/trunk/subversion/svn/propedit-cmd.c Thu May 19 08:43:48 2011
@@ -228,11 +228,13 @@ svn_cl__propedit(apr_getopt_t *os,
           peg_revision.kind = svn_opt_revision_unspecified;
 
           /* Fetch the current property. */
-          SVN_ERR(svn_client_propget3(&props, pname_utf8, target,
+          SVN_ERR(svn_client_propget4(&props, pname_utf8,
+                                      svn_path_is_url(target)
+                                        ? target : local_abspath,
                                       &peg_revision,
                                       &(opt_state->start_revision),
                                       &base_rev, svn_depth_empty,
-                                      NULL, ctx, subpool));
+                                      NULL, ctx, subpool, subpool));
 
           /* Get the property value. */
           propval = apr_hash_get(props,

Modified: subversion/trunk/subversion/svn/propget-cmd.c
URL: 
http://svn.apache.org/viewvc/subversion/trunk/subversion/svn/propget-cmd.c?rev=1124599&r1=1124598&r2=1124599&view=diff
==============================================================================
--- subversion/trunk/subversion/svn/propget-cmd.c (original)
+++ subversion/trunk/subversion/svn/propget-cmd.c Thu May 19 08:43:48 2011
@@ -315,11 +315,15 @@ svn_cl__propget(apr_getopt_t *os,
           SVN_ERR(svn_opt_parse_path(&peg_revision, &truepath, target,
                                      subpool));
 
-          SVN_ERR(svn_client_propget3(&props, pname_utf8, truepath,
+          if (!svn_path_is_url(truepath))
+            SVN_ERR(svn_dirent_get_absolute(&truepath, truepath, subpool));
+
+          SVN_ERR(svn_client_propget4(&props, pname_utf8, truepath,
                                       &peg_revision,
                                       &(opt_state->start_revision),
                                       NULL, opt_state->depth,
-                                      opt_state->changelists, ctx, subpool));
+                                      opt_state->changelists, ctx, subpool,
+                                      subpool));
 
           /* Any time there is more than one thing to print, or where
              the path associated with a printed thing is not obvious,


Reply via email to