Index: subversion/include/svn_config.h
===================================================================
--- subversion/include/svn_config.h	(revision 15456)
+++ subversion/include/svn_config.h	(working copy)
@@ -202,9 +202,12 @@
                           const char *section, const char *option,
                           svn_boolean_t value);
 
-/** A callback function used in enumerating config sections.
+/** Similar to @c svn_config_section_enumerator_t2, but is not
+ * provided with a memory pool argument.
  *
  * See svn_config_enumerate_sections() for the details of this type.
+ *
+ * @deprecated Provided for backwards compatibility with the 1.2 API.
  */
 typedef svn_boolean_t (*svn_config_section_enumerator_t)
        (const char *name, void *baton);
@@ -218,10 +221,23 @@
                                    svn_config_section_enumerator_t callback,
                                    void *baton);
 
-/** Enumerate the sections, passing @a baton and the current section's name to
- * @a callback.  Continue the enumeration if @a callback returns @c TRUE.
- * Return the number of times @a callback was called.
+/** A callback function used in enumerating config sections.
  *
+ * See svn_config_enumerate_sections2() for the details of this type.
+ *
+ * @since New in 1.3.
+ */
+typedef svn_boolean_t (*svn_config_section_enumerator_t2)
+       (const char *name, void *baton, apr_pool_t *pool);
+
+/** Enumerate the sections, passing @a baton and the current section's name
+ * to @a callback.  Continue the enumeration if @a callback returns @c TRUE.
+ * Return the number of times @a callback was called. 
+ * If @a create_iteration_pool is @c TRUE, a separate pool is created for
+ * the iteration and provided to @a callback as its @a pool argument. If it
+ * is @c FALSE, the pool provided to this function is handed over to 
+ * @a callback instead.
+ *
  * ### See kff's comment to svn_config_enumerate2().  It applies to this
  * function, too. ###
  *
@@ -231,12 +247,15 @@
  * @since New in 1.3.
  */
 int svn_config_enumerate_sections2 (svn_config_t *cfg, 
-                                    svn_config_section_enumerator_t callback,
-                                    void *baton, apr_pool_t *pool);
+                                    svn_config_section_enumerator_t2 callback,
+                                    void *baton, apr_pool_t *pool, 
+                                    svn_boolean_t create_iteration_pool);
 
-/** A callback function used in enumerating config options.
+/** Similar to @c svn_config_enumerator_t2, but is not
+ * provided with a memory pool argument.
+ * See svn_config_enumerate() for the details of this type.
  *
- * See svn_config_enumerate() for the details of this type.
+ * @deprecated Provided for backwards compatibility with the 1.2 API. 
  */
 typedef svn_boolean_t (*svn_config_enumerator_t)
        (const char *name, const char *value, void *baton);
@@ -250,10 +269,23 @@
                           svn_config_enumerator_t callback, void *baton);
 
 
+/** A callback function used in enumerating config options.
+ *
+ * See svn_config_enumerate2() for the details of this type.
+ *
+ * @since New in 1.3.
+ */
+typedef svn_boolean_t (*svn_config_enumerator_t2)
+       (const char *name, const char *value, void *baton, apr_pool_t *pool);
+
 /** Enumerate the options in @a section, passing @a baton and the current
  * option's name and value to @a callback.  Continue the enumeration if
  * @a callback returns @c TRUE.  Return the number of times @a callback 
  * was called.
+ * If @a create_iteration_pool is @c TRUE, a separate pool is created for
+ * the iteration and provided to @a callback as its @a pool argument. If it
+ * is @c FALSE, the pool provided to this function is handed over to 
+ * @a callback instead.
  *
  * ### kff asks: A more usual interface is to continue enumerating
  *     while @a callback does not return error, and if @a callback does
@@ -269,8 +301,9 @@
  * @since New in 1.3.
  */
 int svn_config_enumerate2 (svn_config_t *cfg, const char *section,
-                           svn_config_enumerator_t callback, void *baton,
-                           apr_pool_t *pool);
+                           svn_config_enumerator_t2 callback, void *baton,
+                           apr_pool_t *pool,
+                           svn_boolean_t create_iteration_pool);
 
 
 /** Enumerate the group @a master_section in @a cfg.  Each variable
Index: subversion/libsvn_subr/config.c
===================================================================
--- subversion/libsvn_subr/config.c	(revision 15456)
+++ subversion/libsvn_subr/config.c	(working copy)
@@ -662,22 +662,43 @@
                                svn_config_section_enumerator_t callback,
                                void *baton)
 {
-  apr_pool_t *tmp_pool = svn_pool_create (cfg->x_pool);
-  int retval = svn_config_enumerate_sections2 (cfg, callback, baton, tmp_pool);
-  svn_pool_destroy (tmp_pool);
+  apr_hash_index_t *sec_ndx;
+  int count = 0;
+  apr_pool_t *subpool = svn_pool_create (cfg->x_pool);
 
-  return retval;
+  for (sec_ndx = apr_hash_first (subpool, cfg->sections);
+       sec_ndx != NULL;
+       sec_ndx = apr_hash_next (sec_ndx))
+    {
+      void *sec_ptr;
+      cfg_section_t *sec;
+
+      apr_hash_this (sec_ndx, NULL, NULL, &sec_ptr);
+      sec = sec_ptr;
+      ++count;
+      if (!callback (sec->name, baton))
+        break;
+    }
+
+  svn_pool_destroy (subpool);
+  return count;
 }
 
 
 int
 svn_config_enumerate_sections2 (svn_config_t *cfg,
-                                svn_config_section_enumerator_t callback,
-                                void *baton, apr_pool_t *pool)
+                                svn_config_section_enumerator_t2 callback,
+                                void *baton, apr_pool_t *pool,
+                                svn_boolean_t create_iteration_pool)
 {
   apr_hash_index_t *sec_ndx;
+  apr_pool_t *iteration_pool;
   int count = 0;
 
+  if (create_iteration_pool)
+    iteration_pool = svn_pool_create (pool);
+  else
+    iteration_pool = pool;
   for (sec_ndx = apr_hash_first (pool, cfg->sections);
        sec_ndx != NULL;
        sec_ndx = apr_hash_next (sec_ndx))
@@ -688,9 +709,13 @@
       apr_hash_this (sec_ndx, NULL, NULL, &sec_ptr);
       sec = sec_ptr;
       ++count;
-      if (!callback (sec->name, baton))
+      if (create_iteration_pool)
+        svn_pool_clear (iteration_pool);
+      if (!callback (sec->name, baton, iteration_pool))
         break;
     }
+  if (create_iteration_pool)
+    svn_pool_destroy (iteration_pool);
 
   return count;
 }
@@ -698,20 +723,21 @@
 
 
 int
-svn_config_enumerate2 (svn_config_t *cfg, const char *section,
-                       svn_config_enumerator_t callback, void *baton,
-                       apr_pool_t *pool)
+svn_config_enumerate (svn_config_t *cfg, const char *section,
+                      svn_config_enumerator_t callback, void *baton)
 {
   cfg_section_t *sec;
   apr_hash_index_t *opt_ndx;
   int count;
+  apr_pool_t *subpool;
 
   find_option (cfg, section, NULL, &sec);
   if (sec == NULL)
     return 0;
 
+  subpool = svn_pool_create (cfg->x_pool);
   count = 0;
-  for (opt_ndx = apr_hash_first (pool, sec->options);
+  for (opt_ndx = apr_hash_first (subpool, sec->options);
        opt_ndx != NULL;
        opt_ndx = apr_hash_next (opt_ndx))
     {
@@ -728,19 +754,53 @@
         break;
     }
 
+  svn_pool_destroy (subpool);
   return count;
 }
 
 
 int
-svn_config_enumerate (svn_config_t *cfg, const char *section,
-                      svn_config_enumerator_t callback, void *baton)
+svn_config_enumerate2 (svn_config_t *cfg, const char *section,
+                       svn_config_enumerator_t2 callback, void *baton,
+                       apr_pool_t *pool,
+                       svn_boolean_t create_iteration_pool)
 {
-  apr_pool_t *tmp_pool = svn_pool_create (cfg->x_pool);
-  int retval = svn_config_enumerate2 (cfg, section, callback, baton, tmp_pool);
-  svn_pool_destroy (tmp_pool);
+  cfg_section_t *sec;
+  apr_hash_index_t *opt_ndx;
+  apr_pool_t *iteration_pool;
+  int count;
 
-  return retval;
+  find_option (cfg, section, NULL, &sec);
+  if (sec == NULL)
+    return 0;
+
+  if (create_iteration_pool)
+    iteration_pool = svn_pool_create (pool);
+  else 
+    iteration_pool = pool;
+  count = 0;
+  for (opt_ndx = apr_hash_first (pool, sec->options);
+       opt_ndx != NULL;
+       opt_ndx = apr_hash_next (opt_ndx))
+    {
+      void *opt_ptr;
+      cfg_option_t *opt;
+      const char *temp_value;
+
+      apr_hash_this (opt_ndx, NULL, NULL, &opt_ptr);
+      opt = opt_ptr;
+
+      ++count;
+      make_string_from_option (&temp_value, cfg, sec, opt, NULL);
+      if (create_iteration_pool)
+        svn_pool_clear (iteration_pool);
+      if (!callback (opt->name, temp_value, baton, iteration_pool))
+        break;
+    }
+  if (create_iteration_pool)
+    svn_pool_destroy (iteration_pool);
+
+  return count;
 }
 
 
@@ -759,16 +819,17 @@
  */
 static svn_boolean_t search_groups (const char *name,
                                     const char *value,
-                                    void *baton)
+                                    void *baton,
+                                    apr_pool_t *pool)
 {
   struct search_groups_baton *b = baton;
   apr_array_header_t *list;
 
-  list = svn_cstring_split (value, ",", TRUE, b->pool);
+  list = svn_cstring_split (value, ",", TRUE, pool);
   if (svn_cstring_match_glob_list (b->key, list))
     {
       /* Fill in the match and return false, to stop enumerating. */
-      b->match = apr_pstrdup (b->pool, name);
+      b->match = apr_pstrdup (pool, name);
       return FALSE;
     }
   else
@@ -785,7 +846,7 @@
   gb.key = key;
   gb.match = NULL;
   gb.pool = pool;
-  svn_config_enumerate2 (cfg, master_section, search_groups, &gb, pool);
+  svn_config_enumerate2 (cfg, master_section, search_groups, &gb, pool, FALSE);
   return gb.match;
 }
 
Index: subversion/libsvn_client/add.c
===================================================================
--- subversion/libsvn_client/add.c	(revision 15456)
+++ subversion/libsvn_client/add.c	(working copy)
@@ -86,7 +86,8 @@
 static svn_boolean_t
 auto_props_enumerator (const char *name,
                        const char *value,
-                       void *baton)
+                       void *baton,
+                       apr_pool_t *pool)
 {
   auto_props_baton_t *autoprops = baton;
   char *property;
@@ -169,7 +170,7 @@
   /* search for auto props */
   if (use_autoprops)
     svn_config_enumerate2 (cfg, SVN_CONFIG_SECTION_AUTO_PROPS,
-                           auto_props_enumerator, &autoprops, pool);
+                           auto_props_enumerator, &autoprops, pool, FALSE);
 
   /* if mimetype has not been set check the file */
   if (! autoprops.mimetype)
Index: subversion/libsvn_repos/authz.c
===================================================================
--- subversion/libsvn_repos/authz.c	(revision 15456)
+++ subversion/libsvn_repos/authz.c	(working copy)
@@ -30,8 +30,6 @@
 /* Information for the config enumerators called during authz
    lookup. */
 struct authz_lookup_baton {
-  apr_pool_t *pool;
-
   /* The authz configuration. */
   svn_config_t *config;
 
@@ -164,7 +162,8 @@
  * authz_baton accordingly.
  */
 static svn_boolean_t
-authz_parse_line (const char *name, const char *value, void *baton)
+authz_parse_line (const char *name, const char *value, 
+                  void *baton, apr_pool_t *pool)
 {
   struct authz_lookup_baton *b = baton;
 
@@ -179,7 +178,7 @@
       if (*name == '@')
         {
           if (!authz_group_contains_user (b->config, &name[1],
-                                          b->user, b->pool))
+                                          b->user, pool))
             return TRUE;
         }
 
@@ -208,7 +207,7 @@
  * section denies access to the subtree the baton describes.
  */
 static svn_boolean_t
-authz_parse_section (const char *section_name, void *baton)
+authz_parse_section (const char *section_name, void *baton, apr_pool_t *pool)
 {
   struct authz_lookup_baton *b = baton;
   svn_boolean_t conclusive;
@@ -223,7 +222,7 @@
   /* Work out what this section grants. */
   b->allow = b->deny = 0;
   svn_config_enumerate2 (b->config, section_name,
-                         authz_parse_line, b, b->pool);
+                         authz_parse_line, b, pool, FALSE);
 
   /* Has the section explicitely determined an access? */
   conclusive = authz_access_is_determined (b->allow, b->deny,
@@ -259,14 +258,13 @@
   const char *qualified_path;
   struct authz_lookup_baton baton = { 0 };
 
-  baton.pool = pool;
   baton.config = cfg;
   baton.user = user;
 
   /* Try to locate a repository-specific block first. */
   qualified_path = apr_pstrcat (pool, repos_name, ":", path, NULL);
   svn_config_enumerate2 (cfg, qualified_path,
-                         authz_parse_line, &baton, pool);
+                         authz_parse_line, &baton, pool, FALSE);
 
   *access_granted = authz_access_is_granted (baton.allow, baton.deny,
                                              required_access);
@@ -277,7 +275,7 @@
     return TRUE;
 
   /* No repository specific rule, try pan-repository rules. */
-  svn_config_enumerate2 (cfg, path, authz_parse_line, &baton, pool);
+  svn_config_enumerate2 (cfg, path, authz_parse_line, &baton, pool, FALSE);
 
   *access_granted = authz_access_is_granted (baton.allow, baton.deny,
                                              required_access);
@@ -303,7 +301,6 @@
 {
   struct authz_lookup_baton baton = { 0 };
 
-  baton.pool = pool;
   baton.config = cfg;
   baton.user = user;
   baton.required_access = required_access;
@@ -314,7 +311,7 @@
   baton.access = TRUE;
 
   svn_config_enumerate_sections2 (cfg, authz_parse_section,
-                                  &baton, pool);
+                                  &baton, pool, FALSE);
 
   return baton.access;
 }
@@ -387,7 +384,8 @@
    errors.  Use BATON for context and error reporting. */
 static svn_boolean_t authz_validate_rule (const char *group,
                                           const char *value,
-                                          void *baton)
+                                          void *baton,
+                                          apr_pool_t *pool)
 {
   const char *val;
   struct authz_validate_baton *b = baton;
@@ -418,12 +416,12 @@
    BATON for context and error reporting. */
 static svn_boolean_t authz_validate_group (const char *group,
                                            const char *value,
-                                           void *baton)
+                                           void *baton,
+                                           apr_pool_t *pool)
 {
   struct authz_validate_baton *b = baton;
 
-  b->err = authz_group_walk (b->config, group, apr_hash_make (b->pool),
-                             b->pool);
+  b->err = authz_group_walk (b->config, group, apr_hash_make (pool), pool);
   if (b->err)
     return FALSE;
 
@@ -435,7 +433,8 @@
 /* Callback to check the contents of the configuration section given
    by NAME.  Use BATON for context and error reporting. */
 static svn_boolean_t authz_validate_section (const char *name,
-                                             void *baton)
+                                             void *baton,
+                                             apr_pool_t *pool)
 {
   struct authz_validate_baton *b = baton;
 
@@ -443,10 +442,10 @@
      callback. Otherwise, use the rule checking callback. */
   if (strncmp (name, "groups", 6) == 0)
     svn_config_enumerate2 (b->config, name, authz_validate_group,
-                           baton, b->pool);
+                           baton, pool, FALSE);
   else
     svn_config_enumerate2 (b->config, name, authz_validate_rule,
-                           baton, b->pool);
+                           baton, pool, FALSE);
 
   if (b->err)
     return FALSE;
@@ -463,7 +462,6 @@
   svn_authz_t *authz = apr_palloc (pool, sizeof(*authz));
   struct authz_validate_baton baton = { 0 };
 
-  baton.pool = pool;
   baton.err = SVN_NO_ERROR;
 
   /* Load the rule file. */
@@ -472,7 +470,7 @@
 
   /* Step through the entire rule file, stopping on error. */
   svn_config_enumerate_sections2 (authz->cfg, authz_validate_section,
-                                  &baton, pool);
+                                  &baton, pool, FALSE);
   SVN_ERR (baton.err);
 
   *authz_p = authz;


