You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@subversion.apache.org by rh...@apache.org on 2013/02/20 19:24:10 UTC

svn commit: r1448339 - in /subversion/trunk/subversion/libsvn_client: client.h externals.c list.c

Author: rhuijben
Date: Wed Feb 20 18:24:09 2013
New Revision: 1448339

URL: http://svn.apache.org/r1448339
Log:
Move some 'svn ls' functions handling externals from externals.c to list.c,
as they aren't generally reusable anyway.

* subversion/libsvn_client/client.h
  (svn_client__list_internal): Make static.
  (svn_client__list_externals): Make static.

* subversion/libsvn_client/externals.c
  (list_external_items,
   svn_client__list_externals): Move to list.c

* subversion/libsvn_client/list.c
  (includes): Add svn_wc_private.h.
  (list_externals,
   list_internal): Add prototype.

  (svn_client__list_internal): Rename to ...
  (list_internal): ... this and add documentation from .h. Update caller.
  (wrap_list_error): New function, based on externals helper.
  (list_external_items): New function. Copied from svn_client__list_externals.
    Update caller.

  (svn_client_list3): Update caller.

Modified:
    subversion/trunk/subversion/libsvn_client/client.h
    subversion/trunk/subversion/libsvn_client/externals.c
    subversion/trunk/subversion/libsvn_client/list.c

Modified: subversion/trunk/subversion/libsvn_client/client.h
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_client/client.h?rev=1448339&r1=1448338&r2=1448339&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_client/client.h (original)
+++ subversion/trunk/subversion/libsvn_client/client.h Wed Feb 20 18:24:09 2013
@@ -597,58 +597,6 @@ svn_client__switch_internal(svn_revnum_t
 
 /* ---------------------------------------------------------------- */
 
-/*** List ***/
-
-/* List the file/directory entries for PATH_OR_URL at REVISION.
-   The actual node revision selected is determined by the path as 
-   it exists in PEG_REVISION.  
-   
-   If DEPTH is svn_depth_infinity, then list all file and directory entries 
-   recursively.  Else if DEPTH is svn_depth_files, list all files under 
-   PATH_OR_URL (if any), but not subdirectories.  Else if DEPTH is
-   svn_depth_immediates, list all files and include immediate
-   subdirectories (at svn_depth_empty).  Else if DEPTH is
-   svn_depth_empty, just list PATH_OR_URL with none of its entries.
- 
-   DIRENT_FIELDS controls which fields in the svn_dirent_t's are
-   filled in.  To have them totally filled in use SVN_DIRENT_ALL,
-   otherwise simply bitwise OR together the combination of SVN_DIRENT_*
-   fields you care about.
- 
-   If FETCH_LOCKS is TRUE, include locks when reporting directory entries.
- 
-   If INCLUDE_EXTERNALS is TRUE, also list all external items 
-   reached by recursion.  DEPTH value passed to the original list target
-   applies for the externals also.  EXTERNAL_PARENT_URL is url of the 
-   directory which has the externals definitions.  EXTERNAL_TARGET is the
-   target subdirectory of externals definitions.
-
-   Report directory entries by invoking LIST_FUNC/BATON. 
-   Pass EXTERNAL_PARENT_URL and EXTERNAL_TARGET to LIST_FUNC when external
-   items are listed, otherwise both are set to NULL.
- 
-   Use authentication baton cached in CTX to authenticate against the
-   repository.
- 
-   Use POOL for all allocations.
-*/
-svn_error_t *
-svn_client__list_internal(const char *path_or_url,
-                          const svn_opt_revision_t *peg_revision,
-                          const svn_opt_revision_t *revision,
-                          svn_depth_t depth,
-                          apr_uint32_t dirent_fields,
-                          svn_boolean_t fetch_locks,
-                          svn_boolean_t include_externals,
-                          const char *external_parent_url,
-                          const char *external_target,
-                          svn_client_list_func2_t list_func,
-                          void *baton,
-                          svn_client_ctx_t *ctx,
-                          apr_pool_t *pool);
-
-/* ---------------------------------------------------------------- */
-
 /*** Inheritable Properties ***/
 
 /* Convert any svn_prop_inherited_item_t elements in INHERITED_PROPS which
@@ -1108,21 +1056,6 @@ svn_client__do_external_status(svn_clien
                                apr_pool_t *scratch_pool);
 
 
-/* List external items defined on each external in EXTERNALS, a const char *
-   externals_parent_url(url of the directory which has the externals
-   definitions) of all externals mapping to the svn_string_t * externals_desc
-   (externals description text). All other options are the same as those 
-   passed to svn_client_list(). */
-svn_error_t * 
-svn_client__list_externals(apr_hash_t *externals, 
-                           svn_depth_t depth,
-                           apr_uint32_t dirent_fields,
-                           svn_boolean_t fetch_locks,
-                           svn_client_list_func2_t list_func,
-                           void *baton,
-                           svn_client_ctx_t *ctx,
-                           apr_pool_t *scratch_pool);
-
 /* Baton for svn_client__dirent_fetcher */
 struct svn_client__dirent_fetcher_baton_t
 {

Modified: subversion/trunk/subversion/libsvn_client/externals.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_client/externals.c?rev=1448339&r1=1448338&r2=1448339&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_client/externals.c (original)
+++ subversion/trunk/subversion/libsvn_client/externals.c Wed Feb 20 18:24:09 2013
@@ -1223,105 +1223,3 @@ svn_client__do_external_status(svn_clien
   return SVN_NO_ERROR;
 }
 
-/* Walk through all the external items and list them. */
-static svn_error_t *
-list_external_items(apr_array_header_t *external_items,
-                    const char *externals_parent_url,
-                    svn_depth_t depth,
-                    apr_uint32_t dirent_fields,
-                    svn_boolean_t fetch_locks,
-                    svn_client_list_func2_t list_func,
-                    void *baton,
-                    svn_client_ctx_t *ctx,
-                    apr_pool_t *scratch_pool)
-{
-  const char *externals_parent_repos_root_url;
-  apr_pool_t *iterpool;
-  int i;
-
-  SVN_ERR(svn_client_get_repos_root(&externals_parent_repos_root_url, 
-                                    NULL /* uuid */,
-                                    externals_parent_url, ctx, 
-                                    scratch_pool, scratch_pool));
-
-  iterpool = svn_pool_create(scratch_pool);
-
-  for (i = 0; i < external_items->nelts; i++)
-    {
-      const char *resolved_url;
-
-      svn_wc_external_item2_t *item = 
-          APR_ARRAY_IDX(external_items, i, svn_wc_external_item2_t *);
-
-      svn_pool_clear(iterpool);
-
-      SVN_ERR(svn_wc__resolve_relative_external_url(
-                  &resolved_url, 
-                  item,
-                  externals_parent_repos_root_url,
-                  externals_parent_url,
-                  iterpool, iterpool));
-
-      /* List the external */
-      SVN_ERR(wrap_external_error(ctx, item->target_dir,
-                                  svn_client__list_internal(
-                                                resolved_url,
-                                                &item->peg_revision,
-                                                &item->revision,
-                                                depth, dirent_fields, 
-                                                fetch_locks,
-                                                TRUE,
-                                                externals_parent_url,
-                                                item->target_dir,
-                                                list_func, baton, ctx,
-                                                iterpool),
-                                  iterpool));
-    
-    }
-  svn_pool_destroy(iterpool);
-
-  return SVN_NO_ERROR;
-}
-      
-    
-svn_error_t * 
-svn_client__list_externals(apr_hash_t *externals, 
-                           svn_depth_t depth,
-                           apr_uint32_t dirent_fields,
-                           svn_boolean_t fetch_locks,
-                           svn_client_list_func2_t list_func,
-                           void *baton,
-                           svn_client_ctx_t *ctx,
-                           apr_pool_t *scratch_pool)
-{
-  apr_pool_t *iterpool = svn_pool_create(scratch_pool);
-  apr_hash_index_t *hi;
-
-  for (hi = apr_hash_first(scratch_pool, externals);
-       hi;
-       hi = apr_hash_next(hi))
-    {
-      const char *externals_parent_url = svn__apr_hash_index_key(hi);
-      svn_string_t *externals_desc = svn__apr_hash_index_val(hi);
-      apr_array_header_t *external_items;
-
-      svn_pool_clear(iterpool);
-
-      SVN_ERR(svn_wc_parse_externals_description3(&external_items, 
-                                                  externals_parent_url,
-                                                  externals_desc->data, 
-                                                  FALSE, iterpool));
-
-      if (! external_items->nelts)
-        continue;
-
-      SVN_ERR(list_external_items(external_items, externals_parent_url, depth,
-                                  dirent_fields, fetch_locks, list_func,
-                                  baton, ctx, iterpool));
-
-    }
-  svn_pool_destroy(iterpool);
-
-  return SVN_NO_ERROR;
-}
-

Modified: subversion/trunk/subversion/libsvn_client/list.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_client/list.c?rev=1448339&r1=1448338&r2=1448339&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_client/list.c (original)
+++ subversion/trunk/subversion/libsvn_client/list.c Wed Feb 20 18:24:09 2013
@@ -33,8 +33,36 @@
 
 #include "private/svn_fspath.h"
 #include "private/svn_ra_private.h"
+#include "private/svn_wc_private.h"
 #include "svn_private_config.h"
 
+/* Prototypes for referencing before declaration */
+static svn_error_t * 
+list_externals(apr_hash_t *externals, 
+               svn_depth_t depth,
+               apr_uint32_t dirent_fields,
+               svn_boolean_t fetch_locks,
+               svn_client_list_func2_t list_func,
+               void *baton,
+               svn_client_ctx_t *ctx,
+               apr_pool_t *scratch_pool);
+
+static svn_error_t *
+list_internal(const char *path_or_url,
+              const svn_opt_revision_t *peg_revision,
+              const svn_opt_revision_t *revision,
+              svn_depth_t depth,
+              apr_uint32_t dirent_fields,
+              svn_boolean_t fetch_locks,
+              svn_boolean_t include_externals,
+              const char *external_parent_url,
+              const char *external_target,
+              svn_client_list_func2_t list_func,
+              void *baton,
+              svn_client_ctx_t *ctx,
+              apr_pool_t *pool);
+
+
 /* Get the directory entries of DIR at REV (relative to the root of
    RA_SESSION), getting at least the fields specified by DIRENT_FIELDS.
    Use the cancellation function/baton of CTX to check for cancellation.
@@ -273,20 +301,53 @@ svn_client__ra_stat_compatible(svn_ra_se
   return SVN_NO_ERROR;
 }
 
-svn_error_t *
-svn_client__list_internal(const char *path_or_url,
-                          const svn_opt_revision_t *peg_revision,
-                          const svn_opt_revision_t *revision,
-                          svn_depth_t depth,
-                          apr_uint32_t dirent_fields,
-                          svn_boolean_t fetch_locks,
-                          svn_boolean_t include_externals,
-                          const char *external_parent_url,
-                          const char *external_target,
-                          svn_client_list_func2_t list_func,
-                          void *baton,
-                          svn_client_ctx_t *ctx,
-                          apr_pool_t *pool)
+/* List the file/directory entries for PATH_OR_URL at REVISION.
+   The actual node revision selected is determined by the path as 
+   it exists in PEG_REVISION.  
+   
+   If DEPTH is svn_depth_infinity, then list all file and directory entries 
+   recursively.  Else if DEPTH is svn_depth_files, list all files under 
+   PATH_OR_URL (if any), but not subdirectories.  Else if DEPTH is
+   svn_depth_immediates, list all files and include immediate
+   subdirectories (at svn_depth_empty).  Else if DEPTH is
+   svn_depth_empty, just list PATH_OR_URL with none of its entries.
+ 
+   DIRENT_FIELDS controls which fields in the svn_dirent_t's are
+   filled in.  To have them totally filled in use SVN_DIRENT_ALL,
+   otherwise simply bitwise OR together the combination of SVN_DIRENT_*
+   fields you care about.
+ 
+   If FETCH_LOCKS is TRUE, include locks when reporting directory entries.
+ 
+   If INCLUDE_EXTERNALS is TRUE, also list all external items 
+   reached by recursion.  DEPTH value passed to the original list target
+   applies for the externals also.  EXTERNAL_PARENT_URL is url of the 
+   directory which has the externals definitions.  EXTERNAL_TARGET is the
+   target subdirectory of externals definitions.
+
+   Report directory entries by invoking LIST_FUNC/BATON. 
+   Pass EXTERNAL_PARENT_URL and EXTERNAL_TARGET to LIST_FUNC when external
+   items are listed, otherwise both are set to NULL.
+ 
+   Use authentication baton cached in CTX to authenticate against the
+   repository.
+ 
+   Use POOL for all allocations.
+*/
+static svn_error_t *
+list_internal(const char *path_or_url,
+              const svn_opt_revision_t *peg_revision,
+              const svn_opt_revision_t *revision,
+              svn_depth_t depth,
+              apr_uint32_t dirent_fields,
+              svn_boolean_t fetch_locks,
+              svn_boolean_t include_externals,
+              const char *external_parent_url,
+              const char *external_target,
+              svn_client_list_func2_t list_func,
+              void *baton,
+              svn_client_ctx_t *ctx,
+              apr_pool_t *pool)
 {
   svn_ra_session_t *ra_session;
   svn_client__pathrev_t *loc;
@@ -361,14 +422,145 @@ svn_client__list_internal(const char *pa
     {
       /* The 'externals' hash populated by get_dir_contents() is processed 
          here. */
-      SVN_ERR(svn_client__list_externals(externals, depth, dirent_fields, 
-                                         fetch_locks, list_func, baton,
-                                         ctx, pool));
+      SVN_ERR(list_externals(externals, depth, dirent_fields, 
+                             fetch_locks, list_func, baton,
+                             ctx, pool));
     } 
   
   return SVN_NO_ERROR;
 }
 
+static svn_error_t *
+wrap_list_error(const svn_client_ctx_t *ctx,
+                const char *target_abspath,
+                svn_error_t *err,
+                apr_pool_t *scratch_pool)
+{
+  if (err && err->apr_err != SVN_ERR_CANCELLED)
+    {
+      if (ctx->notify_func2)
+        {
+          svn_wc_notify_t *notifier = svn_wc_create_notify(
+                                            target_abspath,
+                                            svn_wc_notify_failed_external,
+                                            scratch_pool);
+          notifier->err = err;
+          ctx->notify_func2(ctx->notify_baton2, notifier, scratch_pool);
+        }
+      svn_error_clear(err);
+      return SVN_NO_ERROR;
+    }
+
+  return err;
+}
+
+
+/* Walk through all the external items and list them. */
+static svn_error_t *
+list_external_items(apr_array_header_t *external_items,
+                    const char *externals_parent_url,
+                    svn_depth_t depth,
+                    apr_uint32_t dirent_fields,
+                    svn_boolean_t fetch_locks,
+                    svn_client_list_func2_t list_func,
+                    void *baton,
+                    svn_client_ctx_t *ctx,
+                    apr_pool_t *scratch_pool)
+{
+  const char *externals_parent_repos_root_url;
+  apr_pool_t *iterpool;
+  int i;
+
+  SVN_ERR(svn_client_get_repos_root(&externals_parent_repos_root_url,
+                                    NULL /* uuid */,
+                                    externals_parent_url, ctx,
+                                    scratch_pool, scratch_pool));
+
+  iterpool = svn_pool_create(scratch_pool);
+
+  for (i = 0; i < external_items->nelts; i++)
+    {
+      const char *resolved_url;
+
+      svn_wc_external_item2_t *item =
+          APR_ARRAY_IDX(external_items, i, svn_wc_external_item2_t *);
+
+      svn_pool_clear(iterpool);
+
+      SVN_ERR(svn_wc__resolve_relative_external_url(
+                  &resolved_url,
+                  item,
+                  externals_parent_repos_root_url,
+                  externals_parent_url,
+                  iterpool, iterpool));
+
+      /* List the external */
+      SVN_ERR(wrap_list_error(ctx, item->target_dir,
+                              list_internal(resolved_url,
+                                            &item->peg_revision,
+                                            &item->revision,
+                                            depth, dirent_fields,
+                                            fetch_locks,
+                                            TRUE,
+                                            externals_parent_url,
+                                            item->target_dir,
+                                            list_func, baton, ctx,
+                                            iterpool),
+                              iterpool));
+
+    }
+  svn_pool_destroy(iterpool);
+
+  return SVN_NO_ERROR;
+}
+
+/* List external items defined on each external in EXTERNALS, a const char *
+   externals_parent_url(url of the directory which has the externals
+   definitions) of all externals mapping to the svn_string_t * externals_desc
+   (externals description text). All other options are the same as those 
+   passed to svn_client_list(). */
+static svn_error_t *
+list_externals(apr_hash_t *externals,
+               svn_depth_t depth,
+               apr_uint32_t dirent_fields,
+               svn_boolean_t fetch_locks,
+               svn_client_list_func2_t list_func,
+               void *baton,
+               svn_client_ctx_t *ctx,
+               apr_pool_t *scratch_pool)
+{
+  apr_pool_t *iterpool = svn_pool_create(scratch_pool);
+  apr_hash_index_t *hi;
+
+  for (hi = apr_hash_first(scratch_pool, externals);
+       hi;
+       hi = apr_hash_next(hi))
+    {
+      const char *externals_parent_url = svn__apr_hash_index_key(hi);
+      svn_string_t *externals_desc = svn__apr_hash_index_val(hi);
+      apr_array_header_t *external_items;
+
+      svn_pool_clear(iterpool);
+
+      SVN_ERR(svn_wc_parse_externals_description3(&external_items,
+                                                  externals_parent_url,
+                                                  externals_desc->data,
+                                                  FALSE, iterpool));
+
+      if (! external_items->nelts)
+        continue;
+
+      SVN_ERR(list_external_items(external_items, externals_parent_url, depth,
+                                  dirent_fields, fetch_locks, list_func,
+                                  baton, ctx, iterpool));
+
+    }
+  svn_pool_destroy(iterpool);
+
+  return SVN_NO_ERROR;
+}
+
+
 svn_error_t *
 svn_client_list3(const char *path_or_url,
                  const svn_opt_revision_t *peg_revision,
@@ -383,11 +575,11 @@ svn_client_list3(const char *path_or_url
                  apr_pool_t *pool)
 {
 
-  return svn_error_trace(svn_client__list_internal(path_or_url, peg_revision,
-                                                   revision, 
-                                                   depth, dirent_fields, 
-                                                   fetch_locks, 
-                                                   include_externals, 
-                                                   NULL, NULL, list_func,
-                                                   baton, ctx, pool));
+  return svn_error_trace(list_internal(path_or_url, peg_revision,
+                                       revision,
+                                       depth, dirent_fields,
+                                       fetch_locks,
+                                       include_externals,
+                                       NULL, NULL, list_func,
+                                       baton, ctx, pool));
 }